diff --git a/src/test/java/features/PdfLyrasisAndroid.feature b/src/test/java/features/PdfLyrasisAndroid.feature index 1ec60ef..6e7c657 100644 --- a/src/test/java/features/PdfLyrasisAndroid.feature +++ b/src/test/java/features/PdfLyrasisAndroid.feature @@ -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' @@ -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' diff --git a/src/test/java/features/PdfPalaceIos.feature b/src/test/java/features/PdfPalaceIos.feature index ecaf2a3..4f9fe78 100644 --- a/src/test/java/features/PdfPalaceIos.feature +++ b/src/test/java/features/PdfPalaceIos.feature @@ -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 @@ -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 diff --git a/src/test/java/screens/pdf/ReaderPdfScreen.java b/src/test/java/screens/pdf/ReaderPdfScreen.java index a5ae010..07767f6 100644 --- a/src/test/java/screens/pdf/ReaderPdfScreen.java +++ b/src/test/java/screens/pdf/ReaderPdfScreen.java @@ -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) { diff --git a/src/test/java/screens/pdf/SearchPdfScreen.java b/src/test/java/screens/pdf/SearchPdfScreen.java index a673d91..7559565 100644 --- a/src/test/java/screens/pdf/SearchPdfScreen.java +++ b/src/test/java/screens/pdf/SearchPdfScreen.java @@ -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; @@ -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() { @@ -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(); } diff --git a/src/test/java/screens/pdf/ThumbnailsPdfScreen.java b/src/test/java/screens/pdf/ThumbnailsPdfScreen.java index d73802b..974a351 100644 --- a/src/test/java/screens/pdf/ThumbnailsPdfScreen.java +++ b/src/test/java/screens/pdf/ThumbnailsPdfScreen.java @@ -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( @@ -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(); + } } diff --git a/src/test/java/stepdefinitions/PdfSteps.java b/src/test/java/stepdefinitions/PdfSteps.java index 2aa3edd..f113366 100644 --- a/src/test/java/stepdefinitions/PdfSteps.java +++ b/src/test/java/stepdefinitions/PdfSteps.java @@ -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()); @@ -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()) {