Skip to content

Commit

Permalink
Merge pull request #25 from ThePalaceProject/android
Browse files Browse the repository at this point in the history
Android refactoring
  • Loading branch information
AEkaterina authored Dec 22, 2023
2 parents 096ea5f + 8125d1d commit 37822ec
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 47 deletions.
7 changes: 4 additions & 3 deletions src/test/java/features/CatalogNavigation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ Feature: Catalog Navigation module
When Open Catalog
Then Catalog screen is opened
When Open categories by chain and chain starts from CategoryScreen:
| Banned Books |
| Holiday Reads |
Then Books are sorted by Author by default on subcategory screen in 'Palace Bookshelf'
And There are sorting by '<type1>', '<type2>' and '<type3>' on Subcategory screen
And There are sorting by '<type1>', '<type2>' and '<type3>' on Subcategory screen in 'Palace Bookshelf'

Scenarios:
| type1 | type2 | type3 |
Expand Down Expand Up @@ -115,8 +115,9 @@ Feature: Catalog Navigation module
Then Catalog screen is opened
When Open categories by chain and chain starts from CategoryScreen:
| Baker & Taylor Axis360 Test |
And Swipe sort options
Then Books are sorted by Author by default on subcategory screen in 'LYRASIS Reads'
And There are sorting by '<type1>', '<type2>' and '<type3>' on Subcategory screen
And There are sorting by '<type1>', '<type2>' and '<type3>' on Subcategory screen in "LYRASIS Reads"

Scenarios:
| type1 | type2 | type3 |
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/features/Distributors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Feature: Distributors
Then Library "A1QA Test Library" is opened on Libraries screen
When Enter credentials for "A1QA Test Library" library
Then Login is performed successfully
When Activate sync bookmarks on Sign in screen
When Swipe down
And Activate sync bookmarks on Sign in screen
And Open Catalog
And Open search modal
And Search for "Silk Road" and save bookName as 'bookNameInfo'
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/features/MyBooks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Feature: My books module
And Return back from search modal
And Open Books
Then Books are sorted by Author ascending on books screen
When Sort books by TITLE
When Sort books by TITLE in "Palace Bookshelf"
Then Books are sorted by Title ascending on books screen

@logout @returnBooks @tier1
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/features/RefreshFeed.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature: Feed
Then Add library screen is opened
When Add library "Palace Bookshelf" on Add library screen
And Open categories by chain and chain starts from CategoryScreen:
| Mystery |
| 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
Expand Down
41 changes: 18 additions & 23 deletions src/test/java/features/Reservations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Feature: Reservation of book in LYRASIS
When Activate sync bookmarks on Sign in screen
And Open Catalog
And Open search modal
And Search for "The Santa Suit" and save bookName as "bookNameInfo"
And Search for "Peter Pan" and save bookName as "bookNameInfo"
And Switch to 'Audiobooks' catalog tab
And Click RESERVE action button on AUDIOBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click REMOVE action button on AUDIOBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Expand All @@ -32,7 +32,7 @@ Feature: Reservation of book in LYRASIS
When Activate sync bookmarks on Sign in screen
And Open Catalog
And Open search modal
And Search for "Vanderbilt" and save bookName as "bookNameInfo"
And Search for "Ladies' Night" and save bookName as "bookNameInfo"
And Switch to 'Audiobooks' catalog tab
Then Subcategory screen is opened
When Open AUDIOBOOK book with RESERVE action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Expand All @@ -59,7 +59,7 @@ Feature: Reservation of book in LYRASIS
When Activate sync bookmarks on Sign in screen
And Open Catalog
And Open search modal
And Search for "The Song of Achilles" and save bookName as "bookNameInfo"
And Search for "The 9/11 Commission Report" and save bookName as "bookNameInfo"
And Switch to 'Audiobooks' catalog tab
Then Subcategory screen is opened
When Open AUDIOBOOK book with RESERVE action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Expand All @@ -81,7 +81,7 @@ Feature: Reservation of book in LYRASIS
When Activate sync bookmarks on Sign in screen
And Open Catalog
And Open search modal
And Search 'unavailable' book of distributor 'Bibliotheca' and bookType 'AUDIOBOOK' and save as 'bookNameInfo'
And Search for "The Secret Garden" and save bookName as 'bookNameInfo'
And Switch to 'Audiobooks' catalog tab
And Open AUDIOBOOK book with RESERVE action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Then Book 'bookInfo' is opened on book details screen
Expand All @@ -105,24 +105,24 @@ Feature: Reservation of book in LYRASIS
When Activate sync bookmarks on Sign in screen
And Open Catalog
And Open search modal
And Search 'unavailable' book of distributor 'Palace Marketplace' and bookType 'AUDIOBOOK' and save as 'bookNameInfo'
And Search for "Wwii Airmen" and save bookName as 'bookNameInfo'
And Click RESERVE action button on AUDIOBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Open Catalog
And Open search modal
And Search 'unavailable' book of distributor 'Palace Marketplace' and bookType 'AUDIOBOOK' and save as 'bookNameInfo2'
And Search for "The Secret Garden" and save bookName as 'bookNameInfo'
And Click RESERVE action button on AUDIOBOOK book with 'bookNameInfo2' bookName on Catalog books screen and save book as 'bookInfo2'
And Clear search field on Catalog books screen
And Search 'unavailable' book of distributor 'Palace Marketplace' and bookType 'AUDIOBOOK' and save as 'bookNameInfo3'
And Search for "Peter Pan" and save bookName as 'bookNameInfo'
And Click RESERVE action button on EBOOK book with 'bookNameInfo3' bookName on Catalog books screen and save book as 'bookInfo3'
And Open Reservations
Then Books are sorted by Title by default on Reservations screen
And Books are sorted by Title ascending on Reservations screen
When Sort books by AUTHOR
And Books are sorted by Title ascending on Reservations screen
When Sort books by AUTHOR in "LYRASIS Reads"
Then Books are sorted by Author ascending on Reservations screen
And There are sorting by 'Title' and 'Author' in 'LYRASIS Reads' on Reservations screen

