Skip to content

Commit

Permalink
updated Book detailed view
Browse files Browse the repository at this point in the history
  • Loading branch information
AEkaterina committed Mar 4, 2024
1 parent 4202cfd commit 89e08b7
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 129 deletions.
126 changes: 7 additions & 119 deletions src/test/java/features/BookDetailView.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ Feature: Book detail view screen
And Book format in Information section is '<format>' on Book details screen
Scenarios:
| distributor | bookType | tabName | format |
| Bibliotheca | EBOOK | eBooks | eBook |
| Bibliotheca | EBOOK | eBooks | ePub |
| Bibliotheca | AUDIOBOOK | Audiobooks | Audiobook |
| Axis 360 | EBOOK | eBooks | eBook |
| Axis 360 | EBOOK | eBooks | ePub |
| Axis 360 | AUDIOBOOK | Audiobooks | Audiobook |
| Palace Marketplace | EBOOK | eBooks | eBook |
| Palace Marketplace | EBOOK | eBooks | ePub |
| Palace Marketplace | AUDIOBOOK | Audiobooks | Audiobook |
| Biblioboard | EBOOK | eBooks | PDF |
| Biblioboard | AUDIOBOOK | Audiobooks | Audiobook |
Expand Down Expand Up @@ -83,7 +83,6 @@ Feature: Book detail view screen
And Switch to '<tabName>' catalog tab
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
And Publisher and Categories in Information section are displayed on book details screen
And Publisher and Categories in Information section are correct on book details screen
And Distributor is equal to '<distributor>' on book details screen

Expand Down Expand Up @@ -123,51 +122,6 @@ Feature: Book detail view screen
| Biblioboard | EBOOK | eBooks |
| Biblioboard | AUDIOBOOK | Audiobooks |

@tier2
Scenario: Check of a book title and author in Palace Bookshelf
When Add library "Palace Bookshelf" on Add library screen
Then Library "Palace Bookshelf" is opened on Catalog screen
When Open search modal
And Search for "Persuasion" 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 Book 'bookInfo' has correct title and author name on Book details screen
And The book cover is displayed on Book details screen

@tier2
Scenario: Check of a "More..." button in Description section in Palace Bookshelf
When Add library "Palace Bookshelf" on Add library screen
Then Library "Palace Bookshelf" is opened on Catalog screen
When Open search modal
And Search for "Persuasion" 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 Description exists on Book details screen
And Button More in Description is available on Book details screen

@tier2
Scenario: Check fields in Information section in Palace Bookshelf
When Add library "Palace Bookshelf" on Add library screen
Then Library "Palace Bookshelf" is opened on Catalog screen
When Open search modal
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

@tier2
Scenario: Check related books section in Palace Bookshelf
When Add library "Palace Bookshelf" on Add library screen
Then Library "Palace Bookshelf" is opened on Catalog screen
When Open search modal
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
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

@tier2
Scenario: Check of a book title and author in Overdrive
When Add library "Palace Bookshelf" on Add library screen
Expand Down Expand Up @@ -216,24 +170,6 @@ Feature: Book detail view screen
And Publisher and Categories in Information section are correct on book details screen
And Distributor is equal to 'Overdrive' on book details screen

@tier2
Scenario: Check related books section in Overdrive
When Add library "Palace Bookshelf" on Add library screen
Then Library "Palace Bookshelf" is opened on Catalog screen
When Turn on test mode
And Enable hidden libraries
And Open Catalog
And Add "A1QA Test Library" account by the logo
Then Library "A1QA Test Library" is opened on Catalog screen
When Open search modal
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
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

@tier2
Scenario: Get button: Check of availability of required interface elements
When Add library "LYRASIS Reads" on Add library screen
Expand Down Expand Up @@ -316,7 +252,7 @@ Feature: Book detail view screen
When Enter a Library card with <numbers> numbers and save it as 'libraryCard' on Sign in screen
And Enter a valid Password for "LYRASIS Reads" library on Sign in screen
And Tap the Sign in button on Sign in screen
Then There is an alert "Invalid credentials" on Sign in screen
Then There is an alert "Invalid Credentials" on Sign in screen

Scenarios:
| numbers |
Expand All @@ -335,9 +271,9 @@ Feature: Book detail view screen
When Enter a Library card with 14 latin letters and save it as 'libraryCard' on Sign in screen
And Enter a valid Password for "LYRASIS Reads" library on Sign in screen
And Tap the Sign in button on Sign in screen
Then There is an alert "Invalid credentials" on Sign in screen
Then There is an alert "Invalid Credentials" on Sign in screen

@report
@tier2
Scenario: Book detail view: Perform check of Get button before log in from the Settings tab
When Add library "LYRASIS Reads" on Add library screen
Then Library "LYRASIS Reads" is opened on Catalog screen
Expand Down Expand Up @@ -369,52 +305,4 @@ Feature: Book detail view screen
Then Sing in screen is opened
When Save library "LYRASIS Reads" for log out
And Enter valid credentials fot "LYRASIS Reads" library on Sign in screen
Then Check that book contains READ action button on Book details screen

