Skip to content

Commit

Permalink
added play sample
Browse files Browse the repository at this point in the history
  • Loading branch information
AEkaterina committed Mar 4, 2024
1 parent 89e08b7 commit e2f0e9c
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 52 deletions.
91 changes: 40 additions & 51 deletions src/test/java/features/Samples.feature
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
71 changes: 71 additions & 0 deletions src/test/java/screens/PlaySampleScreen.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
5 changes: 4 additions & 1 deletion src/test/java/stepdefinitions/BookDetailsSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@
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
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")
Expand Down Expand Up @@ -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());
}
}
63 changes: 63 additions & 0 deletions src/test/java/stepdefinitions/PlaySampleSteps.java
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit e2f0e9c

Please sign in to comment.