@logout @returnBooks @tier1 @exclude_android
Scenario Outline: Alert: Check of Cancel button after Remove button tapping
Scenario: Alert: Check of Cancel button after Remove button tapping
When Close tutorial screen
Then Welcome screen is opened
When Close welcome screen
Expand All @@ -133,21 +133,16 @@ Feature: Reservation of book in LYRASIS
Then Login is performed successfully
When Open Catalog
And Open search modal
And Search 'unavailable' book of distributor '<distributor>' and bookType '<bookType>' and save as 'bookNameInfo'
And Switch to '<tabName>' catalog tab
And Open <bookType> book with RESERVE action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Search for "Wwii Airmen" and save bookName as 'bookNameInfo'
And Switch to 'Audiobooks' catalog tab
And Open AUDIOBOOK book with RESERVE action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click RESERVE action button on Book details screen
And Open Reservations
Then <bookType> book with REMOVE action button and 'bookInfo' bookInfo is present on Reservations screen
When Open <bookType> book with REMOVE action button and 'bookInfo' bookInfo on Reservations screen
Then AUDIOBOOK book with REMOVE action button and 'bookInfo' bookInfo is present on Reservations screen
When Open AUDIOBOOK book with REMOVE action button and 'bookInfo' bookInfo on Reservations screen
And Click REMOVE button but cancel the action by clicking CANCEL button on the alert
And Open Reservations
Then <bookType> book with REMOVE action button and 'bookInfo' bookInfo is present on Reservations screen

Scenarios:
| distributor | bookType | tabName |
| Bibliotheca | AUDIOBOOK | Audiobooks |
| Palace Marketplace | AUDIOBOOK | Audiobooks |
Then AUDIOBOOK book with REMOVE action button and 'bookInfo' bookInfo is present on Reservations screen

@smoke @logout @returnBooks
Scenario: Reservations: Perform check of book appearance and remove it
Expand All @@ -162,7 +157,7 @@ Feature: Reservation of book in LYRASIS
When Activate sync bookmarks on Sign in screen
And Open Catalog
And Open search modal
And Search 'unavailable' book of distributor 'Bibliotheca' and bookType 'AUDIOBOOK' and save as 'bookNameInfo'
And Search for "The Secret Garden" and save bookName as 'bookNameInfo'
And Switch to 'Audiobooks' catalog tab
And Click RESERVE action button on AUDIOBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Then AUDIOBOOK book with REMOVE action button and 'bookInfo' bookInfo is present on Catalog books screen
Expand All @@ -187,7 +182,7 @@ Feature: Reservation of book in LYRASIS
When Activate sync bookmarks on Sign in screen
And Open Catalog
And Open search modal
And Search 'unavailable' book of distributor 'Palace Marketplace' and bookType 'AUDIOBOOK' and save as 'bookNameInfo'
And Search for "The Secret Garden" and save bookName as 'bookNameInfo'
And Switch to 'Audiobooks' catalog tab
And Click RESERVE action button on AUDIOBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Then AUDIOBOOK book with REMOVE action button and 'bookInfo' bookInfo is present on Catalog books screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ public static void swipeUp() {
double toY = AqualityServices.getApplication().getDriver().manage().window().getSize().getHeight() * 0.8;
AqualityServices.getTouchActions().swipe(new Point((int) x, (int) fromY), new Point((int) x, (int) toY));
}

