From e2f0e9c3a1da9bac66aba8b701be07f982992bd0 Mon Sep 17 00:00:00 2001 From: AEkaterina Date: Tue, 5 Mar 2024 02:27:57 +0400 Subject: [PATCH] added play sample --- src/test/java/features/Samples.feature | 91 ++++++++----------- src/test/java/screens/PlaySampleScreen.java | 71 +++++++++++++++ .../stepdefinitions/BookDetailsSteps.java | 5 +- .../java/stepdefinitions/PlaySampleSteps.java | 63 +++++++++++++ 4 files changed, 178 insertions(+), 52 deletions(-) create mode 100644 src/test/java/screens/PlaySampleScreen.java create mode 100644 src/test/java/stepdefinitions/PlaySampleSteps.java 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/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/stepdefinitions/BookDetailsSteps.java b/src/test/java/stepdefinitions/BookDetailsSteps.java index da48529..cbe0dcb 100644 --- a/src/test/java/stepdefinitions/BookDetailsSteps.java +++ b/src/test/java/stepdefinitions/BookDetailsSteps.java @@ -15,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 @@ -26,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") @@ -182,6 +185,6 @@ public void pressActionButtonAndAlertActionButtonOnBookDetailsScreen(ActionButto @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/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(); + } +}