Skip to content

Commit

Permalink
updated pdfs ios
Browse files Browse the repository at this point in the history
  • Loading branch information
AEkaterina committed Jan 5, 2024
1 parent 6015fee commit 781f64f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/test/java/features/PdfLyrasisAndroid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Feature: Read PDF in LYRASIS Reads on Android
@smoke @logout @returnBooks @exclude_ios
Scenario: Android: Read pdfs: Table of contents: Perform check of navigation of TOC button
When Open search modal
And Search for "Being Plumville" and save bookName as 'bookNameInfo'
And Search for "A Queen From the North" and save bookName as 'bookNameInfo'
And Click GET action button on EBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Then EBOOK book with READ action button and 'bookInfo' bookInfo is present on Catalog books screen
When Open EBOOK book with READ action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Expand Down Expand Up @@ -202,7 +202,7 @@ Feature: Read PDF in LYRASIS Reads on Android
@smoke @logout @returnBooks @exclude_ios
Scenario: Android: Read pdfs: Perform check of back button
When Open search modal
And Search for "A Queen From the North" and save bookName as 'bookNameInfo'
And Search for "Being Plumville" and save bookName as 'bookNameInfo'
And Click GET action button on EBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Then EBOOK book with READ action button and 'bookInfo' bookInfo is present on Catalog books screen
When Open EBOOK book with READ action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/features/PdfPalaceIos.feature
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Feature: Read PDF in Palace Bookshelf on IOS
Scenario: Navigate by Thumbnails
When Open TOC on pdf reader screen
Then There are content list with thumbnails and chapter content on pdf toc screen
When Open random thumbnail and save the number as 'pageInfo' on pdf toc screen
When Open 2 thumbnail and save the number as 'pageInfo' on pdf toc screen
Then Page number is equal to 'pageInfo' on pdf reader screen

