-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AEkaterina
committed
Mar 4, 2024
1 parent
89e08b7
commit e2f0e9c
Showing
4 changed files
with
178 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |