Skip to content

Commit

Permalink
Merge pull request #21 from ThePalaceProject/refactoring
Browse files Browse the repository at this point in the history
Refactoring android
  • Loading branch information
AEkaterina authored Nov 5, 2023
2 parents a502914 + 7911632 commit 4a9ef0a
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 28 deletions.
16 changes: 9 additions & 7 deletions src/test/java/features/BookDetailView.feature
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Feature: Book detail view screen
And Open <bookType> book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Then Book 'bookInfo' is opened on book details screen
When Swipe down
Then Related books section is displayed on book details screen
Then Related books section of 'bookInfo' book is displayed on book details screen
And There is a list of related books on book details screen
And More button in related books section is available on book details screen

Expand Down Expand Up @@ -188,7 +188,7 @@ Feature: Book detail view screen
Then Library "Palace Bookshelf" is opened on Libraries screen
When Open Catalog
And Open search modal
And Search for "Persuasion" and save bookName as 'bookNameInfo'
And Search for "The Covid Archive" and save bookName as 'bookNameInfo'
And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Then Book 'bookInfo' is opened on book details screen
And Publisher and Categories in Information section are correct on book details screen
Expand All @@ -199,10 +199,11 @@ Feature: Book detail view screen
Then Library "Palace Bookshelf" is opened on Libraries screen
When Open Catalog
And Open search modal
And Search for "Persuasion" and save bookName as 'bookNameInfo'
And Search for "The Picture of Dorian Gray" and save bookName as 'bookNameInfo'
And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Then Book 'bookInfo' is opened on book details screen
And Related books section is displayed on book details screen
When Swipe down
Then Related books section of 'bookInfo' book is displayed on book details screen
And There is a list of related books on book details screen
And More button in related books section is available on book details screen

Expand Down Expand Up @@ -269,7 +270,7 @@ Feature: Book detail view screen
Then Library "A1QA Test Library" is opened on Libraries screen
When Open Catalog
And Open search modal
And Search for "The Count of Monte Cristo" and save bookName as 'bookNameInfo'
And Search for "Little Women" and save bookName as 'bookNameInfo'
And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Then Book 'bookInfo' is opened on book details screen
And Publisher and Categories in Information section are correct on book details screen
Expand All @@ -286,10 +287,11 @@ Feature: Book detail view screen
Then Library "A1QA Test Library" is opened on Libraries screen
When Open Catalog
And Open search modal
And Search for "The Woman in White" and save bookName as 'bookNameInfo'
And Search for "Little Women" and save bookName as 'bookNameInfo'
And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Then Book 'bookInfo' is opened on book details screen
And Related books section is displayed on book details screen
When Swipe down
Then Related books section of 'bookInfo' book is displayed on book details screen
And There is a list of related books on book details screen
And More button in related books section is available on book details screen

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/features/Reservations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,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 'unavailable' book of distributor 'Bibliotheca' and bookType 'AUDIOBOOK' and save 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
18 changes: 9 additions & 9 deletions src/test/java/features/Settings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ Feature: Check sections from settings screen
When Close welcome screen
Then Add library screen is opened
When Add library "LYRASIS Reads" on Add library screen
And Open Settings
And Open Libraries on Settings screen
And Open "LYRASIS Reads" library on Setting screen
And Open Settings
And Open Libraries on Settings screen
And Open "LYRASIS Reads" library on Setting screen
Then Library "LYRASIS Reads" is opened on Account screen
And All fields and links are displayed on Account screen
And All fields and links are displayed on Sign in screen
And All fields and links are displayed on Account screen
And All fields and links are displayed on Sign in screen