public static void swipeByCoordinates(double fromX, double fromY, double toX, double toY) {
AqualityServices.getTouchActions().swipe(new Point((int) fromX, (int) fromY), new Point((int) toX, (int) toY));
}
}
26 changes: 19 additions & 7 deletions src/test/java/screens/SortOptionsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
public class SortOptionsScreen extends Screen {

private final IButton btnSortBy = getElementFactory().getButton(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("//android.widget.HorizontalScrollView/android.widget.LinearLayout/android.widget.Button")),
new AndroidLocator(By.xpath("//android.widget.Button[@index=\"5\"]")),
new IosLocator(By.xpath("//XCUIElementTypeStaticText[@name=\"Sort By:\"]/following-sibling::XCUIElementTypeButton"))), "Sort by button");
private final IButton btnSortByPalace = getElementFactory().getButton(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("//android.widget.HorizontalScrollView/android.widget.LinearLayout/android.widget.Button[2]")),
new IosLocator(By.xpath("//XCUIElementTypeStaticText[@name=\"Sort By:\"]/following-sibling::XCUIElementTypeButton"))), "Sort by button");
private final IButton btnAvailability = getElementFactory().getButton(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("//*[contains(@resource-id,\"feedHeaderFacets\")]/android.widget.Button[1]")),
Expand All @@ -25,8 +28,9 @@ public class SortOptionsScreen extends Screen {
new AndroidLocator(By.xpath("")),
new IosLocator(By.xpath("//XCUIElementTypeScrollView//XCUIElementTypeButton[3]"))), "Collection button");

private static final String SORT_SELECTION_ANDROID = "//*[contains(@resource-id,\"select_dialog_listview\")]//*[@text=\"%1$s\"]";
private static final String SORT_SELECTION_IOS = "//XCUIElementTypeButton[@name=\"%1$s\"]";
private static final String SORT_SELECTION_LOCATOR_ANDROID = "//*[contains(@resource-id,\"select_dialog_listview\")]//*[@text=\"%1$s\"]";
private static final String SORT_OPTION_LOCATOR_ANDROID = "//android.widget.TextView[@text=\"%1$s\"]";
private static final String SORT_SELECTION_LOCATOR_IOS = "//XCUIElementTypeButton[@name=\"%1$s\"]";
private static final String OPTIONS_IN_TABS_LOCATOR_IOS = "//XCUIElementTypeWindow/XCUIElementTypeOther[2]//XCUIElementTypeScrollView//XCUIElementTypeButton";

private final BtnGetVariantsOfSorting btnVariantOfSorting = (button ->
Expand All @@ -41,8 +45,12 @@ public SortOptionsScreen(){
new IosLocator(By.xpath("//XCUIElementTypeCollectionView/preceding-sibling::XCUIElementTypeOther"))), "Sort options screen");
}

public void openSortBy() {
btnSortBy.click();
public void openSortBy(String libraryName) {
if(libraryName.equals("Palace Bookshelf")) {
btnSortByPalace.click();
} else {
btnSortBy.click();
}
}

public String getTypeVariantsOfBtn(String type) {
Expand Down Expand Up @@ -72,10 +80,14 @@ public List<String> getOptionsInTabs() {
return options;
}

public boolean isSortOptionDisplayed(String sortOption) {
return getElementFactory().getButton(By.xpath(String.format(SORT_OPTION_LOCATOR_ANDROID, sortOption)), "Sort option").state().waitForDisplayed();
}

private void setSortSelection(String value) {
getElementFactory().getButton(LocatorUtils.getLocator(
new AndroidLocator(By.xpath(String.format(SORT_SELECTION_ANDROID, value))),
new IosLocator(By.xpath(String.format(SORT_SELECTION_IOS, value)))), "Sorting value " + value).click();
new AndroidLocator(By.xpath(String.format(SORT_SELECTION_LOCATOR_ANDROID, value))),
new IosLocator(By.xpath(String.format(SORT_SELECTION_LOCATOR_IOS, value)))), "Sorting value " + value).click();
}