@tier2 @exclude_android
Expand All @@ -66,7 +66,7 @@ Feature: Read PDF in Palace Bookshelf on IOS
@tier2 @exclude_android
Scenario: Navigate by Pdf Search Results
When Open search pdf screen
And Enter 'try' text on search pdf screen
And Search for 'try' text on search pdf screen
And Open random found text and save page number as 'pageNumber' on search pdf screen
Then Page number is equal to 'pageNumber' on pdf reader screen

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/screens/pdf/ReaderPdfScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public boolean isReaderOpened() {
public int getPageNumber() {
Integer pageNumber = ActionProcessorUtils.doForIos(() -> {
openNavigationBar();
return Integer.parseInt(StringUtils.substringBetween(lblPageNumber.getAttribute(IosAttributes.NAME), "(", "/"));
return Integer.parseInt(StringUtils.substringBefore(lblPageNumber.getAttribute(IosAttributes.NAME), "/"));
});

if(pageNumber == null) {
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/screens/pdf/SearchPdfScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import aquality.appium.mobile.elements.interfaces.ITextBox;
import aquality.appium.mobile.screens.Screen;
import constants.appattributes.IosAttributes;
import framework.utilities.ActionProcessorUtils;
import framework.utilities.KeyboardUtils;
import io.appium.java_client.android.nativekey.AndroidKey;
import org.openqa.selenium.By;

import java.util.List;
Expand All @@ -15,9 +18,10 @@ public class SearchPdfScreen extends Screen {

private final ITextBox txbSearchLine = getElementFactory().getTextBox(By.xpath("//XCUIElementTypeWindow/XCUIElementTypeOther[2]//XCUIElementTypeTextField"), "Search line");
private final IButton btnDone = getElementFactory().getButton(By.xpath("//XCUIElementTypeWindow/XCUIElementTypeOther[2]//XCUIElementTypeButton"), "Apply search");
private final IButton returnKey = getElementFactory().getButton(By.xpath("//XCUIElementTypeButton[@name=\"Return\"]"), "Return key");

private static final String NUMBER_OF_FOUND_TEXT_LOCATOR_IOS = "//XCUIElementTypeCell/XCUIElementTypeStaticText[2]";
private static final String FOUND_TEXT_NUMBER_LOCATOR_IOS = "//XCUIElementTypeCell/XCUIElementTypeStaticText[@name=\"%d\"]";
private static final String FOUND_TEXT_NUMBER_LOCATOR_IOS = "//XCUIElementTypeCell[%d]/XCUIElementTypeOther[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeStaticText[2]";
private static final String FOUND_TEXT_LOCATOR_IOS = "//XCUIElementTypeCell/XCUIElementTypeStaticText[1]";

public SearchPdfScreen() {
Expand All @@ -28,6 +32,11 @@ public void enterText(String text) {
txbSearchLine.sendKeys(text);
}

public void applySearch() {
ActionProcessorUtils.doForIos(returnKey::click);
ActionProcessorUtils.doForAndroid(() -> KeyboardUtils.pressKey(AndroidKey.ENTER));
}

public String getTextFromSearchTxb() {
return txbSearchLine.getText();
}
Expand Down
9 changes: 8 additions & 1 deletion src/test/java/screens/pdf/ThumbnailsPdfScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ThumbnailsPdfScreen extends Screen {
private static final String THUMBNAIL_NUMBER_LOCATOR_ANDROID = "//android.view.View[@content-desc=\"Thumbnail of Page %d\"]";

private static final String THUMBNAIL_LOCATOR_IOS = "//XCUIElementTypeCollectionView/XCUIElementTypeCell";
private static final String THUMBNAIL_NUMBER_LOCATOR_IOS = "//XCUIElementTypeCollectionView/XCUIElementTypeCell[%d]/XCUIElementTypeStaticText";
private static final String THUMBNAIL_NUMBER_LOCATOR_IOS = "//XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeCollectionView/XCUIElementTypeCell[%d]/XCUIElementTypeStaticText";

public ThumbnailsPdfScreen() {
super(LocatorUtils.getLocator(
Expand All @@ -44,4 +44,11 @@ public int openRandomThumbnail() {
thumbnail.click();
return thumbnailNumber;
}

public void openThumbnail(int thumbnailNumber) {
ILabel thumbnail = getElementFactory().getLabel(LocatorUtils.getLocator(
new AndroidLocator(By.xpath(String.format(THUMBNAIL_NUMBER_LOCATOR_ANDROID, thumbnailNumber))),
new IosLocator(By.xpath(String.format(THUMBNAIL_NUMBER_LOCATOR_IOS, thumbnailNumber)))), "Thumbnail");
thumbnail.click();
}
}
13 changes: 13 additions & 0 deletions src/test/java/stepdefinitions/PdfSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ public void enterSearchedText(String text) {
readerPdfScreen.getSearchPdfScreen().enterText(text);
}

@When("Search for {string} text on search pdf screen")
public void searchText(String text) {
readerPdfScreen.getSearchPdfScreen().enterText(text);
readerPdfScreen.getSearchPdfScreen().applySearch();

}

@When("Open random found text and save page number as {string} on search pdf screen")
public void openRandomTextAndSavePageNumber(String pageNumberKey) {
context.add(pageNumberKey, readerPdfScreen.getSearchPdfScreen().openRandomFoundText());
Expand Down Expand Up @@ -151,6 +158,12 @@ public void openRandomThumbnail(String pageInfoKey) {
context.add(pageInfoKey, tocBookmarksPdfScreen.getThumbnailsPdfScreen().openRandomThumbnail());
}

@When("Open {} thumbnail and save the number as {string} on pdf toc screen")
public void openCurrentThumbnail(int thumbnailNumber, String pageNumberKey) {
context.add(pageNumberKey, thumbnailNumber);
tocBookmarksPdfScreen.getThumbnailsPdfScreen().openThumbnail(thumbnailNumber);
}

@When("Return to pdf reader screen from pdf toc screen")
public void returnToReaderFromTOC() {
if (tocBookmarksPdfScreen.getThumbnailsPdfScreen().areThumbnailsDisplayed() || tocBookmarksPdfScreen.getChaptersPdfScreen().areChaptersDisplayed()) {
Expand Down

0 comments on commit 781f64f

Please sign in to comment.