@smoke
Scenario: Settings: Log in: Perform check of the link Content Licenses
Expand All @@ -101,8 +101,8 @@ Feature: Check sections from settings screen
When Close welcome screen
Then Add library screen is opened
When Add library "LYRASIS Reads" on Add library screen
And Open Settings
And Open Libraries on Settings screen
And Open 'LYRASIS Reads' library on Setting screen
And Open Content Licenses on Account screen
And Open Settings
And Open Libraries on Settings screen
And Open 'LYRASIS Reads' library on Setting screen
And Open Content Licenses on Account screen
Then Content Licenses screen is opened
7 changes: 4 additions & 3 deletions src/test/java/screens/BookDetailsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import aquality.appium.mobile.application.AqualityServices;
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.screens.Screen;
import constants.appattributes.IosAttributes;
Expand Down Expand Up @@ -43,7 +44,7 @@ public class BookDetailsScreen extends Screen {
new AndroidLocator(By.xpath("//android.widget.TextView[@text=\"Description\"]//following::android.widget.TextView[@text=\"More…\"]")),
new IosLocator(By.xpath("//XCUIElementTypeStaticText//following::XCUIElementTypeButton[@name=\"More...\"]"))), "More btn in Description section");
private final ILabel lblPublisherInfo = getElementFactory().getLabel(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("//android.widget.LinearLayout/android.widget.TextView[contains(@text,\"Publisher\")]/following::android.widget.TextView")),
new AndroidLocator(By.xpath("//android.widget.LinearLayout/android.widget.TextView[@text=\"Publisher\"]/following::android.widget.TextView")),
new IosLocator(By.xpath("//XCUIElementTypeStaticText[contains(@name,\"Publisher\")]/following::XCUIElementTypeStaticText"))), "Publisher label");
private final ILabel lblCategories = getElementFactory().getLabel(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("//android.widget.LinearLayout/android.widget.TextView[contains(@text,\"Categor\")]/following::android.widget.TextView")),
Expand All @@ -59,7 +60,7 @@ public class BookDetailsScreen extends Screen {
private static final String AUTHOR_NAME_LOC_ANDROID = "//android.widget.TextView[@text=\"%s\"]";
private static final String BOOK_ACTION_BUTTON_LOC_ANDROID = "//android.widget.Button[@text=\"%s\"]";
private static final String AUTHOR_IN_RELATED_BOOKS_LOC_ANDROID = "//android.widget.FrameLayout//android.widget.TextView[@text=\"%s\"]";
private static final String LIST_OF_RELATED_BOOKS_LOC_ANDROID = "//androidx.recyclerview.widget.RecyclerView[contains(@resource-id, \"feedLaneCoversScroll\")]/android.widget.LinearLayout";
private static final String LIST_OF_RELATED_BOOKS_LOC_ANDROID = "//androidx.recyclerview.widget.RecyclerView[contains(@resource-id, \"feedLaneCoversScroll\")]/android.widget.FrameLayout";

private static final String BOOK_NAME_LOC_IOS = "//XCUIElementTypeStaticText[@name=\"%s\"]";
private static final String AUTHOR_NAME_LOC_IOS = "//XCUIElementTypeStaticText[@name=\"%s\"]";
Expand Down Expand Up @@ -182,7 +183,7 @@ public boolean isRelatedBooksExists(String authorName) {
}

public boolean isListOfBooksDisplayed() {
List<ILabel> listOfRelatedBooks = getElementFactory().findElements(LocatorUtils.getLocator(
List<IElement> listOfRelatedBooks = getElementFactory().findElements(LocatorUtils.getLocator(
new AndroidLocator(By.xpath(LIST_OF_RELATED_BOOKS_LOC_ANDROID)),
new IosLocator(By.xpath(LIST_OF_RELATED_BOOKS_LOC_IOS))), ElementType.LABEL);
return listOfRelatedBooks.size() != 0;
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/screens/CatalogBooksScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class CatalogBooksScreen extends Screen {
private static final String BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_ANDROID = "//android.widget.TextView[@text=\"%s\"]/following-sibling::android.widget.LinearLayout/android.widget.Button[@text=\"%s\"]";
private static final String BOOK_BY_BOOK_NAME_AND_BUTTON_LOC_ANDROID = BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_ANDROID + "/ancestor::android.view.ViewGroup/android.widget.TextView[1]";
private static final String BOOK_NAME_LOCATOR_ANDROID = "//android.view.ViewGroup[contains(@resource-id, \"bookCellIdle\")]/android.widget.TextView[contains(@resource-id, \"bookCellIdleTitle\")]";
private static final String AUTHOR_BY_BOOK_NAME_AND_BUTTON_LOCATOR_ANDROID = BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_ANDROID + "/ancestor::android.view.ViewGroup/android.widget.TextView[2]";
private static final String AUTHOR_BY_BOOK_NAME_AND_BUTTON_LOCATOR_ANDROID = BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_ANDROID + "/ancestor::android.view.ViewGroup/android.widget.TextView[contains(@resource-id, \"bookCellIdleAuthor\")]";
private static final String PROGRESS_BAR_BY_BOOK_NAME_LOC_ANDROID = "//android.widget.TextView[@text=\"%s\"]/following-sibling::android.widget.ProgressBar";
private static final String BUTTON_ON_THE_FIRST_BOOK_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_ANDROID = "//android.widget.TextView/following-sibling::android.widget.LinearLayout//*[@text=\"%s\"]";
private static final String AUTHOR_ON_THE_FIRST_BOOK_BY_BOOK_NAME_AND_BUTTON_LOC_ANDROID = BUTTON_ON_THE_FIRST_BOOK_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_ANDROID + "/ancestor::android.view.ViewGroup/android.widget.TextView[2]";
Expand Down Expand Up @@ -108,11 +108,12 @@ public CatalogBookModel openBookAndGetBookInfo(BookType bookType, String bookNam
new AndroidLocator(By.xpath(String.format(AUTHOR_BY_BOOK_NAME_AND_BUTTON_LOCATOR_ANDROID, bookNameForLocator, actionButtonString))),
new IosLocator(By.xpath(String.format(AUTHOR_BY_BOOK_NAME_AND_BUTTON_LOCATOR_IOS, bookNameForLocator, actionButtonString)))), "Author");
String author;
if (!lblAuthor.state().isDisplayed()) {
if (!lblAuthor.state().waitForDisplayed()) {
author = null;
} else {
author = lblAuthor.getText();
}

CatalogBookModel bookInfo = new CatalogBookModel()
.setTitle(bookName)
.setAuthor(author);
Expand Down
4 changes: 1 addition & 3 deletions src/test/java/screens/CatalogScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import constants.appattributes.IosAttributes;
import framework.utilities.ActionProcessorUtils;
import framework.utilities.LocatorUtils;
import framework.utilities.swipe.SwipeElementUtils;
import models.AndroidLocator;
import models.IosLocator;
import org.openqa.selenium.By;
Expand Down Expand Up @@ -42,7 +41,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.LinearLayout";
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 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…\"]";
Expand Down Expand Up @@ -87,7 +86,6 @@ public Set<String> getListOfBooksNameInFirstCategory() {
categoryLine.getTouchActions().scrollToElement(SwipeDirection.DOWN);
do {
bookNames.addAll(currentBooksNames);
SwipeElementUtils.swipeFromRightToLeft(categoryLine);
currentBooksNames = getValuesFromListOfLabels(LocatorUtils.getLocator(
new AndroidLocator(By.xpath(String.format(CATEGORY_NAME_LOCATOR_ANDROID, categoryName) + BOOK_COVER_IN_CATEGORY_LOCATOR_ANDROID)),
new IosLocator(By.xpath(String.format(CATEGORY_NAME_LOCATOR_IOS, categoryName) + BOOK_COVER_IN_CATEGORY_LOCATOR_IOS))));
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/stepdefinitions/BookDetailsSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ public void isDistributorCorrect(String distributor) {
Assert.assertEquals("Distributor is not correct", distributor.toLowerCase(), distributorFromScreen.toLowerCase());
}

@Then("Related books section is displayed on book details screen")
public void isRelatedBooksExists() {
String authorName = bookDetailsScreen.getBookInfo().getAuthor();
@Then("Related books section of {string} book is displayed on book details screen")
public void isRelatedBooksExists(String bookInfoKey) {
CatalogBookModel bookModel = context.get(bookInfoKey);
String authorName = bookModel.getAuthor();
Assert.assertTrue("Related books section is not displayed", bookDetailsScreen.isRelatedBooksExists(authorName));
}

Expand Down

0 comments on commit 4a9ef0a

Please sign in to comment.