diff --git a/src/test/java/features/ManageLibraries.feature b/src/test/java/features/ManageLibraries.feature index e4c6c58..1f33428 100644 --- a/src/test/java/features/ManageLibraries.feature +++ b/src/test/java/features/ManageLibraries.feature @@ -80,7 +80,7 @@ Feature: Manage Libraries And Open Catalog And Switch to 'Palace Bookshelf' from side menu And Open categories by chain and chain starts from CategoryScreen: - | Summer Reading | + | Holiday Reads | And Click GET action button on the first EBOOK book on catalog books screen and save book as 'bookInfo' And Open Books Then EBOOK book with READ action button and 'bookInfo' bookInfo is present on books screen @@ -183,8 +183,8 @@ Feature: Manage Libraries | Escondido Public Library | | Granby Public Library | | Victorville City Library | - And Save 5 amount as 'amountKey' - When Tap the logo on catalog screen + And Save 6 amount as 'amountKey' + And Tap the logo on catalog screen Then The sorting of 'amountKey' libraries is alphabetical on find your library screen When Tap cancel button on find your library screen Then Category names are loaded on Catalog screen diff --git a/src/test/java/screens/AddLibraryScreen.java b/src/test/java/screens/AddLibraryScreen.java index acc94fd..de28ca6 100644 --- a/src/test/java/screens/AddLibraryScreen.java +++ b/src/test/java/screens/AddLibraryScreen.java @@ -2,7 +2,6 @@ import aquality.appium.mobile.elements.ElementType; import aquality.appium.mobile.elements.interfaces.IButton; -import aquality.appium.mobile.elements.interfaces.IElement; import aquality.appium.mobile.elements.interfaces.ILabel; import aquality.appium.mobile.elements.interfaces.ITextBox; import aquality.appium.mobile.screens.Screen; @@ -32,7 +31,8 @@ public class AddLibraryScreen extends Screen { new AndroidLocator(By.id("search_close_btn")), new IosLocator(By.xpath("//XCUIElementTypeButton[@name=\"clear.button.text\"]"))), "Clear search field button"); - private static final String LIBRARY_BUTTON_LOCATOR_ANDROID = "//android.widget.TextView[contains(@text, \"%s\")]"; + private static final String CURRENT_LIBRARY_BUTTON_LOCATOR_ANDROID = "//android.widget.TextView[contains(@text, \"%s\")]"; + private static final String LIBRARY_BUTTON_LOCATOR_ANDROID = "//androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup/android.widget.TextView[1]"; private static final String LIBRARY_BUTTON_LOCATOR_IOS = "//XCUIElementTypeStaticText[contains(@name, \"%s\")]"; @@ -108,12 +108,12 @@ public boolean isSortingOfLibrariesCorrect() { private IButton getLibraryButton(String libraryName) { return getElementFactory().getButton(LocatorUtils.getLocator( - new AndroidLocator(By.xpath(String.format(LIBRARY_BUTTON_LOCATOR_ANDROID, libraryName))), + new AndroidLocator(By.xpath(String.format(CURRENT_LIBRARY_BUTTON_LOCATOR_ANDROID, libraryName))), new IosLocator(By.xpath(String.format(LIBRARY_BUTTON_LOCATOR_IOS, libraryName)))), libraryName); } private List getLibrariesNames() { - List libraries = getElementFactory().findElements(LocatorUtils.getLocator( + List libraries = getElementFactory().findElements(LocatorUtils.getLocator( new AndroidLocator(By.xpath(LIBRARY_BUTTON_LOCATOR_ANDROID)), new IosLocator(By.xpath(LIBRARY_BUTTON_LOCATOR_IOS))), ElementType.LABEL); diff --git a/src/test/java/screens/CatalogScreen.java b/src/test/java/screens/CatalogScreen.java index 7492a88..966ae6c 100644 --- a/src/test/java/screens/CatalogScreen.java +++ b/src/test/java/screens/CatalogScreen.java @@ -10,6 +10,7 @@ import aquality.appium.mobile.screens.Screen; import aquality.selenium.core.elements.ElementState; import aquality.selenium.core.elements.ElementsCount; +import constants.appattributes.AndroidAttributes; import constants.appattributes.IosAttributes; import framework.utilities.ActionProcessorUtils; import framework.utilities.LocatorUtils; @@ -42,7 +43,7 @@ public class CatalogScreen extends Screen { private static final String CATEGORY_NAME_LOCATOR_ANDROID = "//android.widget.TextView[contains(@resource-id, \"feedLaneTitle\") and @text=\"%1$s\"]/parent::android.widget.LinearLayout/following-sibling::*[contains(@resource-id,\"feedLaneCoversScroll\")]"; private static final String CATEGORY_LOCATOR_ANDROID = "//androidx.recyclerview.widget.RecyclerView//android.widget.LinearLayout/android.widget.TextView[1]"; private static final String BOOK_COVER_IN_CATEGORY_LOCATOR_ANDROID = "/android.widget.FrameLayout"; - private static final String BOOK_NAME_LOCATOR_ANDROID = "//androidx.recyclerview.widget.RecyclerView[contains(@resource-id,\"feedWithoutGroupsList\")]/android.widget.FrameLayout/android.view.ViewGroup/android.widget.TextView[1]"; + private static final String BOOK_NAME_LOCATOR_ANDROID = "//androidx.recyclerview.widget.RecyclerView[contains(@resource-id,\"feedLaneCoversScroll\")]/android.widget.FrameLayout"; private static final String CURRENT_CATEGORY_LOCATOR_ANDROID = "//android.widget.TextView[contains(@resource-id, \"feedLaneTitle\") and @text=\"%1$s\"]"; private static final String MORE_BUTTON_LOCATOR_ANDROID = "//android.widget.LinearLayout/android.widget.TextView[@text=\"Moreā€¦\"]"; private static final String CURRENT_SECTION_LOCATOR_IN_CATALOG_ANDROID = "//androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[%d]/android.widget.LinearLayout/android.widget.TextView[1]"; @@ -96,7 +97,7 @@ public Set getListOfBooksNameInFirstCategory() { public List getListOfBooksNames() { List listOfBookNames = ActionProcessorUtils.doForAndroid(() -> { List listOfBooks = getElementFactory().findElements(By.xpath(BOOK_NAME_LOCATOR_ANDROID), ElementType.LABEL); - return listOfBooks.stream().map(book -> book.getText()).collect(Collectors.toList()); + return listOfBooks.stream().map(book -> book.getAttribute(AndroidAttributes.CONTENT_DESC)).collect(Collectors.toList()); }); if(listOfBookNames == null) { diff --git a/src/test/java/screens/FindYourLibraryScreen.java b/src/test/java/screens/FindYourLibraryScreen.java index 816a84f..c3ceb71 100644 --- a/src/test/java/screens/FindYourLibraryScreen.java +++ b/src/test/java/screens/FindYourLibraryScreen.java @@ -1,5 +1,6 @@ package screens; +import aquality.appium.mobile.elements.ElementType; import aquality.appium.mobile.elements.interfaces.IButton; import aquality.appium.mobile.elements.interfaces.ILabel; import aquality.appium.mobile.screens.Screen; @@ -16,16 +17,13 @@ public class FindYourLibraryScreen extends Screen { private final IButton btnAddLib = getElementFactory().getButton(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//android.widget.LinearLayout//android.widget.TextView[@text=\"Add Library\"]")), new IosLocator(By.xpath("//XCUIElementTypeScrollView//XCUIElementTypeButton[@name=\"Add Library\"]"))), "Add library button"); - private final CreatingLibraryLocator libraryLocator = (index -> - getElementFactory().getLabel(LocatorUtils.getLocator( - new AndroidLocator(By.xpath(String.format("//android.widget.LinearLayout//androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout[%d]/android.widget.LinearLayout/android.widget.TextView[1]", index))), - new IosLocator(By.xpath(String.format("//XCUIElementTypeSheet//XCUIElementTypeScrollView[2]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[%d]/XCUIElementTypeButton", index)))), "Library")); private final IButton btnCancel = getElementFactory().getButton(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//android.widget.TextView[@text=\"Cancel\"]")), new IosLocator(By.xpath("//XCUIElementTypeSheet//XCUIElementTypeScrollView//XCUIElementTypeButton[@name=\"Cancel\"]"))), "Close button"); private static final String LIBRARY_NAME_IOS = "//XCUIElementTypeSheet//XCUIElementTypeScrollView//XCUIElementTypeButton[@name=\"%s\"]"; - private static final String LIBRARY_NAME_ANDROID = "//android.widget.LinearLayout/android.widget.TextView[@text=\"%s\"]"; + private static final String CURRENT_LIBRARY_NAME_LOCATOR_ANDROID = "//android.widget.LinearLayout/android.widget.TextView[@text=\"%s\"]"; + private static final String LIBRARY_NAME_LOCATOR_ANDROID = "//androidx.recyclerview.widget.RecyclerView[contains(@resource-id,\"recyclerView\")]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.TextView[1]"; public FindYourLibraryScreen() { super(LocatorUtils.getLocator( @@ -39,12 +37,12 @@ public void tapAddLibrary() { public void tapToLibrary(String libName) { getElementFactory().getButton(LocatorUtils.getLocator( - new AndroidLocator(By.xpath(String.format(LIBRARY_NAME_ANDROID, libName))), + new AndroidLocator(By.xpath(String.format(CURRENT_LIBRARY_NAME_LOCATOR_ANDROID, libName))), new IosLocator(By.xpath(String.format(LIBRARY_NAME_IOS, libName)))), "Library button").click(); } - public boolean isSortingAlphabetical(int amountOfLibraries) { - List libraries = getListOfLibraries(amountOfLibraries); + public boolean isSortingAlphabetical(int libraryAmount) { + List libraries = getListOfLibraries(libraryAmount); return Ordering.natural().isOrdered(libraries); } @@ -52,21 +50,13 @@ public void tapCancelBtn() { btnCancel.click(); } - private List getListOfLibraries(int listSize) { - List libraries = new ArrayList<>(); - int index = 1; - int end = 0; - while (end <= listSize) { - ILabel lblLibrary = libraryLocator.createLbl(index); - libraries.add(lblLibrary.getText()); - index+=2; - end++; - } - return libraries; - } + private List getListOfLibraries(int amount) { + List libraryLabels = getElementFactory().findElements(LocatorUtils.getLocator( + new AndroidLocator(By.xpath(LIBRARY_NAME_LOCATOR_ANDROID)), + new IosLocator(By.xpath("asd"))), ElementType.LABEL); - @FunctionalInterface - interface CreatingLibraryLocator { - ILabel createLbl(int index); + List libraries = new ArrayList<>(); + libraryLabels.stream().limit(amount).forEach(label -> libraries.add(label.getText().toLowerCase())); + return libraries; } } diff --git a/src/test/java/screens/LibrariesScreen.java b/src/test/java/screens/LibrariesScreen.java index 66064bf..5caae25 100644 --- a/src/test/java/screens/LibrariesScreen.java +++ b/src/test/java/screens/LibrariesScreen.java @@ -25,9 +25,8 @@ public class LibrariesScreen extends Screen { new AndroidLocator(By.id("accountsMenuActionAccountAdd")), new IosLocator(By.xpath("//XCUIElementTypeButton[@name=\"Add Library\"]"))), "Add library button"); private final IButton btnDeleteLibrary = getElementFactory().getButton(LocatorUtils.getLocator( - new AndroidLocator(By.xpath("//android.widget.TextView[@text=\"Delete\"]")), + new AndroidLocator(By.xpath("//android.widget.Button[@text=\"Remove\"]")), new IosLocator(By.xpath("//XCUIElementTypeButton[@label=\"Delete\"]"))), "Delete library button"); - private final IButton btnAcceptDeletionAndroid = getElementFactory().getButton(By.id("android:id/button1"), "btnAcceptDeletion"); private static final String LIBRARY_NAME_LOC_IOS = "//XCUIElementTypeStaticText[@name=\"%s\"]/parent::XCUIElementTypeCell"; private static final String LIBRARY_NAME_ON_LIBRARY_SETTINGS_LOC_IOS = "//XCUIElementTypeStaticText[@name=\"%s\"]"; @@ -101,7 +100,6 @@ public void deleteLibrary(String libraryName) { ActionProcessorUtils.doForAndroid(() -> { getElementFactory().getButton(By.xpath(String.format(POPUP_MENU_BUTTON_BY_LIBRARY_NAME_LOC_ANDROID, libraryName)), "Popup menu button").click(); btnDeleteLibrary.click(); - btnAcceptDeletionAndroid.click(); }); } diff --git a/src/test/java/stepdefinitions/AccountSteps.java b/src/test/java/stepdefinitions/AccountSteps.java index 07e345a..42285eb 100644 --- a/src/test/java/stepdefinitions/AccountSteps.java +++ b/src/test/java/stepdefinitions/AccountSteps.java @@ -224,6 +224,7 @@ public void removeAccount(String libraryName) { @Then("Library {string} is not present on Libraries screen") public void checkAccountIsNotPresent(String libraryName) { + openAccounts(); Assert.assertFalse(libraryName + " is present on Accounts screen", librariesScreen.isLibraryPresent(libraryName)); } diff --git a/src/test/java/stepdefinitions/ApplicationSteps.java b/src/test/java/stepdefinitions/ApplicationSteps.java index c35d416..48c8281 100644 --- a/src/test/java/stepdefinitions/ApplicationSteps.java +++ b/src/test/java/stepdefinitions/ApplicationSteps.java @@ -176,7 +176,7 @@ public void tapTheLogo() { @Then("The sorting of {string} libraries is alphabetical on find your library screen") public void isSortingCorrect(String amountKey) { int amount = context.get(amountKey); - Assert.assertTrue("The list of libraries is not in alphabetical ored", findYourLibraryScreen.isSortingAlphabetical(amount)); + Assert.assertTrue("The list of libraries is not in alphabetical order", findYourLibraryScreen.isSortingAlphabetical(amount)); } @When("Tap cancel button on find your library screen") diff --git a/src/test/java/stepdefinitions/CatalogSteps.java b/src/test/java/stepdefinitions/CatalogSteps.java index cabf3a4..864a9b3 100644 --- a/src/test/java/stepdefinitions/CatalogSteps.java +++ b/src/test/java/stepdefinitions/CatalogSteps.java @@ -86,7 +86,7 @@ public void checkCurrentCategoryName(String expectedCategoryName) { @Then("List of books on screen is not equal to list of books saved as {string}") public void checkListOfBooksAndSavedListOfBooks(String booksNamesListKey) { List expectedList = context.get(booksNamesListKey); - List actualList = catalogBooksScreen.getListOfBooks(); + List actualList = catalogScreen.getListOfBooksNames(); Assert.assertNotEquals("Lists of books are equal" + expectedList.stream().map(Object::toString).collect(Collectors.joining(", ")), expectedList, actualList); } diff --git a/src/test/java/stepdefinitions/CredentialsSteps.java b/src/test/java/stepdefinitions/CredentialsSteps.java index 94d059b..693238d 100644 --- a/src/test/java/stepdefinitions/CredentialsSteps.java +++ b/src/test/java/stepdefinitions/CredentialsSteps.java @@ -8,6 +8,7 @@ import enums.localization.catalog.ActionButtonsForBooksAndAlertsKeys; import framework.configuration.Configuration; import framework.configuration.Credentials; +import framework.utilities.ActionProcessorUtils; import framework.utilities.ScenarioContext; import framework.utilities.returningbooksutil.APIUtil; import io.cucumber.java.en.Then; @@ -78,7 +79,7 @@ public void checkLoginIsPerformedSuccessfully() { @When("Click the log out button on the account screen") public void clickLogOut() { accountScreen.tapSignOut(); - accountScreen.tapApproveSignOut(); + ActionProcessorUtils.doForIos(accountScreen::tapApproveSignOut); if(alertScreen.state().waitForDisplayed()){ alertScreen.waitAndPerformAlertActionIfDisplayed(ActionButtonsForBooksAndAlertsKeys.SIGN_OUT); }