# sorting doesn't work correctly
# @tier1
# Scenario: Check of sorting books in related books in Palace
# When I add "Palace Bookshelf" account from welcomeScreen
# And I open Catalog
# And I open search modal
# And I search for "Persuasion" 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
# When Tap More... button in related books on book details view
# And I sort books by AUTHOR
# Then Books are sorted by Author ascending
# When I save list of books as 'listOfBooks'
# And I sort books by RECENTLY_ADDED
# Then List of books on subcategory screen is not equal to list of books saved as 'listOfBooks'
# When I sort books by TITLE
# Then Books are sorted by Title ascending

# sorting doesn't work correctly
# @tier1
# Scenario Outline: Check of sorting books in related books in LYRASIS
# When I add "LYRASIS Reads" account from welcomeScreen
# And I open Catalog
# And I open search modal
# And I search 'available' book of distributor '<distributor>' and bookType '<bookType>' and save as 'bookNameInfo'
# And I switch to '<tabName>' catalog tab
# 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 Tap More... button in related books on book details view
# And I sort books by AUTHOR
# Then Books are sorted by Author ascending
# When I save list of books as 'listOfBooks'
# And I sort books by RECENTLY_ADDED
# Then List of books on subcategory screen is not equal to list of books saved as 'listOfBooks'
# When I sort books by TITLE
# Then Books are sorted by Title ascending
#
# Scenarios:
# | distributor | bookType | tabName |
# | Bibliotheca | EBOOK | eBooks |
# | Bibliotheca | AUDIOBOOK | Audiobooks |
# | Axis 360 | EBOOK | eBooks |
# | Axis 360 | AUDIOBOOK | Audiobooks |
# | Palace Marketplace | EBOOK | eBooks |
# | Palace Marketplace | AUDIOBOOK | Audiobooks |
# | Biblioboard | EBOOK | eBooks |
# | Biblioboard | AUDIOBOOK | Audiobooks |
Then Check that book contains READ action button on Book details screen
19 changes: 18 additions & 1 deletion src/test/java/screens/CatalogBooksScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CatalogBooksScreen extends Screen {

Expand All @@ -44,7 +45,7 @@ public class CatalogBooksScreen extends Screen {

private static final String BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS = "//XCUIElementTypeStaticText[@name=\"%s\"]/following-sibling::XCUIElementTypeOther/XCUIElementTypeButton[contains(@name,\"%s\")]";
private static final String BOOK_BY_BOOK_NAME_AND_BUTTON_LOC_IOS = BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS + "/ancestor::XCUIElementTypeOther/XCUIElementTypeStaticText[1]";
private static final String BOOK_NAME_LOCATOR_IOS = "//XCUIElementTypeCollectionView/XCUIElementTypeCell/XCUIElementTypeOther/XCUIElementTypeStaticText[1]";
private static final String BOOK_NAME_LOCATOR_IOS = "//XCUIElementTypeCell/XCUIElementTypeOther/XCUIElementTypeStaticText[1]";
private static final String AUTHOR_BY_BOOK_NAME_AND_BUTTON_LOCATOR_IOS = BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS + "/ancestor::XCUIElementTypeOther[2]/XCUIElementTypeStaticText[2]";
private static final String PROGRESS_BAR_BY_BOOK_NAME_LOC_IOS = "//XCUIElementTypeStaticText[@name=\"%s\"]/following-sibling::XCUIElementTypeProgressIndicator";
private static final String BUTTON_ON_THE_FIRST_BOOK_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS = "//XCUIElementTypeStaticText/following-sibling::XCUIElementTypeOther/XCUIElementTypeButton[contains(@name,\"%s\")]";
Expand Down Expand Up @@ -82,6 +83,16 @@ public List<String> getListOfBooks(){
return getBooksName();
}

public String getBookFromCatalogSection(){
List<ILabel> bookLabels = getBooksLabels();
Random random = new Random();
int bookIndex = random.nextInt(bookLabels.size() - 3) + 4;
ILabel bookName = getElementFactory().getLabel(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("//androidx.recyclerview.widget.RecyclerView/android.widget.FrameLayout/android.view.ViewGroup/android.widget.TextView[contains(@resource-id, \"bookCellIdleTitle\")]")),
new IosLocator(By.xpath(String.format("//XCUIElementTypeCollectionView/XCUIElementTypeCell[%d]/XCUIElementTypeOther/XCUIElementTypeStaticText[1]", bookIndex)))), "Book name");
return bookName.getText();
}

public String getNameOfFirstBook() {
return lblNameOfFirstBook.getText();
}
Expand Down Expand Up @@ -139,6 +150,12 @@ private List<String> getBooksName() {
return booksName;
}

