diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 142d3ee..c8d79de 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -15,7 +15,7 @@ on: bs_app_link: description: 'app_url of uploaded to BS link' required: true - default: 'bs://0b0718a5fc1dc8444a6f437e2790299b731e38ef' + default: 'bs://c18a7bd4186aa3384596153ab08de6e3f157d350' build_name: description: 'build name of given application' required: true @@ -35,7 +35,7 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK 11 uses: actions/setup-java@v3 @@ -62,44 +62,5 @@ jobs: name: allure-report path: target/site/allure-maven-plugin -# - name: Get Allure history -# uses: actions/checkout@v3 -# if: always() -# continue-on-error: true -# with: -# ref: gh-pages -# path: gh-pages -# -# - name: Allure Report action from marketplace -# uses: PavanMudigonda/allure-html-reporter-github-pages@v1.0 -# if: always() -# id: allure-report -# with: -# token: ${{ secrets.PERSONAL_TOKEN }} -# WORKFLOW_ID: maven.yml -# allure_results: allure-results -# gh_pages: gh-pages -# allure_report: allure-report -# allure_history: allure-history -# -# - name: Deploy report to GitHub Pages -# if: always() -# uses: peaceiris/actions-gh-pages@v2 -# env: -# PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }} -# PUBLISH_BRANCH: gh-pages -# PUBLISH_DIR: allure-history -# keep_files: true -# -# - name: Post the link to the report -# if: always() -# uses: Sibz/github-status-action@v1 -# with: -# authToken: ${{secrets.PERSONAL_TOKEN}} -# context: 'Test report' -# state: 'success' -# sha: ${{ github.event.pull_request.head.sha || github.sha }} -# target_url: https://thepalaceproject.github.io/allure-html-reporter-github-pages/${{ github.run_number }} -# -# - name: Debug Allure Results -# run: ls -R allure-results + - name: Clean Up + run: rm -rf allure-results \ No newline at end of file diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml deleted file mode 100644 index 22b78f5..0000000 --- a/.github/workflows/sonarqube.yml +++ /dev/null @@ -1,78 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# This workflow helps you trigger a SonarQube analysis of your code and populates -# GitHub Code Scanning alerts with the vulnerabilities found. -# (this feature is available starting from SonarQube 9.7, Developer Edition and above) - -# 1. Make sure you add a valid GitHub configuration to your SonarQube (Administration > DevOps platforms > GitHub) - -# 2. Import your project on SonarQube -# * Add your repository as a new project by clicking "Create project" from your homepage. -# -# 3. Select GitHub Actions as your CI and follow the tutorial -# * a. Generate a new token and add it to your GitHub repository's secrets using the name SONAR_TOKEN -# (On SonarQube, click on your avatar on top-right > My account > Security or ask your administrator) -# -# * b. Copy/paste your SonarQube host URL to your GitHub repository's secrets using the name SONAR_HOST_URL -# -# * c. Copy/paste the project Key into the args parameter below -# (You'll find this information in SonarQube by following the tutorial or by clicking on Project Information at the top-right of your project's homepage) - -# Feel free to take a look at our documentation (https://docs.sonarqube.org/latest/analysis/github-integration/) -# or reach out to our community forum if you need some help (https://community.sonarsource.com/c/sq/10) - -name: SonarQube analysis - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - workflow_dispatch: - -permissions: - pull-requests: read # allows SonarQube to decorate PRs with analysis results - -jobs: - Analysis: - runs-on: ubuntu-latest - - steps: - - - uses: actions/checkout@v3 - env: - EXCLUDE_PATH: palace/.git - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Cache SonarQube packages - uses: actions/cache@v1 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache Maven packages - uses: actions/cache@v1 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Install SonarQube Scanner - run: | - curl -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip -o sonar-scanner.zip - unzip sonar-scanner.zip - rm sonar-scanner.zip - mv sonar-scanner-* sonar-scanner - sudo mv sonar-scanner /opt/ - sudo ln -s /opt/sonar-scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner - - name: Run SonarQube analysis - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - run: sonar-scanner -Dsonar.projectKey=Mobile_tests -Dsonar.projectName='MobileTests' -Dsonar.sources='src' -Dsonar.language='java' -Dsonar.java.binaries='src' -Dsonar.java.test.binaries='src' \ No newline at end of file diff --git a/pom.xml b/pom.xml index 919d94b..bea31a2 100644 --- a/pom.xml +++ b/pom.xml @@ -28,12 +28,6 @@ - - - - - - io.qameta.allure allure-maven @@ -157,29 +151,11 @@ 2.2.11 - - com.github.aquality-automation - aquality-tracking-cucumber5-jvm - 1.3.1 - - net.masterthought cucumber-reporting 5.7.6 test - - - com.github.aquality-automation - aquality-tracking-cucumber5-jvm - 1.3.1 - - - - - - - \ No newline at end of file diff --git a/src/test/java/features/BookDetailView.feature b/src/test/java/features/BookDetailView.feature index e7f6015..426989d 100644 --- a/src/test/java/features/BookDetailView.feature +++ b/src/test/java/features/BookDetailView.feature @@ -42,11 +42,11 @@ Feature: Book detail view screen And Book format in Information section is '' on Book details screen Scenarios: | distributor | bookType | tabName | format | - | Bibliotheca | EBOOK | eBooks | eBook | + | Bibliotheca | EBOOK | eBooks | ePub | | Bibliotheca | AUDIOBOOK | Audiobooks | Audiobook | - | Axis 360 | EBOOK | eBooks | eBook | + | Axis 360 | EBOOK | eBooks | ePub | | Axis 360 | AUDIOBOOK | Audiobooks | Audiobook | - | Palace Marketplace | EBOOK | eBooks | eBook | + | Palace Marketplace | EBOOK | eBooks | ePub | | Palace Marketplace | AUDIOBOOK | Audiobooks | Audiobook | | Biblioboard | EBOOK | eBooks | PDF | | Biblioboard | AUDIOBOOK | Audiobooks | Audiobook | @@ -83,7 +83,6 @@ Feature: Book detail view screen And Switch to '' catalog tab And Open book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' Then Book 'bookInfo' is opened on book details screen - And Publisher and Categories in Information section are displayed on book details screen And Publisher and Categories in Information section are correct on book details screen And Distributor is equal to '' on book details screen @@ -123,51 +122,6 @@ Feature: Book detail view screen | Biblioboard | EBOOK | eBooks | | Biblioboard | AUDIOBOOK | Audiobooks | - @tier2 - Scenario: Check of a book title and author in Palace Bookshelf - When Add library "Palace Bookshelf" on Add library screen - Then Library "Palace Bookshelf" is opened on Catalog screen - When Open search modal - And Search for "Persuasion" and save bookName as 'bookNameInfo' - And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' - Then Book 'bookInfo' is opened on book details screen - And Book 'bookInfo' has correct title and author name on Book details screen - And The book cover is displayed on Book details screen - - @tier2 - Scenario: Check of a "More..." button in Description section in Palace Bookshelf - When Add library "Palace Bookshelf" on Add library screen - Then Library "Palace Bookshelf" is opened on Catalog screen - When Open search modal - And Search for "Persuasion" and save bookName as 'bookNameInfo' - And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' - Then Book 'bookInfo' is opened on book details screen - And Description exists on Book details screen - And Button More in Description is available on Book details screen - - @tier2 - Scenario: Check fields in Information section in Palace Bookshelf - When Add library "Palace Bookshelf" on Add library screen - Then Library "Palace Bookshelf" is opened on Catalog screen - When Open search modal - And Search for "The Covid Archive" and save bookName as 'bookNameInfo' - And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' - Then Book 'bookInfo' is opened on book details screen - And Publisher and Categories in Information section are correct on book details screen - - @tier2 - Scenario: Check related books section in Palace Bookshelf - When Add library "Palace Bookshelf" on Add library screen - Then Library "Palace Bookshelf" is opened on Catalog screen - When Open search modal - And Search for "The Picture of Dorian Gray" and save bookName as 'bookNameInfo' - And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' - Then Book 'bookInfo' is opened on book details screen - When Swipe down - Then Related books section of 'bookInfo' book is displayed on book details screen - And There is a list of related books on book details screen - And More button in related books section is available on book details screen - @tier2 Scenario: Check of a book title and author in Overdrive When Add library "Palace Bookshelf" on Add library screen @@ -216,24 +170,6 @@ Feature: Book detail view screen And Publisher and Categories in Information section are correct on book details screen And Distributor is equal to 'Overdrive' on book details screen - @tier2 - Scenario: Check related books section in Overdrive - When Add library "Palace Bookshelf" on Add library screen - Then Library "Palace Bookshelf" is opened on Catalog screen - When Turn on test mode - And Enable hidden libraries - And Open Catalog - And Add "A1QA Test Library" account by the logo - Then Library "A1QA Test Library" is opened on Catalog screen - When Open search modal - And Search for "Little Women" and save bookName as 'bookNameInfo' - And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' - Then Book 'bookInfo' is opened on book details screen - When Swipe down - Then Related books section of 'bookInfo' book is displayed on book details screen - And There is a list of related books on book details screen - And More button in related books section is available on book details screen - @tier2 Scenario: Get button: Check of availability of required interface elements When Add library "LYRASIS Reads" on Add library screen @@ -316,7 +252,7 @@ Feature: Book detail view screen When Enter a Library card with numbers and save it as 'libraryCard' on Sign in screen And Enter a valid Password for "LYRASIS Reads" library on Sign in screen And Tap the Sign in button on Sign in screen - Then There is an alert "Invalid credentials" on Sign in screen + Then There is an alert "Invalid Credentials" on Sign in screen Scenarios: | numbers | @@ -335,9 +271,9 @@ Feature: Book detail view screen When Enter a Library card with 14 latin letters and save it as 'libraryCard' on Sign in screen And Enter a valid Password for "LYRASIS Reads" library on Sign in screen And Tap the Sign in button on Sign in screen - Then There is an alert "Invalid credentials" on Sign in screen + Then There is an alert "Invalid Credentials" on Sign in screen - @report + @tier2 Scenario: Book detail view: Perform check of Get button before log in from the Settings tab When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Catalog screen @@ -369,52 +305,4 @@ Feature: Book detail view screen Then Sing in screen is opened When Save library "LYRASIS Reads" for log out And Enter valid credentials fot "LYRASIS Reads" library on Sign in screen - Then Check that book contains READ action button on Book details screen - - # sorting doesn't work correctly -# @tier1 -# Scenario: Check of sorting books in related books in Palace -# When I add "Palace Bookshelf" account from welcomeScreen -# And I open Catalog -# And I open search modal -# And I search for "Persuasion" and save bookName as 'bookNameInfo' -# And Open EBOOK book with GET action button and 'bookNameInfo' bookName on catalog books screen and save book as 'bookInfo' -# Then Book 'bookInfo' is opened on book details screen -# When Tap More... button in related books on book details view -# And I sort books by AUTHOR -# Then Books are sorted by Author ascending -# When I save list of books as 'listOfBooks' -# And I sort books by RECENTLY_ADDED -# Then List of books on subcategory screen is not equal to list of books saved as 'listOfBooks' -# When I sort books by TITLE -# Then Books are sorted by Title ascending - - # sorting doesn't work correctly -# @tier1 -# Scenario Outline: Check of sorting books in related books in LYRASIS -# When I add "LYRASIS Reads" account from welcomeScreen -# And I open Catalog -# And I open search modal -# And I search 'available' book of distributor '' and bookType '' and save as 'bookNameInfo' -# And I switch to '' catalog tab -# And Open book with GET action button and 'bookNameInfo' bookName on catalog books screen and save book as 'bookInfo' -# Then Book 'bookInfo' is opened on book details screen -# When Tap More... button in related books on book details view -# And I sort books by AUTHOR -# Then Books are sorted by Author ascending -# When I save list of books as 'listOfBooks' -# And I sort books by RECENTLY_ADDED -# Then List of books on subcategory screen is not equal to list of books saved as 'listOfBooks' -# When I sort books by TITLE -# Then Books are sorted by Title ascending -# -# Scenarios: -# | distributor | bookType | tabName | -# | Bibliotheca | EBOOK | eBooks | -# | Bibliotheca | AUDIOBOOK | Audiobooks | -# | Axis 360 | EBOOK | eBooks | -# | Axis 360 | AUDIOBOOK | Audiobooks | -# | Palace Marketplace | EBOOK | eBooks | -# | Palace Marketplace | AUDIOBOOK | Audiobooks | -# | Biblioboard | EBOOK | eBooks | -# | Biblioboard | AUDIOBOOK | Audiobooks | \ No newline at end of file + Then Check that book contains READ action button on Book details screen \ No newline at end of file diff --git a/src/test/java/features/Samples.feature b/src/test/java/features/Samples.feature index 77989b1..cb2e485 100644 --- a/src/test/java/features/Samples.feature +++ b/src/test/java/features/Samples.feature @@ -1,28 +1,7 @@ -Feature: Check of View Sample +Feature: Check of View Sample in A1QA Test Library - @tier2 @exclude_android - Scenario: Palace Marketplace: Check of view sample - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened - When Add library "LYRASIS Reads" on Add library screen - Then Library "LYRASIS Reads" is opened on Catalog screen - When Open search modal - And Search for "The Optimistic Decade" and save bookName as 'bookNameInfo' - And Switch to "eBooks" catalog tab - And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' - And Click VIEW_SAMPLE action button on Book details screen - Then 'bookInfo' book is present on epub reader screen - When Open TOC epub screen - Then TOC screen is opened - When Close TOC epub screen - And Return to previous screen from epub - Then Book 'bookInfo' is opened on book details screen - - @tier2 @exclude_android - Scenario: Overdrive: Check of view sample in epub - When Close tutorial screen + Background: + Given Close tutorial screen Then Welcome screen is opened When Close welcome screen Then Add library screen is opened @@ -33,33 +12,43 @@ Feature: Check of View Sample And Open Catalog And Add "A1QA Test Library" account by the logo Then Library "A1QA Test Library" is opened on Catalog screen - When Open search modal - And Search for "Writing Wild" and save bookName as 'bookNameInfo' - And Switch to "eBooks" catalog tab - And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' - And Click VIEW_SAMPLE action button on Book details screen - Then Reader epub screen is opened - - @tier2 @exclude_android - Scenario: Overdrive: Check of view sample in audiobook - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened - When Add library "Palace Bookshelf" on Add library screen - Then Library "Palace Bookshelf" is opened on Catalog screen - When Turn on test mode - And Enable hidden libraries - And Open Catalog - And Add "A1QA Test Library" account by the logo - Then Library "A1QA Test Library" is opened on Catalog screen - When Open search modal - And Search for "The Lost Symbol" and save bookName as 'bookNameInfo' + When Open Catalog And Switch to "Audiobooks" catalog tab + Then Catalog screen is opened + + @tier2 + Scenario: Audiobooks: Play Sample: Sample player: Perform check of the elements + When Get AUDIOBOOK book from "OneAudio Test" category and save it as 'bookNameInfo' + And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' + And Click PLAY_SAMPLE action button on Book details screen + Then Check that Sample player screen of 'bookNameInfo' book contains all necessary elements + + @smoke @exclude_android + Scenario: iOS: Audiobooks: Play Sample: Play Sample button: Perform check of activating and deactivating sample player + When Get AUDIOBOOK book from "OneAudio Test" category and save it as 'bookNameInfo' + And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' + And Click PLAY_SAMPLE action button on Book details screen + Then Sample player screen is displayed on Books details screen + And Pause button is displayed on Sample player screen + When Click PLAY_SAMPLE action button on Book details screen + Then Play button is displayed on Sample player screen + + @smoke + Scenario: Audiobooks: Play Sample: Sample player: Perform check of pause and play buttons + When Get AUDIOBOOK book from "OneAudio Test" category and save it as 'bookNameInfo' + And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' + And Click PLAY_SAMPLE action button on Book details screen + Then Sample player screen is displayed on Books details screen + When Tap pause button on Sample player screen + Then Play button is displayed on Sample player screen + When Tap play button on Sample player screen + Then Pause button is displayed on Sample player screen + + @smoke @exclude_ios + Scenario: Android: Audiobooks: Play Sample: Sample player: Perform check of Back button + When Get AUDIOBOOK book from "OneAudio Test" category and save it as 'bookNameInfo' And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo' And Click PLAY_SAMPLE action button on Book details screen - Then Play button is present on audio player screen - When Tap play button on audio player screen - Then Pause button is present on audio player screen - When Tap pause button on audio player screen - Then Play button is present on audio player screen + Then Sample player screen is displayed on Books details screen + When Tap Back button on Sample played screen + Then Book 'bookNameInfo' is opened on book details screen \ No newline at end of file diff --git a/src/test/java/screens/CatalogBooksScreen.java b/src/test/java/screens/CatalogBooksScreen.java index c49dad8..69f7490 100644 --- a/src/test/java/screens/CatalogBooksScreen.java +++ b/src/test/java/screens/CatalogBooksScreen.java @@ -21,6 +21,7 @@ import java.time.Duration; import java.util.ArrayList; import java.util.List; +import java.util.Random; public class CatalogBooksScreen extends Screen { @@ -44,7 +45,7 @@ public class CatalogBooksScreen extends Screen { private static final String BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS = "//XCUIElementTypeStaticText[@name=\"%s\"]/following-sibling::XCUIElementTypeOther/XCUIElementTypeButton[contains(@name,\"%s\")]"; private static final String BOOK_BY_BOOK_NAME_AND_BUTTON_LOC_IOS = BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS + "/ancestor::XCUIElementTypeOther/XCUIElementTypeStaticText[1]"; - private static final String BOOK_NAME_LOCATOR_IOS = "//XCUIElementTypeCollectionView/XCUIElementTypeCell/XCUIElementTypeOther/XCUIElementTypeStaticText[1]"; + private static final String BOOK_NAME_LOCATOR_IOS = "//XCUIElementTypeCell/XCUIElementTypeOther/XCUIElementTypeStaticText[1]"; private static final String AUTHOR_BY_BOOK_NAME_AND_BUTTON_LOCATOR_IOS = BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS + "/ancestor::XCUIElementTypeOther[2]/XCUIElementTypeStaticText[2]"; private static final String PROGRESS_BAR_BY_BOOK_NAME_LOC_IOS = "//XCUIElementTypeStaticText[@name=\"%s\"]/following-sibling::XCUIElementTypeProgressIndicator"; private static final String BUTTON_ON_THE_FIRST_BOOK_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS = "//XCUIElementTypeStaticText/following-sibling::XCUIElementTypeOther/XCUIElementTypeButton[contains(@name,\"%s\")]"; @@ -82,6 +83,16 @@ public List getListOfBooks(){ return getBooksName(); } + public String getBookFromCatalogSection(){ + List bookLabels = getBooksLabels(); + Random random = new Random(); + int bookIndex = random.nextInt(bookLabels.size() - 3) + 4; + ILabel bookName = getElementFactory().getLabel(LocatorUtils.getLocator( + new AndroidLocator(By.xpath("//androidx.recyclerview.widget.RecyclerView/android.widget.FrameLayout/android.view.ViewGroup/android.widget.TextView[contains(@resource-id, \"bookCellIdleTitle\")]")), + new IosLocator(By.xpath(String.format("//XCUIElementTypeCollectionView/XCUIElementTypeCell[%d]/XCUIElementTypeOther/XCUIElementTypeStaticText[1]", bookIndex)))), "Book name"); + return bookName.getText(); + } + public String getNameOfFirstBook() { return lblNameOfFirstBook.getText(); } @@ -139,6 +150,12 @@ private List getBooksName() { return booksName; } + private List getBooksLabels() { + return getElementFactory().findElements(LocatorUtils.getLocator( + new AndroidLocator(By.xpath(BOOK_NAME_LOCATOR_ANDROID)), + new IosLocator(By.xpath(BOOK_NAME_LOCATOR_IOS))), ElementType.LABEL); + } + public CatalogBookModel clickActionButtonAndGetBookInfo(BookType bookType, String bookName, ActionButtonsForBooksAndAlertsKeys actionButtonKey) { String bookNameForLocator = bookName; if (AqualityServices.getApplication().getPlatformName() == PlatformName.IOS && BookType.AUDIOBOOK == bookType) { diff --git a/src/test/java/screens/PlaySampleScreen.java b/src/test/java/screens/PlaySampleScreen.java new file mode 100644 index 0000000..99a1ae2 --- /dev/null +++ b/src/test/java/screens/PlaySampleScreen.java @@ -0,0 +1,71 @@ +package screens; + +import aquality.appium.mobile.elements.interfaces.IButton; +import aquality.appium.mobile.elements.interfaces.ILabel; +import aquality.appium.mobile.screens.Screen; +import framework.utilities.LocatorUtils; +import models.AndroidLocator; +import models.IosLocator; +import org.openqa.selenium.By; + +public class PlaySampleScreen extends Screen { + + private final ILabel lblTimeDuration = getElementFactory().getLabel(LocatorUtils.getLocator( + new AndroidLocator(By.xpath("//android.widget.TextView[contains(@resource-id, \"player_remaining_time\")]")), + new IosLocator(By.xpath("//XCUIElementTypeStaticText[contains(@name, \"left\")]"))), "Time duration"); + private final IButton btnRewinding = getElementFactory().getButton(LocatorUtils.getLocator( + new AndroidLocator(By.xpath("//android.widget.ImageView[contains(@resource-is, \"player_jump_forwards\")]")), + new IosLocator(By.xpath("//XCUIElementTypeButton[contains(@name, \"30 Seconds\")]"))), "30 Seconds rewind"); + private final IButton btnPlay = getElementFactory().getButton(LocatorUtils.getLocator( + new AndroidLocator(By.xpath("//android.widget.ImageView[@content-desc=\"Play\"]")), + new IosLocator(By.xpath("//XCUIElementTypeButton[@name=\"Play\"]"))), "Play button"); + private final IButton btnPause = getElementFactory().getButton(LocatorUtils.getLocator( + new AndroidLocator(By.xpath("//android.widget.ImageView[@content-desc=\"Pause\"]")), + new IosLocator(By.xpath("//XCUIElementTypeButton[@name=\"Pause\"]"))), "Pause button"); + private final IButton btbBack = getElementFactory().getButton(By.xpath("//android.view.ViewGroup[contains(@content-desc=\"toolbar\")]/android.widget.ImageButton"), "Back button"); + + private static final String BOOK_NAME_LOCATOR_IOS = "//XCUIElementTypeStaticText[@name=\"%s\"]"; + + public static final String BOOK_NAME_LOCATOR_ANDROID = "//android.widget.TextView[@text=\"%s\"]"; + + public PlaySampleScreen() { + super(LocatorUtils.getLocator( + new AndroidLocator(By.xpath("")), + new IosLocator(By.xpath(""))), "Play sample screen"); + } + + public boolean isBookTitleDisplayed(String bookName) { + ILabel lblBookName = getElementFactory().getLabel(LocatorUtils.getLocator( + new AndroidLocator(By.xpath(BOOK_NAME_LOCATOR_ANDROID)), + new IosLocator(By.xpath(String.format(BOOK_NAME_LOCATOR_IOS, bookName)))), "Book name"); + return lblBookName.state().waitForDisplayed(); + } + + public boolean isTimeDurationDisplayed() { + return lblTimeDuration.state().waitForDisplayed(); + } + + public boolean isRewindingDisplayed() { + return btnRewinding.state().waitForDisplayed(); + } + + public boolean isPlayButtonDisplayed() { + return btnPlay.state().waitForDisplayed(); + } + + public boolean isPauseButtonDisplayed() { + return btnPause.state().waitForDisplayed(); + } + + public void clickPlayButton() { + btnPlay.click(); + } + + public void clickPauseButton() { + btnPause.click(); + } + + public void clickBackButton() { + btbBack.click(); + } +} diff --git a/src/test/java/screens/pdf/NavigationBarPdfScreen.java b/src/test/java/screens/pdf/NavigationBarPdfScreen.java index 3f1cdaa..e4ee07c 100644 --- a/src/test/java/screens/pdf/NavigationBarPdfScreen.java +++ b/src/test/java/screens/pdf/NavigationBarPdfScreen.java @@ -21,7 +21,7 @@ public class NavigationBarPdfScreen extends Screen { private final IButton btnSettings = getElementFactory().getButton(By.xpath("//android.widget.Button[@content-desc=\"Settings\"]"), "Settings button"); private final IButton btnBookmark = getElementFactory().getButton(LocatorUtils.getLocator( new AndroidLocator(By.xpath("")), - new IosLocator(By.xpath("//XCUIElementTypeNavigationBar//XCUIElementTypeButton[@name=\"Bookmark\"]"))), "Bookmark button"); + new IosLocator(By.xpath("//XCUIElementTypeNavigationBar//XCUIElementTypeButton[@name=\"Add Bookmark\"]"))), "Bookmark button"); public NavigationBarPdfScreen() { super(LocatorUtils.getLocator( diff --git a/src/test/java/stepdefinitions/BookDetailsSteps.java b/src/test/java/stepdefinitions/BookDetailsSteps.java index 9636289..cbe0dcb 100644 --- a/src/test/java/stepdefinitions/BookDetailsSteps.java +++ b/src/test/java/stepdefinitions/BookDetailsSteps.java @@ -5,6 +5,7 @@ import com.google.inject.Inject; import constants.RegEx; import enums.localization.catalog.ActionButtonsForBooksAndAlertsKeys; +import framework.utilities.ActionProcessorUtils; import framework.utilities.ScenarioContext; import framework.utilities.swipe.SwipeElementUtils; import io.cucumber.java.en.Then; @@ -14,10 +15,12 @@ import org.junit.Assert; import screens.AlertScreen; import screens.BookDetailsScreen; +import screens.PlaySampleScreen; public class BookDetailsSteps { private final BookDetailsScreen bookDetailsScreen; private final AlertScreen alertScreen; + private final PlaySampleScreen playSampleScreen; private final ScenarioContext context; @Inject @@ -25,6 +28,7 @@ public BookDetailsSteps(ScenarioContext context) { this.context = context; bookDetailsScreen = new BookDetailsScreen(); alertScreen = new AlertScreen(); + playSampleScreen = new PlaySampleScreen(); } @Then("Book {string} is opened on book details screen") @@ -83,6 +87,7 @@ public void checkThatBookContainsActionButton(final ActionButtonsForBooksAndAler @Then("Book format in Information section is displayed on Book details screen") public void isBookFormatDisplayed() { + ActionProcessorUtils.doForAndroid(SwipeElementUtils::swipeDown); Assert.assertTrue("Book format is not displayed", bookDetailsScreen.isBookFormatInfoExist()); } @@ -117,14 +122,18 @@ public void isInformationSectionFull() { @Then("Publisher and Categories in Information section are correct on book details screen") public void isInformationSectionIsCorrect() { SoftAssertions softAssertions = new SoftAssertions(); - if (AqualityServices.getApplication().getPlatformName()==PlatformName.ANDROID) { - SwipeElementUtils.swipeDown(); + ActionProcessorUtils.doForAndroid(SwipeElementUtils::swipeDown); + + if(bookDetailsScreen.isPublisherInfoExist()) { + String publisher = bookDetailsScreen.getPublisherInfo(); + softAssertions.assertThat(publisher.matches(RegEx.VALID_PUBLISHER_OR_CATEGORY_NAME)).as("Publisher field has invalid symbols").isTrue(); } - String publisher = bookDetailsScreen.getPublisherInfo(); - softAssertions.assertThat(publisher.matches(RegEx.VALID_PUBLISHER_OR_CATEGORY_NAME)).as("Publisher field has invalid symbols").isTrue(); - String categories = bookDetailsScreen.getCategoryInfo(); - softAssertions.assertThat(categories.matches(RegEx.VALID_PUBLISHER_OR_CATEGORY_NAME)).as("Category field has invalid symbols").isTrue(); + if(bookDetailsScreen.isCategoryInfoExist()) { + String categories = bookDetailsScreen.getCategoryInfo(); + softAssertions.assertThat(categories.matches(RegEx.VALID_PUBLISHER_OR_CATEGORY_NAME)).as("Category field has invalid symbols").isTrue(); + + } softAssertions.assertAll(); } @@ -173,4 +182,9 @@ public void pressActionButtonAndAlertActionButtonOnBookDetailsScreen(ActionButto bookDetailsScreen.clickActionButton(actionBookButtonKey); alertScreen.waitAndPerformAlertActionIfDisplayed(actionAlertButtonKey); } + + @Then("Sample player screen is displayed on Books details screen") + public void isSamplePlayerDisplayed() { + Assert.assertTrue("Sample player is not displayed", playSampleScreen.isTimeDurationDisplayed()); + } } diff --git a/src/test/java/stepdefinitions/GettingBooksStep.java b/src/test/java/stepdefinitions/GettingBooksStep.java index bdfb077..2f18029 100644 --- a/src/test/java/stepdefinitions/GettingBooksStep.java +++ b/src/test/java/stepdefinitions/GettingBooksStep.java @@ -4,6 +4,7 @@ import constants.util.UtilConstants; import enums.BookType; import enums.localization.sortoptions.AvailabilityKeys; +import framework.utilities.ActionProcessorUtils; import framework.utilities.swipe.SwipeElementUtils; import org.apache.commons.lang3.StringUtils; import screens.*; @@ -52,9 +53,16 @@ public static String getBookFromSection(String bookType, String distributor) { AqualityServices.getConditionalWait().waitFor(catalogBooksScreen::isFirstBookInCatalogDisplayed); SwipeElementUtils.swipeDown(); - List books = catalogBooksScreen.getListOfBooks(); - int bookIndex = random.nextInt(books.size()); - String bookName = books.get(bookIndex); + String bookName = ActionProcessorUtils.doForAndroid(() -> { + List books = catalogBooksScreen.getListOfBooks(); + int bookIndex = random.nextInt(books.size()); + return books.get(bookIndex); + }); + + if(bookName == null) { + bookName = ActionProcessorUtils.doForIos(catalogBooksScreen::getBookFromCatalogSection); + } + if(bookType.equalsIgnoreCase(BookType.AUDIOBOOK.getBookType())) { bookName = StringUtils.substringBefore(bookName, ". Audiobook."); } diff --git a/src/test/java/stepdefinitions/PdfSteps.java b/src/test/java/stepdefinitions/PdfSteps.java index 4855910..3da745b 100644 --- a/src/test/java/stepdefinitions/PdfSteps.java +++ b/src/test/java/stepdefinitions/PdfSteps.java @@ -141,7 +141,7 @@ public void comparePageNumbers(String pageInfoKey, String libraryName) { @Then("Current page number is equal to {string} on pdf reader screen") public void checkPageNumber(String pageNumberKey) { - String pageNumber = Integer.toString(context.get(pageNumberKey)); + String pageNumber = context.get(pageNumberKey); Assert.assertEquals("Page number is wrong", pageNumber, readerPdfScreen.getCurrentPageNumber()); } diff --git a/src/test/java/stepdefinitions/PlaySampleSteps.java b/src/test/java/stepdefinitions/PlaySampleSteps.java new file mode 100644 index 0000000..6a281d5 --- /dev/null +++ b/src/test/java/stepdefinitions/PlaySampleSteps.java @@ -0,0 +1,63 @@ +package stepdefinitions; + +import com.google.inject.Inject; +import framework.utilities.ActionProcessorUtils; +import framework.utilities.ScenarioContext; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import org.assertj.core.api.SoftAssertions; +import org.junit.Assert; +import screens.PlaySampleScreen; + +public class PlaySampleSteps { + + private final PlaySampleScreen playSampleScreen; + private final ScenarioContext context; + + @Inject + public PlaySampleSteps(ScenarioContext context) { + this.context = context; + playSampleScreen = new PlaySampleScreen(); + } + + @Then("Pause button is displayed on Sample player screen") + public void isPauseButtonDisplayed() { + Assert.assertTrue("Pause button is not displayed", playSampleScreen.isPauseButtonDisplayed()); + } + + @Then("Play button is displayed on Sample player screen") + public void isPlayButtonDisplayed() { + Assert.assertTrue("Play button is not displayed", playSampleScreen.isPlayButtonDisplayed()); + } + + @Then("Check that Sample player screen of {string} book contains all necessary elements") + public void checkElementsOnTheScreen(String bookNameKey) { + String bookName = context.get(bookNameKey); + SoftAssertions softAssertions = new SoftAssertions(); + softAssertions.assertThat(playSampleScreen.isBookTitleDisplayed(bookName)).as("Sample does not contain title").isTrue(); + softAssertions.assertThat(playSampleScreen.isTimeDurationDisplayed()).as("Time duration is not displayed").isTrue(); + softAssertions.assertThat(playSampleScreen.isRewindingDisplayed()).as("Rewinding button is not displayed").isTrue(); + ActionProcessorUtils.doForIos(() -> { + softAssertions.assertThat(playSampleScreen.isPauseButtonDisplayed()).as("Pause button is not displayed").isTrue(); + }); + ActionProcessorUtils.doForAndroid(() -> { + softAssertions.assertThat(playSampleScreen.isPlayButtonDisplayed()).as("Play button is not displayed").isTrue(); + }); + softAssertions.assertAll(); + } + + @When("Tap pause button on Sample player screen") + public void tapPauseBtn() { + playSampleScreen.clickPauseButton(); + } + + @When("Tap play button on Sample player screen") + public void tapPlayBtn() { + playSampleScreen.clickPlayButton(); + } + + @When("Tap Back button on Sample played screen") + public void tapBackBtn() { + playSampleScreen.clickBackButton(); + } +}