@FunctionalInterface
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/screens/SubcategoryScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class SubcategoryScreen extends Screen {
new AndroidLocator(By.xpath("//android.widget.HorizontalScrollView/android.widget.LinearLayout/android.widget.Button[2]")),
new IosLocator(By.xpath("//XCUIElementTypeScrollView//XCUIElementTypeButton[1]"))), "Sort by button in Palace");
private final IButton btnSorting = getElementFactory().getButton(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("//android.widget.HorizontalScrollView/android.widget.LinearLayout/android.widget.Button")),
new AndroidLocator(By.xpath("//android.widget.Button[@index=\"5\"]")),
new IosLocator(By.xpath("//XCUIElementTypeScrollView//XCUIElementTypeButton[1]"))), "Sort by button");
private final IButton btnAvailability = getElementFactory().getButton(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("//android.widget.HorizontalScrollView//android.widget.Button[1]")),
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/stepdefinitions/AccountSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void typeWord(String word, String wordKey){
@Then("Libraries contain word {string} on Add library screen")
public void isLibraryContainsWord(String wordKey) {
String word = context.get(wordKey);
Assert.assertTrue("Search result does not contain libraries with " + word, addLibraryScreen.isLibraryContainsWord(word));
Assert.assertTrue("Search result does not contain libraries with " + word, addLibraryScreen.isLibraryContainsWord(word.toLowerCase()));
}

@Then("Search result is empty on Add library screen")
Expand Down
24 changes: 18 additions & 6 deletions src/test/java/stepdefinitions/CatalogSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,36 @@ public void tapBackBtn() {
subcategoryScreen.tapBack();
}

@When("Swipe sort options")
public void swipeSortOptions() {
double fromX = 870;
double fromY = 350;
double toX = 100;
double toY = 350;

SwipeElementUtils.swipeByCoordinates(fromX, fromY, toX, toY);
SwipeElementUtils.swipeByCoordinates(fromX, fromY, toX, toY);
SwipeElementUtils.swipeByCoordinates(fromX, fromY, toX, toY);
}

@Then("Books are sorted by Author by default on subcategory screen in {string}")
public void isSortedByDefaultInPalace(String libraryName) {
Assert.assertEquals("Books are not sorted by default", "Author", subcategoryScreen.getNameOfSorting(libraryName));
}

@Then("There are sorting by {string}, {string} and {string} on Subcategory screen")
public void checkTypeOfSorting(String type1, String type2, String type3) {
sortOptionsScreen.openSortBy();
@Then("There are sorting by {string}, {string} and {string} on Subcategory screen in {string}")
public void checkTypeOfSorting(String type1, String type2, String type3, String libraryName) {
sortOptionsScreen.openSortBy(libraryName);
SoftAssertions softAssertions = new SoftAssertions();
softAssertions.assertThat(sortOptionsScreen.getTypeVariantsOfBtn(type1)).as("There is no sorting type by " + type1).isEqualTo(type1);
softAssertions.assertThat(sortOptionsScreen.getTypeVariantsOfBtn(type2)).as("There is no sorting type by " + type2).isEqualTo(type2);
softAssertions.assertThat(sortOptionsScreen.getTypeVariantsOfBtn(type3)).as("There is no sorting type by " + type3).isEqualTo(type3);
softAssertions.assertAll();
}

@When("Sort books by {}")
public void sortBooksBy(SortByKeys sortingCategory) {
sortOptionsScreen.openSortBy();
@When("Sort books by {} in {string}")
public void sortBooksBy(SortByKeys sortingCategory, String libraryName) {
sortOptionsScreen.openSortBy(libraryName);
sortOptionsScreen.changeSortByTo(sortingCategory);
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
"platformVersion": "12.0"
}
},
"SamsungGalaxyTabS9_13": {
"SamsungGalaxyTabS8_12": {
"capabilities": {
"deviceName": "Samsung Galaxy Tab S9",
"platformVersion": "13.0"
"deviceName": "Samsung Galaxy Tab S8",
"platformVersion": "12.0"
}
},
"GooglePixel8Pro_14": {
Expand Down

0 comments on commit 37822ec

Please sign in to comment.