private List<ILabel> getBooksLabels() {
return getElementFactory().findElements(LocatorUtils.getLocator(
new AndroidLocator(By.xpath(BOOK_NAME_LOCATOR_ANDROID)),
new IosLocator(By.xpath(BOOK_NAME_LOCATOR_IOS))), ElementType.LABEL);
}

public CatalogBookModel clickActionButtonAndGetBookInfo(BookType bookType, String bookName, ActionButtonsForBooksAndAlertsKeys actionButtonKey) {
String bookNameForLocator = bookName;
if (AqualityServices.getApplication().getPlatformName() == PlatformName.IOS && BookType.AUDIOBOOK == bookType) {
Expand Down
23 changes: 17 additions & 6 deletions src/test/java/stepdefinitions/BookDetailsSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.inject.Inject;
import constants.RegEx;
import enums.localization.catalog.ActionButtonsForBooksAndAlertsKeys;
import framework.utilities.ActionProcessorUtils;
import framework.utilities.ScenarioContext;
import framework.utilities.swipe.SwipeElementUtils;
import io.cucumber.java.en.Then;
Expand Down Expand Up @@ -83,6 +84,7 @@ public void checkThatBookContainsActionButton(final ActionButtonsForBooksAndAler

@Then("Book format in Information section is displayed on Book details screen")
public void isBookFormatDisplayed() {
ActionProcessorUtils.doForAndroid(SwipeElementUtils::swipeDown);
Assert.assertTrue("Book format is not displayed", bookDetailsScreen.isBookFormatInfoExist());
}

Expand Down Expand Up @@ -117,14 +119,18 @@ public void isInformationSectionFull() {
@Then("Publisher and Categories in Information section are correct on book details screen")
public void isInformationSectionIsCorrect() {
SoftAssertions softAssertions = new SoftAssertions();
if (AqualityServices.getApplication().getPlatformName()==PlatformName.ANDROID) {
SwipeElementUtils.swipeDown();
ActionProcessorUtils.doForAndroid(SwipeElementUtils::swipeDown);

if(bookDetailsScreen.isPublisherInfoExist()) {
String publisher = bookDetailsScreen.getPublisherInfo();
softAssertions.assertThat(publisher.matches(RegEx.VALID_PUBLISHER_OR_CATEGORY_NAME)).as("Publisher field has invalid symbols").isTrue();
}

String publisher = bookDetailsScreen.getPublisherInfo();
softAssertions.assertThat(publisher.matches(RegEx.VALID_PUBLISHER_OR_CATEGORY_NAME)).as("Publisher field has invalid symbols").isTrue();
String categories = bookDetailsScreen.getCategoryInfo();
softAssertions.assertThat(categories.matches(RegEx.VALID_PUBLISHER_OR_CATEGORY_NAME)).as("Category field has invalid symbols").isTrue();
if(bookDetailsScreen.isCategoryInfoExist()) {
String categories = bookDetailsScreen.getCategoryInfo();
softAssertions.assertThat(categories.matches(RegEx.VALID_PUBLISHER_OR_CATEGORY_NAME)).as("Category field has invalid symbols").isTrue();

}
softAssertions.assertAll();
}

Expand Down Expand Up @@ -173,4 +179,9 @@ public void pressActionButtonAndAlertActionButtonOnBookDetailsScreen(ActionButto
bookDetailsScreen.clickActionButton(actionBookButtonKey);
alertScreen.waitAndPerformAlertActionIfDisplayed(actionAlertButtonKey);
}

@Then("Sample player screen is displayed on Books details screen")
public void isSamplePlayerDisplayed() {

}
}
14 changes: 11 additions & 3 deletions src/test/java/stepdefinitions/GettingBooksStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import constants.util.UtilConstants;
import enums.BookType;
import enums.localization.sortoptions.AvailabilityKeys;
import framework.utilities.ActionProcessorUtils;
import framework.utilities.swipe.SwipeElementUtils;
import org.apache.commons.lang3.StringUtils;
import screens.*;
Expand Down Expand Up @@ -52,9 +53,16 @@ public static String getBookFromSection(String bookType, String distributor) {
AqualityServices.getConditionalWait().waitFor(catalogBooksScreen::isFirstBookInCatalogDisplayed);

SwipeElementUtils.swipeDown();
List<String> books = catalogBooksScreen.getListOfBooks();
int bookIndex = random.nextInt(books.size());
String bookName = books.get(bookIndex);
String bookName = ActionProcessorUtils.doForAndroid(() -> {
List<String> books = catalogBooksScreen.getListOfBooks();
int bookIndex = random.nextInt(books.size());
return books.get(bookIndex);
});

if(bookName == null) {
bookName = ActionProcessorUtils.doForIos(catalogBooksScreen::getBookFromCatalogSection);
}

if(bookType.equalsIgnoreCase(BookType.AUDIOBOOK.getBookType())) {
bookName = StringUtils.substringBefore(bookName, ". Audiobook.");
}
Expand Down

0 comments on commit 89e08b7

Please sign in to comment.