From a020b31e976f40996625ce391d18f6758915efbc Mon Sep 17 00:00:00 2001 From: AEkaterina Date: Wed, 18 Oct 2023 01:17:22 +0400 Subject: [PATCH 1/6] updated reservations scenario, pdf for ios --- src/test/java/features/BookDetailView.feature | 122 +++--------------- .../java/features/CatalogNavigation.feature | 54 +------- src/test/java/features/Distributors.feature | 32 +---- src/test/java/features/MenuBar.feature | 20 +-- src/test/java/features/MyBooks.feature | 32 +---- .../java/features/PdfLyrasisAndroid.feature | 16 +-- src/test/java/features/PdfLyrasisIos.feature | 62 ++++++++- src/test/java/features/Reservations.feature | 18 +-- .../screens/epub/BookmarksEpubScreen.java | 9 +- .../screens/epub/NavigationBarScreen.java | 2 +- src/test/java/stepdefinitions/AlertSteps.java | 2 +- 11 files changed, 124 insertions(+), 245 deletions(-) diff --git a/src/test/java/features/BookDetailView.feature b/src/test/java/features/BookDetailView.feature index ca783ec..c0ad2cb 100644 --- a/src/test/java/features/BookDetailView.feature +++ b/src/test/java/features/BookDetailView.feature @@ -1,11 +1,13 @@ Feature: Book detail view screen - @tier2 - Scenario Outline: Check of a book title and author in LYRASIS Reads - When Close tutorial screen + Background: + Given Close tutorial screen Then Welcome screen is opened When Close welcome screen Then Add library screen is opened + + @tier2 + Scenario Outline: Check of a book title and author in LYRASIS Reads When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -30,10 +32,6 @@ Feature: Book detail view screen @tier2 Scenario Outline: Check of a book format in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -57,10 +55,6 @@ Feature: Book detail view screen @tier2 Scenario Outline: Check of a "More..." button in Description section in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -85,10 +79,6 @@ Feature: Book detail view screen @tier2 Scenario Outline: Check fields in Information section in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -114,10 +104,6 @@ Feature: Book detail view screen @tier2 Scenario Outline: Check related books section in LYRASIS - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -173,10 +159,6 @@ Feature: Book detail view screen @tier2 Scenario: Check of a book title and author in Palace Bookshelf - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Open Catalog @@ -189,10 +171,6 @@ Feature: Book detail view screen @tier2 Scenario: Check of a "More..." button in Description section in Palace Bookshelf - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Open Catalog @@ -205,10 +183,6 @@ Feature: Book detail view screen @tier2 Scenario: Check fields in Information section in Palace Bookshelf - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Open Catalog @@ -220,10 +194,6 @@ Feature: Book detail view screen @tier2 Scenario: Check related books section in Palace Bookshelf - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Open Catalog @@ -255,10 +225,6 @@ Feature: Book detail view screen @tier2 Scenario: Check of a book title and author in Overdrive - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Turn on test mode @@ -276,10 +242,6 @@ Feature: Book detail view screen @tier2 Scenario: Check of a "More..." button in Description section in Overdrive - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Turn on test mode @@ -297,10 +259,6 @@ Feature: Book detail view screen @tier2 Scenario: Check fields in Information section in Overdrive - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Turn on test mode @@ -318,10 +276,6 @@ Feature: Book detail view screen @tier2 Scenario: Check related books section in Overdrive - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Turn on test mode @@ -340,10 +294,6 @@ Feature: Book detail view screen @tier2 Scenario: Get button: Check of availability of required interface elements - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -356,10 +306,6 @@ Feature: Book detail view screen @tier2 @exclude_android Scenario: Get button: check of Library Card field - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -372,10 +318,6 @@ Feature: Book detail view screen @tier2 @exclude_android Scenario: Get button: check of Password field - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -388,10 +330,6 @@ Feature: Book detail view screen @tier2 Scenario: Get: Sign in: Check of loging in with leaving the Library Card field empty - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -405,10 +343,6 @@ Feature: Book detail view screen @tier2 Scenario: Get: Sign in: Check of loging in with leaving the Password field empty - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -422,10 +356,6 @@ Feature: Book detail view screen @tier2 Scenario: Get: Sign in: Library card: Check that the field allows you to edit the data - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -440,10 +370,6 @@ Feature: Book detail view screen @tier2 Scenario Outline: Get: Sign in: Library card: Check of less than minimum allowed or more than maximum characters - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -464,10 +390,6 @@ Feature: Book detail view screen @tier2 Scenario: Get: Log in: Library card: Check that the field doesn't allow characters except numbers - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -483,49 +405,37 @@ Feature: Book detail view screen @smoke Scenario: Book detail view: Perform check of Get button before log in from the Settings tab - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog And Open search modal - And Search for "Lemon" and save bookName as 'bookNameInfo' + And Search for "Eat That Frog!" and save bookName as 'bookNameInfo' And Open book with GET action button and 'bookNameInfo' bookName on catalog books screen And Click GET action button on Book details screen Then Sing in screen is opened @smoke Scenario: Book detail view: Get: Log in: Perform check of availability of required interface elements - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog - And Open search modal - And Search for "Libertie" and save bookName as 'bookNameInfo' - And Open book with GET action button and 'bookNameInfo' bookName on catalog books screen - And Click GET action button on Book details screen + And Open search modal + And Search for "Libertie" and save bookName as 'bookNameInfo' + And Open book with GET action button and 'bookNameInfo' bookName on catalog books screen + And Click GET action button on Book details screen Then Sing in screen is opened - And All fields and links are displayed on Sign in screen + And All fields and links are displayed on Sign in screen @smoke @logout @returnBooks Scenario: Book detail view: Get: Log in: Perform check of logging in - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog - And Open search modal - And Search for "Renaissance Futurities" and save bookName as 'bookNameInfo' - And Open book with GET action button and 'bookNameInfo' bookName on catalog books screen - And Click GET action button on Book details screen + And Open search modal + And Search for "Renaissance Futurities" and save bookName as 'bookNameInfo' + And Open book with GET action button and 'bookNameInfo' bookName on catalog books screen + And Click GET action button on Book details 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 + And Enter valid credentials fot "LYRASIS Reads" library on Sign in screen Then Check that book contains READ action button on Book details screen \ No newline at end of file diff --git a/src/test/java/features/CatalogNavigation.feature b/src/test/java/features/CatalogNavigation.feature index 4db6ab8..c132c3a 100644 --- a/src/test/java/features/CatalogNavigation.feature +++ b/src/test/java/features/CatalogNavigation.feature @@ -1,11 +1,13 @@ Feature: Catalog Navigation module - @tier2 - Scenario: Return to last library catalog - When Close tutorial screen + Background: + Given Close tutorial screen Then Welcome screen is opened When Close welcome screen Then Add library screen is opened + + @tier2 + Scenario: Return to last library catalog When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Add 'LYRASIS Reads' library in Libraries screen @@ -16,10 +18,6 @@ Feature: Catalog Navigation module @tier2 Scenario: Browse Categories in Palace Bookshelf - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Catalog screen is opened And Library "Palace Bookshelf" is opened on Libraries screen @@ -38,10 +36,6 @@ Feature: Catalog Navigation module @tier2 Scenario: Check of the titles of books sections in Palace Bookshelf - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Open Catalog @@ -50,10 +44,6 @@ Feature: Catalog Navigation module @tier2 Scenario Outline: Check of books sorting in Palace Bookshelf - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Open Catalog @@ -94,10 +84,6 @@ Feature: Catalog Navigation module @tier2 Scenario Outline: Check of tabs at the top of the screen in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -115,10 +101,6 @@ Feature: Catalog Navigation module @tier2 Scenario: Check of the titles of books sections in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -127,10 +109,6 @@ Feature: Catalog Navigation module @tier2 Scenario Outline: Check of books sorting in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -171,10 +149,6 @@ Feature: Catalog Navigation module @tier2 Scenario Outline: Check of books availability in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -191,10 +165,6 @@ Feature: Catalog Navigation module @tier2 Scenario: Check all types of availability - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -211,10 +181,6 @@ Feature: Catalog Navigation module @tier2 @exclude_android Scenario Outline: Check of books collections - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Open Catalog @@ -231,10 +197,6 @@ Feature: Catalog Navigation module @smoke @logout @returnBooks @exclude_android Scenario: Catalog: Perform check of Reserve button and Allow notifications - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Enter credentials for "LYRASIS Reads" library @@ -252,10 +214,6 @@ Feature: Catalog Navigation module @smoke @logout @returnBooks @exclude_android Scenario: Catalog: Alert: Perform check of "Don't Allow" button - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Enter credentials for "LYRASIS Reads" library @@ -267,7 +225,7 @@ Feature: Catalog Navigation module 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 without closing alert on Book details screen Then There is an alert to allow notifications - When Tap Don't Allow button on the alert + When Don't Allow notifications on the alert Then Alert to allow notification is not displayed And Check that book contains REMOVE action button on Book details screen diff --git a/src/test/java/features/Distributors.feature b/src/test/java/features/Distributors.feature index c43d788..4313023 100644 --- a/src/test/java/features/Distributors.feature +++ b/src/test/java/features/Distributors.feature @@ -1,11 +1,13 @@ Feature: Distributors - @logout @returnBooks @tier2 - Scenario Outline: Reserving from Book Detail View in LYRASIS Reads - When Close tutorial screen + Background: + Given Close tutorial screen Then Welcome screen is opened When Close welcome screen Then Add library screen is opened + + @logout @returnBooks @tier2 + Scenario Outline: Reserving from Book Detail View in LYRASIS Reads When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Enter credentials for 'LYRASIS Reads' library @@ -31,10 +33,6 @@ Feature: Distributors @logout @returnBooks @tier2 Scenario Outline: Getting and returning books from Book Detail View in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Enter credentials for 'LYRASIS Reads' library @@ -67,10 +65,6 @@ Feature: Distributors @logout @returnBooks @tier2 Scenario: Getting and returning a book from Book Detail View for Overdrive - Given Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Turn on test mode @@ -97,10 +91,6 @@ Feature: Distributors @logout @returnBooks @tier2 Scenario: Getting and returning an audiobook from Book Detail View for Overdrive - Given Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Turn on test mode @@ -127,10 +117,6 @@ Feature: Distributors @tier2 Scenario: Getting and returning a book from Book Detail View for Palace Bookshelf - Given Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Open Catalog @@ -149,10 +135,6 @@ Feature: Distributors @logout @returnBooks @tier2 Scenario Outline: Check of canceling the downloading from book details view for LYRASIS Reads - Given Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Enter credentials for 'LYRASIS Reads' library @@ -180,10 +162,6 @@ Feature: Distributors @logout @returnBooks @tier2 Scenario: Check of canceling the downloading from book details view for Overdrive - Given Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Turn on test mode diff --git a/src/test/java/features/MenuBar.feature b/src/test/java/features/MenuBar.feature index 562e8c3..c7efe12 100644 --- a/src/test/java/features/MenuBar.feature +++ b/src/test/java/features/MenuBar.feature @@ -1,11 +1,13 @@ Feature: Menu Bar module - @tier2 - Scenario Outline: Check of menu bar in Palace Bookshelf - When Close tutorial screen + Background: + Given Close tutorial screen Then Welcome screen is opened When Close welcome screen Then Add library screen is opened + + @tier2 + Scenario Outline: Check of menu bar in Palace Bookshelf When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen And There is a menu bar at the bottom of the screen @@ -17,10 +19,6 @@ Feature: Menu Bar module @tier2 Scenario: Check of the tabs in Palace Bookshelf - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen And Open Catalog Then Catalog screen is opened @@ -31,10 +29,6 @@ Feature: Menu Bar module @tier2 Scenario Outline: Check of menu bar in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen And There is a menu bar at the bottom of the screen @@ -46,10 +40,6 @@ Feature: Menu Bar module @tier2 Scenario: Check of the tabs in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen And Open Catalog Then Catalog screen is opened diff --git a/src/test/java/features/MyBooks.feature b/src/test/java/features/MyBooks.feature index 6e89a19..5bc2b94 100644 --- a/src/test/java/features/MyBooks.feature +++ b/src/test/java/features/MyBooks.feature @@ -1,11 +1,13 @@ Feature: My books module - @tier2 - Scenario: Check of added books in Palace Bookshelf - When Close tutorial screen + Background: + Given Close tutorial screen Then Welcome screen is opened When Close welcome screen Then Add library screen is opened + + @tier2 + Scenario: Check of added books in Palace Bookshelf When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Open Catalog @@ -21,10 +23,6 @@ Feature: My books module @tier2 Scenario: Check of sorting in Palace Bookshelf - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "Palace Bookshelf" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Open Catalog @@ -42,10 +40,6 @@ Feature: My books module @logout @returnBooks @tier1 Scenario: Return book from My Books in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "Palace Bookshelf" is opened on Libraries screen When Enter credentials for 'LYRASIS Reads' library @@ -65,10 +59,6 @@ Feature: My books module @logout @returnBooks @tier1 Scenario: Get a book from Book Detail View and Return from Books in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Enter credentials for 'LYRASIS Reads' library @@ -90,10 +80,6 @@ Feature: My books module @logout @returnBooks @tier1 Scenario: Get a book from Subcategory List View and Return from Books in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Enter credentials for 'LYRASIS Reads' library @@ -119,10 +105,6 @@ Feature: My books module @logout @returnBooks @tier1 @exclude_android Scenario: Get a book from Subcategory List View and Return from Subcategory List View in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Enter credentials for 'LYRASIS Reads' library @@ -138,10 +120,6 @@ Feature: My books module @logout @returnBooks @tier1 Scenario: Get a book from Subcategory List View and Read from Books in LYRASIS Reads - When Close tutorial screen - Then Welcome screen is opened - When Close welcome screen - Then Add library screen is opened When Add library "LYRASIS Reads" on Add library screen Then Library "LYRASIS Reads" is opened on Libraries screen When Enter credentials for 'LYRASIS Reads' library diff --git a/src/test/java/features/PdfLyrasisAndroid.feature b/src/test/java/features/PdfLyrasisAndroid.feature index 94c861a..616658c 100644 --- a/src/test/java/features/PdfLyrasisAndroid.feature +++ b/src/test/java/features/PdfLyrasisAndroid.feature @@ -183,8 +183,8 @@ Feature: Read PDF in LYRASIS Reads on Android And Scroll page up on pdf reader screen Then Page number is not equal to 'pageInfo2' on pdf reader screen - @smoke @logout @returnBooks - Scenario: Read pdfs: Table of contents: Perform check of navigation + @smoke @logout @returnBooks @exclude_ios + Scenario: Android: Read pdfs: Table of contents: Perform check of navigation When Open search modal And Search for "Race Cars" 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' @@ -199,8 +199,8 @@ Feature: Read PDF in LYRASIS Reads on Android When Open content with thumbnails on pdf toc screen Then Thumbnails of the book pages are displayed - @smoke @logout @returnBooks - Scenario: Read pdfs: Perform check of back button + @smoke @logout @returnBooks @exclude_ios + Scenario: Android: Read pdfs: Perform check of back button When Open search modal And Search for "Race Cars" 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' @@ -211,8 +211,8 @@ Feature: Read PDF in LYRASIS Reads on Android When Close pdf reader by back button Then Book "bookInfo" is opened on book details screen - @smoke @logout @returnBooks - Scenario: Read pdfs: Table of contents: Contents with thumbnails: Perform check of navigation + @smoke @logout @returnBooks @exclude_ios + Scenario: Android: Read pdfs: Table of contents: Contents with thumbnails: Perform check of navigation When Open search modal And Search for "Race Cars" 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' @@ -227,8 +227,8 @@ Feature: Read PDF in LYRASIS Reads on Android And Return to pdf reader screen from pdf toc screen Then Page number is equal to 'pageInfo' on pdf reader screen - @smoke @logout @returnBooks - Scenario: Read pdfs: Table of contents: Chapter content: Perform check of navigation + @smoke @logout @returnBooks @exclude_ios + Scenario: Android: Read pdfs: Table of contents: Chapter content: Perform check of navigation When Open search modal And Search for "Comprehension and Critical Thinking Grade 6" 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' diff --git a/src/test/java/features/PdfLyrasisIos.feature b/src/test/java/features/PdfLyrasisIos.feature index d026f2d..f6db82a 100644 --- a/src/test/java/features/PdfLyrasisIos.feature +++ b/src/test/java/features/PdfLyrasisIos.feature @@ -195,4 +195,64 @@ Feature: Read PDF in LYRARIS Reads on IOS When Open search pdf screen And Enter '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 \ No newline at end of file + Then Page number is equal to 'pageNumber' on pdf reader screen + + @smoke @logout @returnBooks @exclude_android + Scenario: iOS: Read pdfs: Table of contents: Perform check of navigation + When Open search modal + And Search for "Race Cars" 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' + And Click READ action button on Book details screen + Then Reader pdf screen is opened + When Open TOC on pdf reader screen + Then There are content list with thumbnails and chapter content on pdf toc screen + When Open text chapter content on pdf toc screen + Then Text chapter content is opened on pdf toc screen + When Open content with thumbnails on pdf toc screen + Then Thumbnails of the book pages are displayed + + @smoke @logout @returnBooks @exclude_android + Scenario: iOS: Read pdfs: Perform check of back button + When Open search modal + And Search for "Race Cars" 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' + And Click READ action button on Book details screen + Then Reader pdf screen is opened + When Close pdf reader by back button + Then Book "bookInfo" is opened on book details screen + + @smoke @logout @returnBooks @exclude_android + Scenario: iOS: Read pdfs: Table of contents: Contents with thumbnails: Perform check of navigation + When Open search modal + And Search for "Race Cars" 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' + And Click READ action button on Book details screen + Then Reader pdf screen is opened + When Open TOC on pdf reader screen + And Open content with thumbnails on pdf toc screen + Then Thumbnails of the book pages are displayed + When Open random thumbnail and save the number as 'pageInfo' on pdf toc screen + And Return to pdf reader screen from pdf toc screen + Then Page number is equal to 'pageInfo' on pdf reader screen + + @smoke @logout @returnBooks @exclude_android + Scenario: iOS: Read pdfs: Table of contents: Chapter content: Perform check of navigation + When Open search modal + And Search for "Comprehension and Critical Thinking Grade 6" 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' + And Click READ action button on Book details screen + Then Reader pdf screen is opened + When Open TOC on pdf reader screen + And Open text chapter content on pdf toc screen + Then Text chapter content is opened on pdf toc screen + When Open random chapter and save the number as 'pageInfo' on pdf toc screen + And Return to pdf reader screen from pdf toc screen + Then Page number is equal to 'pageInfo' on pdf reader screen \ No newline at end of file diff --git a/src/test/java/features/Reservations.feature b/src/test/java/features/Reservations.feature index 408cf04..f6db6f6 100644 --- a/src/test/java/features/Reservations.feature +++ b/src/test/java/features/Reservations.feature @@ -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 'unavailable' book of distributor 'Bibliotheca' and bookType 'AUDIOBOOK' and save as 'bookNameInfo' + And Search for "The Santa Suit" 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' @@ -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 'unavailable' book of distributor 'Palace Marketplace' and bookType 'AUDIOBOOK' and save as 'bookNameInfo' + And Search for "Vanderbilt" 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' @@ -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 'unavailable' book of distributor 'Palace Marketplace' and bookType 'AUDIOBOOK' and save as 'bookNameInfo' + And Search for "The Song of Achilles" 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' @@ -185,16 +185,16 @@ Feature: Reservation of book in LYRASIS When Enter credentials for 'LYRASIS Reads' library Then Login is performed successfully When Activate sync bookmarks on Sign in screen - And Open Catalog - And Open search modal - And Search for "Fahrenheit 451" 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 Open Catalog + And Open search modal + And Search for "Fahrenheit 451" 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 When Open Reservations 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 action button without closing alert on Book details screen + And Click REMOVE action button without closing alert on Book details screen Then There is an alert to remove reservations with REMOVE and CANCEL buttons When Tap CANCEL button on the alert Then Check that book contains REMOVE action button on Book details screen \ No newline at end of file diff --git a/src/test/java/screens/epub/BookmarksEpubScreen.java b/src/test/java/screens/epub/BookmarksEpubScreen.java index f157e28..6c43fc0 100644 --- a/src/test/java/screens/epub/BookmarksEpubScreen.java +++ b/src/test/java/screens/epub/BookmarksEpubScreen.java @@ -26,7 +26,7 @@ public class BookmarksEpubScreen extends Screen { new IosLocator(By.xpath("//XCUIElementTypeStaticText[contains(@text, \"no bookmarks\")]"))), "No bookmarks label"); private final ILabel lblBookmarksTab = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.id("tocBookmarksList")), - new IosLocator(By.xpath(""))), "Bookmarks tab"); + new IosLocator(By.xpath("//XCUIElementTypeTable"))), "Bookmarks tab"); private final IButton btnDelete = getElementFactory().getButton(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//android.widget.Button[contains(@resource-id,\"button1\")]")), new IosLocator(By.name("Delete"))), "Delete bookmark button"); @@ -43,7 +43,12 @@ public BookmarksEpubScreen() { } public boolean isBookmarkScreenOpened() { - return lblBookmarksTab.state().waitForDisplayed(); + boolean isOpened = ActionProcessorUtils.doForAndroid(() -> lblBookmarksTab.state().waitForDisplayed()); + + if (!isOpened) { + isOpened = ActionProcessorUtils.doForIos(() -> lblNoBookmarks.state().waitForDisplayed() || lblBookmarksTab.state().waitForDisplayed()); + } + return isOpened; } public boolean isBookmarkPresent(String expectedBookmarkTitle, String bookmarkDateTime) { diff --git a/src/test/java/screens/epub/NavigationBarScreen.java b/src/test/java/screens/epub/NavigationBarScreen.java index 9907a38..cc799fe 100644 --- a/src/test/java/screens/epub/NavigationBarScreen.java +++ b/src/test/java/screens/epub/NavigationBarScreen.java @@ -15,7 +15,7 @@ public class NavigationBarScreen extends Screen { private final IButton btnTOC = getElementFactory().getButton(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//android.widget.Button[contains(@resource-id,\"readerMenuTOC\")]")), - new IosLocator(By.xpath("//XCUIElementTypeNavigationBar/XCUIElementTypeButton[3]"))), "TOC button"); + new IosLocator(By.xpath("//XCUIElementTypeNavigationBar/XCUIElementTypeButton[@name=\"Table of contents and bookmarks\"]"))), "TOC button"); private final IButton btnAddBookmark = getElementFactory().getButton(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//android.widget.TextView[@content-desc=\"Create a bookmark for the current page\"]")), new IosLocator(By.xpath("//XCUIElementTypeNavigationBar/XCUIElementTypeButton[@name=\"Add Bookmark\"]"))), "Add Bookmark button"); diff --git a/src/test/java/stepdefinitions/AlertSteps.java b/src/test/java/stepdefinitions/AlertSteps.java index dfb52fc..cdb8380 100644 --- a/src/test/java/stepdefinitions/AlertSteps.java +++ b/src/test/java/stepdefinitions/AlertSteps.java @@ -23,7 +23,7 @@ public void tapActionButton(ActionButtonsForBooksAndAlertsKeys actionButtons) { alertScreen.waitAndPerformAlertActionIfDisplayed(actionButtons); } - @When("Tap Don't Allow button on the alert") + @When("Don't Allow notifications on the alert") public void tapDoNotAllow() { AqualityServices.getApplication().getDriver().switchTo().alert().dismiss(); } From 748fba5bfde09141908f9e170bfa3c9226ce7bbe Mon Sep 17 00:00:00 2001 From: AEkaterina Date: Wed, 18 Oct 2023 04:01:49 +0400 Subject: [PATCH 2/6] updated MyBooks test module --- src/test/java/features/RefreshFeed.feature | 4 ++-- src/test/java/screens/MyBooksScreen.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/java/features/RefreshFeed.feature b/src/test/java/features/RefreshFeed.feature index 1ab5522..ede13ed 100644 --- a/src/test/java/features/RefreshFeed.feature +++ b/src/test/java/features/RefreshFeed.feature @@ -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: - | Summer Reading | + | Mystery | 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 @@ -27,7 +27,7 @@ Feature: Feed Then Library "Palace Bookshelf" is opened on Libraries screen When Open Catalog And Open categories by chain and chain starts from CategoryScreen: - | Summer Reading | + | Mystery | 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 diff --git a/src/test/java/screens/MyBooksScreen.java b/src/test/java/screens/MyBooksScreen.java index b1e6699..351e3d5 100644 --- a/src/test/java/screens/MyBooksScreen.java +++ b/src/test/java/screens/MyBooksScreen.java @@ -27,7 +27,7 @@ public class MyBooksScreen extends Screen { new IosLocator(By.xpath("//XCUIElementTypeStaticText[contains(@name,'Visit the Catalog')]"))), "No books present label"); private final ILabel mainBooksElementCollection = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//android.view.ViewGroup[contains(@resource-id,\"feedContentRefresh\")]")), - new IosLocator(By.xpath("//XCUIElementTypeCollectionView"))), "Elements collection container"); + new IosLocator(By.xpath("//XCUIElementTypeScrollView"))), "Elements collection container"); private static final String BOOK_LOC_ANDROID = "//androidx.recyclerview.widget.RecyclerView/android.widget.FrameLayout"; private static final String BOOK_NAME_LOC_ANDROID = BOOK_LOC_ANDROID + "/android.view.ViewGroup/android.widget.TextView[1]"; @@ -35,9 +35,9 @@ public class MyBooksScreen 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//*[@text=\"%s\"]"; private static final String BOOK_NAME_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_LOC_IOS = "//XCUIElementTypeCollectionView//XCUIElementTypeCell"; - 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_NAME_BY_BOOK_NAME_AND_BUTTON_LOC_IOS = BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS + "/ancestor::XCUIElementTypeOther[2]/XCUIElementTypeStaticText[1]"; + private static final String BOOK_LOC_IOS = "//XCUIElementTypeScrollView/XCUIElementTypeOther/XCUIElementTypeButton"; + private static final String BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS = "//XCUIElementTypeStaticText[@name=\"%s\"]/following-sibling::XCUIElementTypeButton[contains(@name,\"%s\")]"; + private static final String BOOK_NAME_BY_BOOK_NAME_AND_BUTTON_LOC_IOS = BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS + "/ancestor::XCUIElementTypeButton/XCUIElementTypeStaticText[1]"; private static final String BOOK_NAME_LOC_IOS = BOOK_LOC_IOS + "/XCUIElementTypeOther/XCUIElementTypeStaticText[1]"; private static final String AUTHORS_NAME_LOC_IOS = BOOK_LOC_IOS + "/XCUIElementTypeOther/XCUIElementTypeStaticText[2]"; From 17704685405567749cc872f71e3351e45e3360a2 Mon Sep 17 00:00:00 2001 From: AEkaterina Date: Thu, 19 Oct 2023 16:12:43 +0400 Subject: [PATCH 3/6] updated pdf in Palace, added sonar --- .github/workflows/sonarqube.yml | 78 +++++++++++++++++++ src/test/java/features/PdfPalaceIos.feature | 5 +- src/test/java/screens/SortOptionsScreen.java | 2 +- .../screens/pdf/NavigationBarPdfScreen.java | 2 +- .../java/screens/pdf/ReaderPdfScreen.java | 2 +- .../java/screens/pdf/ThumbnailsPdfScreen.java | 2 +- .../stepdefinitions/ApplicationSteps.java | 7 +- 7 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/sonarqube.yml diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000..22b78f5 --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,78 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow helps you trigger a SonarQube analysis of your code and populates +# GitHub Code Scanning alerts with the vulnerabilities found. +# (this feature is available starting from SonarQube 9.7, Developer Edition and above) + +# 1. Make sure you add a valid GitHub configuration to your SonarQube (Administration > DevOps platforms > GitHub) + +# 2. Import your project on SonarQube +# * Add your repository as a new project by clicking "Create project" from your homepage. +# +# 3. Select GitHub Actions as your CI and follow the tutorial +# * a. Generate a new token and add it to your GitHub repository's secrets using the name SONAR_TOKEN +# (On SonarQube, click on your avatar on top-right > My account > Security or ask your administrator) +# +# * b. Copy/paste your SonarQube host URL to your GitHub repository's secrets using the name SONAR_HOST_URL +# +# * c. Copy/paste the project Key into the args parameter below +# (You'll find this information in SonarQube by following the tutorial or by clicking on Project Information at the top-right of your project's homepage) + +# Feel free to take a look at our documentation (https://docs.sonarqube.org/latest/analysis/github-integration/) +# or reach out to our community forum if you need some help (https://community.sonarsource.com/c/sq/10) + +name: SonarQube analysis + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +permissions: + pull-requests: read # allows SonarQube to decorate PRs with analysis results + +jobs: + Analysis: + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v3 + env: + EXCLUDE_PATH: palace/.git + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache SonarQube packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages + uses: actions/cache@v1 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Install SonarQube Scanner + run: | + curl -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip -o sonar-scanner.zip + unzip sonar-scanner.zip + rm sonar-scanner.zip + mv sonar-scanner-* sonar-scanner + sudo mv sonar-scanner /opt/ + sudo ln -s /opt/sonar-scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner + - name: Run SonarQube analysis + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + run: sonar-scanner -Dsonar.projectKey=Mobile_tests -Dsonar.projectName='MobileTests' -Dsonar.sources='src' -Dsonar.language='java' -Dsonar.java.binaries='src' -Dsonar.java.test.binaries='src' \ No newline at end of file diff --git a/src/test/java/features/PdfPalaceIos.feature b/src/test/java/features/PdfPalaceIos.feature index 7698f1f..ecaf2a3 100644 --- a/src/test/java/features/PdfPalaceIos.feature +++ b/src/test/java/features/PdfPalaceIos.feature @@ -9,7 +9,7 @@ Feature: Read PDF in Palace Bookshelf on IOS Then Library "Palace Bookshelf" is opened on Libraries screen When Open Catalog And Open search modal - And Search for 'Deep into Pharo' and save bookName as 'bookNameInfo' + And Search for 'Pharo by Example 5.0' 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' @@ -72,7 +72,8 @@ Feature: Read PDF in Palace Bookshelf on IOS @tier2 @exclude_android Scenario: Navigate by Page slider - When Save page number as 'pageNumber' on pdf reader screen + When Swipe pdf page forward from 4 to 6 times on reader pdf screen + And Save page number as 'pageNumber' on pdf reader screen And Slide page slider RIGHT on reader pdf screen Then The 'pageNumber' saved page number is less than the current page number on the reader pdf screen When Save page number as 'pageNumber' on pdf reader screen diff --git a/src/test/java/screens/SortOptionsScreen.java b/src/test/java/screens/SortOptionsScreen.java index 21d868f..0534c0f 100644 --- a/src/test/java/screens/SortOptionsScreen.java +++ b/src/test/java/screens/SortOptionsScreen.java @@ -17,7 +17,7 @@ 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[2]")), - new IosLocator(By.xpath("(//XCUIElementTypeCollectionView/preceding-sibling::XCUIElementTypeOther//XCUIElementTypeButton)[1]"))), "Sort by button"); + 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]")), new IosLocator(By.xpath("//XCUIElementTypeScrollView//XCUIElementTypeButton[2]"))), "Availability button"); diff --git a/src/test/java/screens/pdf/NavigationBarPdfScreen.java b/src/test/java/screens/pdf/NavigationBarPdfScreen.java index 7acc390..40a7cae 100644 --- a/src/test/java/screens/pdf/NavigationBarPdfScreen.java +++ b/src/test/java/screens/pdf/NavigationBarPdfScreen.java @@ -17,7 +17,7 @@ public class NavigationBarPdfScreen extends Screen { new IosLocator(By.xpath("//XCUIElementTypeNavigationBar/XCUIElementTypeOther[2]//XCUIElementTypeButton[2]"))), "Search button"); private final IButton btnBack = getElementFactory().getButton(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//android.widget.ImageButton[@content-desc=\"Back\"]")), - new IosLocator(By.xpath("//XCUIElementTypeNavigationBar/XCUIElementTypeButton[@name=\"Back\"]"))), "Back button"); + new IosLocator(By.xpath("//XCUIElementTypeNavigationBar//XCUIElementTypeButton[@name=\"Back\"]"))), "Back button"); private final IButton btnSettings = getElementFactory().getButton(By.xpath("//android.widget.Button[@content-desc=\"Settings\"]"), "Settings button"); private final IButton btnBookmark = getElementFactory().getButton(LocatorUtils.getLocator( new AndroidLocator(By.xpath("")), diff --git a/src/test/java/screens/pdf/ReaderPdfScreen.java b/src/test/java/screens/pdf/ReaderPdfScreen.java index 07767f6..a5ae010 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.substringBefore(lblPageNumber.getAttribute(IosAttributes.NAME), "/")); + return Integer.parseInt(StringUtils.substringBetween(lblPageNumber.getAttribute(IosAttributes.NAME), "(", "/")); }); if(pageNumber == null) { diff --git a/src/test/java/screens/pdf/ThumbnailsPdfScreen.java b/src/test/java/screens/pdf/ThumbnailsPdfScreen.java index 127c350..d73802b 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 = THUMBNAIL_LOCATOR_IOS + "/XCUIElementTypeStaticText[@name=\"%d\"]"; + private static final String THUMBNAIL_NUMBER_LOCATOR_IOS = "//XCUIElementTypeCollectionView/XCUIElementTypeCell[%d]/XCUIElementTypeStaticText"; public ThumbnailsPdfScreen() { super(LocatorUtils.getLocator( diff --git a/src/test/java/stepdefinitions/ApplicationSteps.java b/src/test/java/stepdefinitions/ApplicationSteps.java index 77ed958..c07df4d 100644 --- a/src/test/java/stepdefinitions/ApplicationSteps.java +++ b/src/test/java/stepdefinitions/ApplicationSteps.java @@ -1,7 +1,6 @@ package stepdefinitions; import aquality.appium.mobile.application.AqualityServices; -import aquality.appium.mobile.application.PlatformName; import com.google.inject.Inject; import enums.localization.catalog.ActionButtonsForBooksAndAlertsKeys; import enums.timeouts.RestartAppTimeouts; @@ -144,11 +143,7 @@ public void returnToPreviousScreenForEpubAndPdf() { readerEpubScreen.openNavigationBar(); readerEpubScreen.getNavigationBarEpubScreen().returnToPreviousScreen(); } else if (readerPdfScreen.state().isDisplayed()) { - if (AqualityServices.getApplication().getPlatformName() == PlatformName.ANDROID) { - readerPdfScreen.getNavigationBarScreen().tapBackButton(); - } else if (AqualityServices.getApplication().getPlatformName() == PlatformName.IOS) { - readerPdfScreen.getNavigationBarScreen().tapBackButton(); - } + readerPdfScreen.getNavigationBarScreen().tapBackButton(); } }); } From 21e27473eceb479257c8910c6b6447b2f9bb4a59 Mon Sep 17 00:00:00 2001 From: AEkaterina Date: Thu, 19 Oct 2023 16:57:22 +0400 Subject: [PATCH 4/6] fixed sonar comments --- src/test/java/hooks/LoggerHooks.java | 1 + .../screens/audiobook/AudioPlayerScreen.java | 21 +++++++++++++------ .../audiobook/PlaybackSpeedScreen.java | 21 +++++++++++++------ .../stepdefinitions/GettingBooksStep.java | 2 +- .../audiobooksteps/AudioPlayerSteps.java | 1 + 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/test/java/hooks/LoggerHooks.java b/src/test/java/hooks/LoggerHooks.java index fecc50b..e617835 100644 --- a/src/test/java/hooks/LoggerHooks.java +++ b/src/test/java/hooks/LoggerHooks.java @@ -64,6 +64,7 @@ public void afterStep(Scenario scenario) { @After public void afterTest(Scenario scenario) { + counter.remove(); counter.set(0); } } diff --git a/src/test/java/screens/audiobook/AudioPlayerScreen.java b/src/test/java/screens/audiobook/AudioPlayerScreen.java index 0ce79d4..ad9b103 100644 --- a/src/test/java/screens/audiobook/AudioPlayerScreen.java +++ b/src/test/java/screens/audiobook/AudioPlayerScreen.java @@ -19,6 +19,8 @@ import java.time.Duration; import java.util.HashMap; import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class AudioPlayerScreen extends Screen { @@ -93,12 +95,19 @@ public AudioPlayerScreen() { sleepTimerScreen = new SleepTimerScreen(); } - private static final Map speedNameIos = new HashMap() {{ - put("2.0", "Two times normal speed. Fastest."); - put("0.75", "Three quarters of normal speed. Slower."); - put("1.25", "One and one quarter faster than normal speed."); - put("1.5", "One and a half times faster than normal speed."); - }}; +// private static final Map speedNameIos = new HashMap() {{ +// put("2.0", "Two times normal speed. Fastest."); +// put("0.75", "Three quarters of normal speed. Slower."); +// put("1.25", "One and one quarter faster than normal speed."); +// put("1.5", "One and a half times faster than normal speed."); +// }}; + + private static final Map speedNameIos = Stream.of( + new String[]{"2.0", "Two times normal speed. Fastest."}, + new String[]{"0.75", "Three quarters of normal speed. Slower."}, + new String[]{"1.25", "One and one quarter faster than normal speed."}, + new String[]{"1.5", "One and a half times faster than normal speed."} + ).collect(Collectors.toMap(data -> data[0], data -> data[1])); public boolean isPlayerOpened(String bookName) { btnPlay.state().waitForDisplayed(); diff --git a/src/test/java/screens/audiobook/PlaybackSpeedScreen.java b/src/test/java/screens/audiobook/PlaybackSpeedScreen.java index 674b737..4aba4de 100644 --- a/src/test/java/screens/audiobook/PlaybackSpeedScreen.java +++ b/src/test/java/screens/audiobook/PlaybackSpeedScreen.java @@ -12,6 +12,8 @@ import java.util.HashMap; import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class PlaybackSpeedScreen extends Screen { @@ -30,13 +32,20 @@ public PlaybackSpeedScreen() { new IosLocator(By.xpath("//XCUIElementTypeStaticText[@name=\"Playback Speed\"]"))), "Playback speed screen"); } - private static Map speedNameIos = new HashMap() {{ - put("2.0", "Two times normal speed. Fastest."); - put("0.75", "Three quarters of normal speed. Slower."); - put("1.25", "One and one quarter faster than normal speed."); - put("1.5", "One and a half times faster than normal speed."); +// private static Map speedNameIos = new HashMap() {{ +// put("2.0", "Two times normal speed. Fastest."); +// put("0.75", "Three quarters of normal speed. Slower."); +// put("1.25", "One and one quarter faster than normal speed."); +// put("1.5", "One and a half times faster than normal speed."); +// +// }}; - }}; + private static final Map speedNameIos = Stream.of( + new String[]{"2.0", "Two times normal speed. Fastest."}, + new String[]{"0.75", "Three quarters of normal speed. Slower."}, + new String[]{"1.25", "One and one quarter faster than normal speed."}, + new String[]{"1.5", "One and a half times faster than normal speed."} + ).collect(Collectors.toMap(data -> data[0], data -> data[1])); public void selectPlaybackSpeed(String playbackSpeed) { ActionProcessorUtils.doForIos(() -> { diff --git a/src/test/java/stepdefinitions/GettingBooksStep.java b/src/test/java/stepdefinitions/GettingBooksStep.java index 8e512aa..0328ffe 100644 --- a/src/test/java/stepdefinitions/GettingBooksStep.java +++ b/src/test/java/stepdefinitions/GettingBooksStep.java @@ -14,6 +14,7 @@ import java.util.Random; public class GettingBooksStep { + private static final Random random = new Random(); private static final CatalogScreen catalogScreen = new CatalogScreen(); private static final SearchScreen searchScreen = new SearchScreen(); private static final SortOptionsScreen sortOptionsScreen = new SortOptionsScreen(); @@ -52,7 +53,6 @@ public static String getBookFromSection(String bookType, String distributor) { SwipeElementUtils.swipeDown(); List books = catalogScreen.getListOfBooksNames(); - Random random = new Random(); int bookIndex = random.nextInt(books.size()); String bookName = books.get(bookIndex); if(bookType.equalsIgnoreCase(BookType.AUDIOBOOK.getBookType())) { diff --git a/src/test/java/stepdefinitions/audiobooksteps/AudioPlayerSteps.java b/src/test/java/stepdefinitions/audiobooksteps/AudioPlayerSteps.java index 1f0104a..00f3777 100644 --- a/src/test/java/stepdefinitions/audiobooksteps/AudioPlayerSteps.java +++ b/src/test/java/stepdefinitions/audiobooksteps/AudioPlayerSteps.java @@ -67,6 +67,7 @@ public void checkThatBookIsNotPlayingOnAudioPlayerScreen() { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); + Thread.currentThread().interrupt(); } Assert.assertEquals("Book is playing on audio player screen", firstTiming, audioPlayerScreen.getLeftTime()); } From b2e6e7eba3ad177152052ec1f8f92ca4be13b3d3 Mon Sep 17 00:00:00 2001 From: AEkaterina Date: Thu, 19 Oct 2023 20:33:14 +0400 Subject: [PATCH 5/6] fixed sonar comments --- src/test/java/constants/RegEx.java | 2 ++ .../appattributes/AndroidAttributes.java | 5 ++- .../appattributes/IosAttributes.java | 5 ++- .../ScenarioContextKey.java | 4 ++- .../catalog/BookActionButtonNames.java | 2 ++ .../AbstractILocalizationProvider.java | 2 +- .../providers/LocalizationController.java | 7 ++-- .../LocalizationProviderFactory.java | 2 ++ .../java/constants/util/UtilConstants.java | 2 ++ src/test/java/enums/BookType.java | 4 +-- .../configuration/ConfigurationStorage.java | 2 ++ .../framework/configuration/Credentials.java | 1 + .../utilities/ActionProcessorUtils.java | 2 ++ .../java/framework/utilities/DateUtils.java | 2 ++ .../framework/utilities/LocatorUtils.java | 2 ++ .../framework/utilities/PlatformUtils.java | 2 ++ .../java/framework/utilities/RegExUtil.java | 6 ++-- .../framework/utilities/ScreenshotUtils.java | 2 ++ .../BookModel.java | 2 +- .../FeedModel.java | 8 ++--- .../GettingBookUtil.java | 4 ++- .../XMLAPIMethods.java | 2 +- .../{feedXMLUtil => feedxmlutil}/XMLUtil.java | 33 +++++++++-------- .../APIPageXMLModel.java | 2 +- .../APIUtil.java | 13 ++++--- .../GetBooksAPIMethods.java | 2 +- .../ReturnBooksAPIMethods.java | 2 +- .../utilities/swipe/SwipeElementUtils.java | 36 +------------------ src/test/java/hooks/LoggerHooks.java | 4 +-- src/test/java/hooks/ReturningBooksHooks.java | 6 ++-- src/test/java/hooks/ScreenshotHooks.java | 2 +- src/test/java/hooks/logout/LogoutHooks.java | 2 +- src/test/java/runners/TestRunner.java | 8 +++-- src/test/java/screens/AlertScreen.java | 4 +-- src/test/java/screens/BookDetailsScreen.java | 5 --- src/test/java/screens/CatalogBooksScreen.java | 22 +++++------- src/test/java/screens/CatalogScreen.java | 6 ++-- .../java/screens/SoftwareLicensesScreen.java | 4 +-- src/test/java/screens/SubcategoryScreen.java | 12 +++---- .../java/screens/UserAgreementScreen.java | 2 +- .../screens/audiobook/AudioPlayerScreen.java | 8 ----- .../audiobook/PlaybackSpeedScreen.java | 9 ----- .../stepdefinitions/CredentialsSteps.java | 4 +-- .../stepdefinitions/GettingBooksStep.java | 4 +-- .../java/stepdefinitions/SignInSteps.java | 4 +-- src/test/java/stepdefinitions/XMLSteps.java | 2 +- 46 files changed, 119 insertions(+), 147 deletions(-) rename src/test/java/constants/{keysForContext => keysforcontext}/ScenarioContextKey.java (69%) rename src/test/java/framework/utilities/{feedXMLUtil => feedxmlutil}/BookModel.java (96%) rename src/test/java/framework/utilities/{feedXMLUtil => feedxmlutil}/FeedModel.java (96%) rename src/test/java/framework/utilities/{feedXMLUtil => feedxmlutil}/GettingBookUtil.java (88%) rename src/test/java/framework/utilities/{feedXMLUtil => feedxmlutil}/XMLAPIMethods.java (80%) rename src/test/java/framework/utilities/{feedXMLUtil => feedxmlutil}/XMLUtil.java (93%) rename src/test/java/framework/utilities/{returningBooksUtil => returningbooksutil}/APIPageXMLModel.java (97%) rename src/test/java/framework/utilities/{returningBooksUtil => returningbooksutil}/APIUtil.java (93%) rename src/test/java/framework/utilities/{returningBooksUtil => returningbooksutil}/GetBooksAPIMethods.java (83%) rename src/test/java/framework/utilities/{returningBooksUtil => returningbooksutil}/ReturnBooksAPIMethods.java (86%) diff --git a/src/test/java/constants/RegEx.java b/src/test/java/constants/RegEx.java index 02b1fbf..692120d 100644 --- a/src/test/java/constants/RegEx.java +++ b/src/test/java/constants/RegEx.java @@ -7,4 +7,6 @@ public class RegEx { public static final String PAGE_NUMBER_REGEX_FOR_ANDROID = "Page (\\d+) of (\\d+)"; public static final String VALID_PUBLISHER_OR_CATEGORY_NAME = "([a-zA-Z0-9&\\s-,;'./]*)([a-zA-Z,&\\s;:'.]*)([a-zA-Z0-9,\\s-'.]*)"; public static final String DATE_TIME_FORMAT = "y-M-dd HH:m:s"; + + private RegEx() { } } diff --git a/src/test/java/constants/appattributes/AndroidAttributes.java b/src/test/java/constants/appattributes/AndroidAttributes.java index 7006ba6..52a6f0a 100644 --- a/src/test/java/constants/appattributes/AndroidAttributes.java +++ b/src/test/java/constants/appattributes/AndroidAttributes.java @@ -1,11 +1,10 @@ package constants.appattributes; -import lombok.experimental.UtilityClass; - -@UtilityClass public class AndroidAttributes { public static final String CONTENT_DESC = "content-desc"; public static final String TEXT = "text"; public static final String SELECTED = "selected"; public static final String CHECKED = "checked"; + + private AndroidAttributes() { } } diff --git a/src/test/java/constants/appattributes/IosAttributes.java b/src/test/java/constants/appattributes/IosAttributes.java index a7d00b5..eac5f9a 100644 --- a/src/test/java/constants/appattributes/IosAttributes.java +++ b/src/test/java/constants/appattributes/IosAttributes.java @@ -1,10 +1,9 @@ package constants.appattributes; -import lombok.experimental.UtilityClass; - -@UtilityClass public class IosAttributes { public static final String NAME = "name"; public static final String VALUE = "value"; public static final String VISIBLE = "visible"; + + private IosAttributes() {} } diff --git a/src/test/java/constants/keysForContext/ScenarioContextKey.java b/src/test/java/constants/keysforcontext/ScenarioContextKey.java similarity index 69% rename from src/test/java/constants/keysForContext/ScenarioContextKey.java rename to src/test/java/constants/keysforcontext/ScenarioContextKey.java index 40c3d25..e47ec47 100644 --- a/src/test/java/constants/keysForContext/ScenarioContextKey.java +++ b/src/test/java/constants/keysforcontext/ScenarioContextKey.java @@ -1,6 +1,8 @@ -package constants.keysForContext; +package constants.keysforcontext; public class ScenarioContextKey { public static final String SCENARIO_KEY = "SCENARIO"; public static final String LIST_OF_CREDENTIALS_KEY = "CREDENTIALS"; + + private ScenarioContextKey() { } } diff --git a/src/test/java/constants/localization/catalog/BookActionButtonNames.java b/src/test/java/constants/localization/catalog/BookActionButtonNames.java index d5cf7f9..8c8aea6 100644 --- a/src/test/java/constants/localization/catalog/BookActionButtonNames.java +++ b/src/test/java/constants/localization/catalog/BookActionButtonNames.java @@ -3,4 +3,6 @@ public class BookActionButtonNames { public static final String GET_BUTTON_NAME = "Get"; public static final String DOWNLOAD_BUTTON_NAME = "Download"; + + private BookActionButtonNames() { } } diff --git a/src/test/java/constants/localization/providers/AbstractILocalizationProvider.java b/src/test/java/constants/localization/providers/AbstractILocalizationProvider.java index 4a386bc..38186ab 100644 --- a/src/test/java/constants/localization/providers/AbstractILocalizationProvider.java +++ b/src/test/java/constants/localization/providers/AbstractILocalizationProvider.java @@ -27,7 +27,7 @@ public abstract class AbstractILocalizationProvider implements ILocalizationProv */ private final String filename; - public AbstractILocalizationProvider(@NonNull String filename) { + protected AbstractILocalizationProvider(@NonNull String filename) { localizationController = new LocalizationController(StandardCharsets.UTF_8); this.filename = filename; bundles.put(DEFAULT_LOCALE, ResourceBundle diff --git a/src/test/java/constants/localization/providers/LocalizationController.java b/src/test/java/constants/localization/providers/LocalizationController.java index a5c4fa9..685ca48 100644 --- a/src/test/java/constants/localization/providers/LocalizationController.java +++ b/src/test/java/constants/localization/providers/LocalizationController.java @@ -1,5 +1,6 @@ package constants.localization.providers; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -18,6 +19,7 @@ public LocalizationController(Charset charset) { this.charset = charset; } + @Override public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IOException { String bundleName = toBundleName(baseName, locale); @@ -37,8 +39,9 @@ public ResourceBundle newBundle(String baseName, Locale locale, String format, stream = loader.getResourceAsStream(resourceName); } if (stream != null) { - try { - bundle = new PropertyResourceBundle(new InputStreamReader(stream, charset)); + try(InputStreamReader inputStreamReader = new InputStreamReader(stream, charset); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) { + bundle = new PropertyResourceBundle(bufferedReader); } finally { stream.close(); } diff --git a/src/test/java/constants/localization/providers/LocalizationProviderFactory.java b/src/test/java/constants/localization/providers/LocalizationProviderFactory.java index e535fd8..af02e79 100644 --- a/src/test/java/constants/localization/providers/LocalizationProviderFactory.java +++ b/src/test/java/constants/localization/providers/LocalizationProviderFactory.java @@ -6,6 +6,8 @@ public class LocalizationProviderFactory { private static Map providers = new ConcurrentHashMap<>(); + private LocalizationProviderFactory () { } + public static AbstractILocalizationProvider getProvider(String fileName) { return providers.computeIfAbsent(fileName, v -> new AbstractILocalizationProvider(v) { // default diff --git a/src/test/java/constants/util/UtilConstants.java b/src/test/java/constants/util/UtilConstants.java index e48459f..7eb194b 100644 --- a/src/test/java/constants/util/UtilConstants.java +++ b/src/test/java/constants/util/UtilConstants.java @@ -15,4 +15,6 @@ public class UtilConstants { public static final String PALACE_MARKETPLACE = "palace marketplace"; public static final String PALACE_MARKETPLACE_CATEGORY = "Palace Marketplace Test"; public static final String PALACE_BOOKSHELF = "Palace Bookshelf"; + + private UtilConstants() { } } diff --git a/src/test/java/enums/BookType.java b/src/test/java/enums/BookType.java index 03cf089..0c3cb16 100644 --- a/src/test/java/enums/BookType.java +++ b/src/test/java/enums/BookType.java @@ -8,9 +8,9 @@ public enum BookType { AUDIOBOOK("audiobook"), PDF("pdf"); - private String bookType; + private String currentBookType; public String getBookType() { - return bookType; + return currentBookType; } } \ No newline at end of file diff --git a/src/test/java/framework/configuration/ConfigurationStorage.java b/src/test/java/framework/configuration/ConfigurationStorage.java index 20148b0..4395a48 100644 --- a/src/test/java/framework/configuration/ConfigurationStorage.java +++ b/src/test/java/framework/configuration/ConfigurationStorage.java @@ -8,6 +8,8 @@ public class ConfigurationStorage { private static Map map = new ConcurrentHashMap<>(); + private ConfigurationStorage() {} + public static synchronized void lockCredentials(String barcode) { AqualityServices.getLogger().info("Locking credential with barcode " + barcode); map.put(Thread.currentThread().getId(), barcode); diff --git a/src/test/java/framework/configuration/Credentials.java b/src/test/java/framework/configuration/Credentials.java index 3f57fbe..352f130 100644 --- a/src/test/java/framework/configuration/Credentials.java +++ b/src/test/java/framework/configuration/Credentials.java @@ -4,6 +4,7 @@ @Data public class Credentials { + private String barcode; private String pin; diff --git a/src/test/java/framework/utilities/ActionProcessorUtils.java b/src/test/java/framework/utilities/ActionProcessorUtils.java index f6d8b48..3517585 100644 --- a/src/test/java/framework/utilities/ActionProcessorUtils.java +++ b/src/test/java/framework/utilities/ActionProcessorUtils.java @@ -10,6 +10,8 @@ public class ActionProcessorUtils { private static final PlatformName PLATFORM_NAME = AqualityServices.getApplication().getPlatformName(); + private ActionProcessorUtils() {} + private static void doForPlatform(PlatformName platformName, Runnable action) { if(PLATFORM_NAME.equals(platformName)) { action.run(); diff --git a/src/test/java/framework/utilities/DateUtils.java b/src/test/java/framework/utilities/DateUtils.java index 2fc1ce6..5e61c52 100644 --- a/src/test/java/framework/utilities/DateUtils.java +++ b/src/test/java/framework/utilities/DateUtils.java @@ -9,6 +9,8 @@ import java.util.List; public class DateUtils { + + private DateUtils() {} public static Duration getDuration(String date) { String formattedString = ""; List parts = Arrays.asList(date.split(":")); diff --git a/src/test/java/framework/utilities/LocatorUtils.java b/src/test/java/framework/utilities/LocatorUtils.java index 1e5befe..987e7ea 100644 --- a/src/test/java/framework/utilities/LocatorUtils.java +++ b/src/test/java/framework/utilities/LocatorUtils.java @@ -10,6 +10,8 @@ public class LocatorUtils { private static final PlatformName PLATFORM_NAME = AqualityServices.getApplication().getPlatformName(); + private LocatorUtils() {} + public static By getLocator(AndroidLocator androidLocator, IosLocator iosLocator) { switch (PLATFORM_NAME) { case ANDROID: diff --git a/src/test/java/framework/utilities/PlatformUtils.java b/src/test/java/framework/utilities/PlatformUtils.java index 4553615..fa5fe34 100644 --- a/src/test/java/framework/utilities/PlatformUtils.java +++ b/src/test/java/framework/utilities/PlatformUtils.java @@ -5,6 +5,8 @@ public class PlatformUtils { + private PlatformUtils() {} + public static PlatformName getPlatformName() { return AqualityServices.getApplication().getPlatformName(); } diff --git a/src/test/java/framework/utilities/RegExUtil.java b/src/test/java/framework/utilities/RegExUtil.java index c451724..ded722a 100644 --- a/src/test/java/framework/utilities/RegExUtil.java +++ b/src/test/java/framework/utilities/RegExUtil.java @@ -5,9 +5,11 @@ public class RegExUtil { + private RegExUtil() {} + public static String deleteBracketsFromText(String text) { - text = text.replaceAll("\\(", ""); - text = text.replaceAll("\\)", ""); + text = text.replace("\\(", ""); + text = text.replace("\\)", ""); return text; } diff --git a/src/test/java/framework/utilities/ScreenshotUtils.java b/src/test/java/framework/utilities/ScreenshotUtils.java index d622fdf..0f816c7 100644 --- a/src/test/java/framework/utilities/ScreenshotUtils.java +++ b/src/test/java/framework/utilities/ScreenshotUtils.java @@ -4,6 +4,8 @@ import org.openqa.selenium.OutputType; public class ScreenshotUtils { + + private ScreenshotUtils() {} public static byte[] getScreenshot() { AqualityServices.getApplication().getDriver().getPageSource(); return AqualityServices.getApplication().getDriver().getScreenshotAs(OutputType.BYTES); diff --git a/src/test/java/framework/utilities/feedXMLUtil/BookModel.java b/src/test/java/framework/utilities/feedxmlutil/BookModel.java similarity index 96% rename from src/test/java/framework/utilities/feedXMLUtil/BookModel.java rename to src/test/java/framework/utilities/feedxmlutil/BookModel.java index e26695c..d112f62 100644 --- a/src/test/java/framework/utilities/feedXMLUtil/BookModel.java +++ b/src/test/java/framework/utilities/feedxmlutil/BookModel.java @@ -1,4 +1,4 @@ -package framework.utilities.feedXMLUtil; +package framework.utilities.feedxmlutil; import java.util.Objects; diff --git a/src/test/java/framework/utilities/feedXMLUtil/FeedModel.java b/src/test/java/framework/utilities/feedxmlutil/FeedModel.java similarity index 96% rename from src/test/java/framework/utilities/feedXMLUtil/FeedModel.java rename to src/test/java/framework/utilities/feedxmlutil/FeedModel.java index 3f0372c..585cb3e 100644 --- a/src/test/java/framework/utilities/feedXMLUtil/FeedModel.java +++ b/src/test/java/framework/utilities/feedxmlutil/FeedModel.java @@ -1,4 +1,4 @@ -package framework.utilities.feedXMLUtil; +package framework.utilities.feedxmlutil; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -180,7 +180,7 @@ public void setCountAvailableCopies(int countAvailableCopies) { class IndirectAcquisition{ private String type; - private InternalIndirectAcquisition indirectAcquisition; + private InternalIndirectAcquisition internalIndirectAcquisition; public String getType() { return type; @@ -192,12 +192,12 @@ public void setType(String type) { } public InternalIndirectAcquisition getInternalIndirectAcquisition() { - return indirectAcquisition; + return internalIndirectAcquisition; } @XmlElement(name = "indirectAcquisition", namespace = "http://opds-spec.org/2010/catalog") public void setInternalIndirectAcquisition(InternalIndirectAcquisition indirectAcquisition) { - this.indirectAcquisition = indirectAcquisition; + this.internalIndirectAcquisition = indirectAcquisition; } } diff --git a/src/test/java/framework/utilities/feedXMLUtil/GettingBookUtil.java b/src/test/java/framework/utilities/feedxmlutil/GettingBookUtil.java similarity index 88% rename from src/test/java/framework/utilities/feedXMLUtil/GettingBookUtil.java rename to src/test/java/framework/utilities/feedxmlutil/GettingBookUtil.java index e0447f0..ec0b411 100644 --- a/src/test/java/framework/utilities/feedXMLUtil/GettingBookUtil.java +++ b/src/test/java/framework/utilities/feedxmlutil/GettingBookUtil.java @@ -1,8 +1,10 @@ -package framework.utilities.feedXMLUtil; +package framework.utilities.feedxmlutil; public class GettingBookUtil { private static XMLUtil xmlUtil; + private GettingBookUtil() {} + public static synchronized void setXmlUtil(XMLUtil xml){ xmlUtil = xml; } diff --git a/src/test/java/framework/utilities/feedXMLUtil/XMLAPIMethods.java b/src/test/java/framework/utilities/feedxmlutil/XMLAPIMethods.java similarity index 80% rename from src/test/java/framework/utilities/feedXMLUtil/XMLAPIMethods.java rename to src/test/java/framework/utilities/feedxmlutil/XMLAPIMethods.java index 165bced..dd76bf0 100644 --- a/src/test/java/framework/utilities/feedXMLUtil/XMLAPIMethods.java +++ b/src/test/java/framework/utilities/feedxmlutil/XMLAPIMethods.java @@ -1,4 +1,4 @@ -package framework.utilities.feedXMLUtil; +package framework.utilities.feedxmlutil; import retrofit2.Call; import retrofit2.http.GET; diff --git a/src/test/java/framework/utilities/feedXMLUtil/XMLUtil.java b/src/test/java/framework/utilities/feedxmlutil/XMLUtil.java similarity index 93% rename from src/test/java/framework/utilities/feedXMLUtil/XMLUtil.java rename to src/test/java/framework/utilities/feedxmlutil/XMLUtil.java index 6c4202b..ff8d5f1 100644 --- a/src/test/java/framework/utilities/feedXMLUtil/XMLUtil.java +++ b/src/test/java/framework/utilities/feedxmlutil/XMLUtil.java @@ -1,4 +1,4 @@ -package framework.utilities.feedXMLUtil; +package framework.utilities.feedxmlutil; import aquality.appium.mobile.application.AqualityServices; import constants.util.UtilConstants; @@ -15,8 +15,9 @@ import java.util.stream.Collectors; public class XMLUtil { + private static final String SEPARATOR_LINE = "//////////////////////////////////////////////////////////////////////////////////////"; private static final String BASE_URL = "https://gorgon.tpp-qa.lyrasistechnology.org"; - private static final String partOfURL = "lyrasis-reads/crawlable"; + private static final String PART_OF_URL = "lyrasis-reads/crawlable"; private HashMap> hashMapAvailableEbooks; private HashMap> hashMapAvailableAudiobooks; private HashMap> hashMapUnavailableEbooks; @@ -24,33 +25,33 @@ public class XMLUtil { private ArrayList availableBooksAnyType; private ArrayList unavailableBooksAnyType; private ArrayList availablePdf; - private final int CONNECT_TIMEOUT = 120; - private final int READ_TIMEOUT = 120; - private final int WRITE_TIMEOUT = 120; - private final int THREAD_SLEEP_TIME = 3000; + private static final int CONNECT_TIMEOUT = 120; + private static final int READ_TIMEOUT = 120; + private static final int WRITE_TIMEOUT = 120; + private static final int THREAD_SLEEP_TIME = 3000; public XMLUtil() { setHashMapsForEBooksAndAudioBooks(); } public void getDistributorsInfo(){ - AqualityServices.getLogger().info("//////////////////////////////////////////////////////////////////////////////////////"); + AqualityServices.getLogger().info(SEPARATOR_LINE); for (String distributor : hashMapAvailableAudiobooks.keySet()) { printDistributorInfo("hashMapAvailableAudiobooks", distributor, hashMapAvailableAudiobooks.get(distributor)); } - AqualityServices.getLogger().info("//////////////////////////////////////////////////////////////////////////////////////"); + AqualityServices.getLogger().info(SEPARATOR_LINE); for (String distributor : hashMapAvailableEbooks.keySet()) { printDistributorInfo("hashMapAvailableEbooks", distributor, hashMapAvailableEbooks.get(distributor)); } - AqualityServices.getLogger().info("//////////////////////////////////////////////////////////////////////////////////////"); + AqualityServices.getLogger().info(SEPARATOR_LINE); for (String distributor : hashMapUnavailableAudiobooks.keySet()) { printDistributorInfo("hashMapUnavailableAudiobooks", distributor, hashMapUnavailableAudiobooks.get(distributor)); } - AqualityServices.getLogger().info("//////////////////////////////////////////////////////////////////////////////////////"); + AqualityServices.getLogger().info(SEPARATOR_LINE); for (String distributor : hashMapUnavailableEbooks.keySet()) { printDistributorInfo("hashMapUnavailableEbooks", distributor, hashMapUnavailableEbooks.get(distributor)); } - AqualityServices.getLogger().info("//////////////////////////////////////////////////////////////////////////////////////"); + AqualityServices.getLogger().info(SEPARATOR_LINE); } private void printDistributorInfo(String text, String distributor, List list){ @@ -62,15 +63,14 @@ private void printDistributorInfo(String text, String distributor, List listAvailableBooksAnyType = new ArrayList<>(); ArrayList listUnavailableBooksAnyType = new ArrayList<>(); ArrayList listAvailablePdf = new ArrayList<>(); while (true) { FeedModel feedModel = supportMethod(url); - boolean isNextXMLPresent = feedModel.getLinksFromFeed().stream().anyMatch(link -> link.getConditionForNextXML().equals(UtilConstants.NEXT.toLowerCase())); - if (!isNextXMLPresent) { + if (!hasNextXML(feedModel)) { break; } @@ -156,6 +156,11 @@ private void setListAvailableAndUnavailableBooksAnyTypeMayBeWithRepeat() { availablePdf = getListAvailablePdfWithoutRepetitions(listAvailablePdf); } + private boolean hasNextXML(FeedModel feedModel) { + return feedModel.getLinksFromFeed().stream() + .anyMatch(link -> link.getConditionForNextXML().equals(UtilConstants.NEXT.toLowerCase())); + } + private ArrayList getListAvailablePdfWithoutRepetitions(ArrayList arrayList) { Set setAvailablePdf = new HashSet<>(arrayList); diff --git a/src/test/java/framework/utilities/returningBooksUtil/APIPageXMLModel.java b/src/test/java/framework/utilities/returningbooksutil/APIPageXMLModel.java similarity index 97% rename from src/test/java/framework/utilities/returningBooksUtil/APIPageXMLModel.java rename to src/test/java/framework/utilities/returningbooksutil/APIPageXMLModel.java index 6e7a015..bb7b5df 100644 --- a/src/test/java/framework/utilities/returningBooksUtil/APIPageXMLModel.java +++ b/src/test/java/framework/utilities/returningbooksutil/APIPageXMLModel.java @@ -1,4 +1,4 @@ -package framework.utilities.returningBooksUtil; +package framework.utilities.returningbooksutil; import javax.xml.bind.annotation.XmlAttribute; diff --git a/src/test/java/framework/utilities/returningBooksUtil/APIUtil.java b/src/test/java/framework/utilities/returningbooksutil/APIUtil.java similarity index 93% rename from src/test/java/framework/utilities/returningBooksUtil/APIUtil.java rename to src/test/java/framework/utilities/returningbooksutil/APIUtil.java index 0a29080..f7a1030 100644 --- a/src/test/java/framework/utilities/returningBooksUtil/APIUtil.java +++ b/src/test/java/framework/utilities/returningbooksutil/APIUtil.java @@ -1,4 +1,4 @@ -package framework.utilities.returningBooksUtil; +package framework.utilities.returningbooksutil; import aquality.appium.mobile.application.AqualityServices; import framework.configuration.Credentials; @@ -15,6 +15,9 @@ public class APIUtil { private static final PropertyUtils propertyUtils = new PropertyUtils("src/test/resources/apiConfig.properties"); + private static final String PROPERTY_BASE_URL = "base_url"; + + private APIUtil() { } public static void returnBooks(Credentials credentials) { String authHeader = getAuthHeader(credentials); @@ -43,14 +46,14 @@ private static void sendRequestsForReturningBooks(String authHeader, ArrayList getListOfBooksInAccount(String authHeader) { OkHttpClient client = makeHttpClient(); GetBooksAPIMethods getBooksAPIMethods = new Retrofit .Builder() - .baseUrl(propertyUtils.getProperty("base_url")) + .baseUrl(propertyUtils.getProperty(PROPERTY_BASE_URL)) .addConverterFactory(JaxbConverterFactory.create()) .client(client) .build() diff --git a/src/test/java/framework/utilities/returningBooksUtil/GetBooksAPIMethods.java b/src/test/java/framework/utilities/returningbooksutil/GetBooksAPIMethods.java similarity index 83% rename from src/test/java/framework/utilities/returningBooksUtil/GetBooksAPIMethods.java rename to src/test/java/framework/utilities/returningbooksutil/GetBooksAPIMethods.java index 3f01807..d8b601a 100644 --- a/src/test/java/framework/utilities/returningBooksUtil/GetBooksAPIMethods.java +++ b/src/test/java/framework/utilities/returningbooksutil/GetBooksAPIMethods.java @@ -1,4 +1,4 @@ -package framework.utilities.returningBooksUtil; +package framework.utilities.returningbooksutil; import retrofit2.Call; import retrofit2.http.GET; diff --git a/src/test/java/framework/utilities/returningBooksUtil/ReturnBooksAPIMethods.java b/src/test/java/framework/utilities/returningbooksutil/ReturnBooksAPIMethods.java similarity index 86% rename from src/test/java/framework/utilities/returningBooksUtil/ReturnBooksAPIMethods.java rename to src/test/java/framework/utilities/returningbooksutil/ReturnBooksAPIMethods.java index 5e1a546..e0f25c6 100644 --- a/src/test/java/framework/utilities/returningBooksUtil/ReturnBooksAPIMethods.java +++ b/src/test/java/framework/utilities/returningbooksutil/ReturnBooksAPIMethods.java @@ -1,4 +1,4 @@ -package framework.utilities.returningBooksUtil; +package framework.utilities.returningbooksutil; import okhttp3.ResponseBody; import retrofit2.Call; diff --git a/src/test/java/framework/utilities/swipe/SwipeElementUtils.java b/src/test/java/framework/utilities/swipe/SwipeElementUtils.java index 425846c..bedb826 100644 --- a/src/test/java/framework/utilities/swipe/SwipeElementUtils.java +++ b/src/test/java/framework/utilities/swipe/SwipeElementUtils.java @@ -26,29 +26,7 @@ public static void swipeElementDown(IElement element) { Point center = mobileElement.getCenter(); element.getTouchActions().swipe(new Point(upperLeft.x + dimensions.width / 2, center.getY() + dimensions.height / 2)); } -// -// public static void swipeElementUp(IElement element) { -// MobileElement mobileElement = element.getElement(); -// Point upperLeft = mobileElement.getLocation(); -// Point center = mobileElement.getCenter(); -// element.getTouchActions().swipe(new Point(center.x, upperLeft.y)); -// } -// -// public static void swipeThroughEntireElementUp(IElement element) { -// MobileElement mobileElement = element.getElement(); -// Point upperLeft = mobileElement.getLocation(); -// Point center = mobileElement.getCenter(); -// Dimension dimensions = mobileElement.getSize(); -// ITouchActions touchActions = AqualityServices.getTouchActions(); -// touchActions.swipe(new Point(center.x, upperLeft.y + dimensions.height - 1), new Point(center.x, upperLeft.y - 1)); -// } -// -// public static void swipeFromLeftToRight(IElement element) { -// MobileElement mobileElement = element.getElement(); -// Rectangle rectangle = mobileElement.getRect(); -// element.getTouchActions().swipe(new Point(rectangle.x + rectangle.width - 1, mobileElement.getCenter().y)); -// } -// + public static void swipeFromRightToLeft(IElement element) { Point point = element.getElement().getCenter(); AqualityServices.getTouchActions().swipe(new Point(0, element.getElement().getCenter().y), point); @@ -66,18 +44,6 @@ public static void swipeThroughEntireElement(IElement element, EntireElementSwip AqualityServices.getTouchActions().swipe(direction.getFrom(), direction.getTo()); } - /* - * The method can be applied to every element with swiping/dragging support. - * Swipe/drag will be performed from one edge of the screen to another. - * - * @param element element to be dragged/swiped - * @param entireScreenDragDirection direction of the drag/swipe - */ -// public static void dragElementThroughEntireScreen(IElement element, EntireScreenDragDirection entireScreenDragDirection) { -// Direction direction = entireScreenDragDirection.getDragDirection(element); -// AqualityServices.getTouchActions().swipe(direction.getFrom(), direction.getTo()); -// } - public static void swipeDown() { double x = AqualityServices.getApplication().getDriver().manage().window().getSize().getWidth() * 0.5; double fromY = AqualityServices.getApplication().getDriver().manage().window().getSize().getHeight() * 0.8; diff --git a/src/test/java/hooks/LoggerHooks.java b/src/test/java/hooks/LoggerHooks.java index e617835..13a8fef 100644 --- a/src/test/java/hooks/LoggerHooks.java +++ b/src/test/java/hooks/LoggerHooks.java @@ -39,16 +39,14 @@ public void addLogToScenario(Scenario scenario) { @BeforeStep public void getStepName(Scenario scenario) throws Exception { Field delegateField = scenario.getClass().getDeclaredField("delegate"); - delegateField.setAccessible(true); TestCaseState testCaseState = (TestCaseState) delegateField.get(scenario); Field testCaseField = testCaseState.getClass().getDeclaredField("testCase"); - testCaseField.setAccessible(true); TestCase r1 = (TestCase) testCaseField.get(testCaseState); List stepDefinitions = r1.getTestSteps() .stream() - .filter(x -> x instanceof PickleStepTestStep) + .filter(PickleStepTestStep.class::isInstance) .map(x -> (PickleStepTestStep) x) .collect(Collectors.toList()); diff --git a/src/test/java/hooks/ReturningBooksHooks.java b/src/test/java/hooks/ReturningBooksHooks.java index 046d657..608f765 100644 --- a/src/test/java/hooks/ReturningBooksHooks.java +++ b/src/test/java/hooks/ReturningBooksHooks.java @@ -2,10 +2,10 @@ import aquality.appium.mobile.application.AqualityServices; import com.google.inject.Inject; -import constants.keysForContext.ScenarioContextKey; +import constants.keysforcontext.ScenarioContextKey; import framework.configuration.Credentials; import framework.utilities.ScenarioContext; -import framework.utilities.returningBooksUtil.APIUtil; +import framework.utilities.returningbooksutil.APIUtil; import io.cucumber.java.After; import java.util.Map; @@ -25,8 +25,6 @@ public void returnBooks() { AqualityServices.getLogger().info("Test finished - returning books"); Map map = context.get(ScenarioContextKey.LIST_OF_CREDENTIALS_KEY); - System.out.println(map.size()); - if (map.size() == 0) { throw new RuntimeException("There are not barcodes for returning books"); } diff --git a/src/test/java/hooks/ScreenshotHooks.java b/src/test/java/hooks/ScreenshotHooks.java index 61bbeba..7656202 100644 --- a/src/test/java/hooks/ScreenshotHooks.java +++ b/src/test/java/hooks/ScreenshotHooks.java @@ -2,7 +2,7 @@ import aquality.appium.mobile.application.AqualityServices; import com.google.inject.Inject; -import constants.keysForContext.ScenarioContextKey; +import constants.keysforcontext.ScenarioContextKey; import framework.utilities.ScreenshotUtils; import framework.utilities.ScenarioContext; import io.cucumber.java.After; diff --git a/src/test/java/hooks/logout/LogoutHooks.java b/src/test/java/hooks/logout/LogoutHooks.java index 4a2e335..6524710 100644 --- a/src/test/java/hooks/logout/LogoutHooks.java +++ b/src/test/java/hooks/logout/LogoutHooks.java @@ -44,7 +44,7 @@ public void logout() { AqualityServices.getLogger().info("Test finished - logging out"); restartApp(); List listOfLibraries = context.get(ContextLibrariesKeys.LOG_OUT.getKey()); - if (listOfLibraries.size() == 0) { + if (listOfLibraries.isEmpty()) { throw new RuntimeException("There are not libraries for logout"); } for (String library : listOfLibraries) { diff --git a/src/test/java/runners/TestRunner.java b/src/test/java/runners/TestRunner.java index a9715d0..b1407ef 100644 --- a/src/test/java/runners/TestRunner.java +++ b/src/test/java/runners/TestRunner.java @@ -1,8 +1,8 @@ package runners; import aquality.appium.mobile.application.AqualityServices; -import framework.utilities.feedXMLUtil.GettingBookUtil; -import framework.utilities.feedXMLUtil.XMLUtil; +import framework.utilities.feedxmlutil.GettingBookUtil; +import framework.utilities.feedxmlutil.XMLUtil; import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions; import org.junit.BeforeClass; @@ -18,11 +18,13 @@ plugin = { "io.qameta.allure.cucumber5jvm.AllureCucumber5Jvm" }, - tags = "@settings" + tags = "@check" ) public class TestRunner { + private TestRunner() {} + @BeforeClass public static void setup() { AqualityServices.getLogger().info("Start getting books"); diff --git a/src/test/java/screens/AlertScreen.java b/src/test/java/screens/AlertScreen.java index e150d5b..61d6edd 100644 --- a/src/test/java/screens/AlertScreen.java +++ b/src/test/java/screens/AlertScreen.java @@ -26,8 +26,8 @@ public class AlertScreen extends Screen{ public AlertScreen() { super(LocatorUtils.getLocator( - new AndroidLocator(By.xpath("//android.widget.LinearLayout[contains(@resource-id, \"grant_dialog\")]")), - new IosLocator(By.xpath("//XCUIElementTypeAlert"))), "Alert screen"); + new AndroidLocator(By.xpath(UNIQUE_ELEMENT_LOCATOR_ANDROID)), + new IosLocator(By.xpath(UNIQUE_ELEMENT_LOCATOR_IOS))), "Alert screen"); } public void waitAndPerformAlertActionIfDisplayed(ActionButtonsForBooksAndAlertsKeys actionButtonNamesAlertKeys) { diff --git a/src/test/java/screens/BookDetailsScreen.java b/src/test/java/screens/BookDetailsScreen.java index 021d9a0..72249e0 100644 --- a/src/test/java/screens/BookDetailsScreen.java +++ b/src/test/java/screens/BookDetailsScreen.java @@ -74,10 +74,6 @@ public BookDetailsScreen() { } public CatalogBookModel getBookInfo() { - - System.out.println("title: " + lblBookTitle.getText()); - System.out.println("author: " + lblBookAuthor.getText()); - return new CatalogBookModel() .setTitle(lblBookTitle.getText()) .setAuthor(lblBookAuthor.getText()); @@ -94,7 +90,6 @@ public boolean isAuthorNameDisplayed(String authorName) { ILabel lblAuthor = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.xpath(String.format(AUTHOR_NAME_LOC_ANDROID, authorName))), new IosLocator(By.xpath(String.format(AUTHOR_NAME_LOC_IOS, authorName)))), "Author name label"); - System.out.println(lblAuthor.getText()); return lblAuthor.state().waitForDisplayed(); } diff --git a/src/test/java/screens/CatalogBooksScreen.java b/src/test/java/screens/CatalogBooksScreen.java index e0a4470..cf3a554 100644 --- a/src/test/java/screens/CatalogBooksScreen.java +++ b/src/test/java/screens/CatalogBooksScreen.java @@ -24,6 +24,8 @@ public class CatalogBooksScreen extends Screen { + private static final String AUDIOBOOK_LOCATOR_PART = ". Audiobook."; + private final ILabel lblNameOfFirstBook = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//androidx.recyclerview.widget.RecyclerView/android.widget.FrameLayout[1]/android.view.ViewGroup/android.widget.TextView[1]")), new IosLocator(By.xpath("//XCUIElementTypeCell[1]/XCUIElementTypeOther/XCUIElementTypeStaticText[1]"))), "Book name of the first book"); @@ -60,7 +62,7 @@ public boolean isBookDisplayed(BookType bookType, String bookName, ActionButtons String bookNameLocator = bookName; if(PlatformUtils.getPlatformName() == PlatformName.IOS && BookType.AUDIOBOOK == bookType) { - bookNameLocator = bookNameLocator + ". Audiobook."; + bookNameLocator = bookNameLocator + AUDIOBOOK_LOCATOR_PART; } ILabel lblBookName = getElementFactory().getLabel(LocatorUtils.getLocator( @@ -95,7 +97,7 @@ public boolean isNoResults() { public CatalogBookModel openBookAndGetBookInfo(BookType bookType, String bookName, ActionButtonsForBooksAndAlertsKeys actionButtonKey) { String bookNameForLocator = bookName; if (PlatformUtils.getPlatformName() == PlatformName.IOS && BookType.AUDIOBOOK == bookType) { - bookNameForLocator = bookNameForLocator + ". Audiobook."; + bookNameForLocator = bookNameForLocator + AUDIOBOOK_LOCATOR_PART; } String actionButtonString = actionButtonKey.getDefaultLocalizedValue(); @@ -139,13 +141,13 @@ private List getBooksName() { public CatalogBookModel clickActionButtonAndGetBookInfo(BookType bookType, String bookName, ActionButtonsForBooksAndAlertsKeys actionButtonKey) { String bookNameForLocator = bookName; if (AqualityServices.getApplication().getPlatformName() == PlatformName.IOS && BookType.AUDIOBOOK == bookType) { - bookNameForLocator = bookNameForLocator + ". Audiobook."; + bookNameForLocator = bookNameForLocator + AUDIOBOOK_LOCATOR_PART; } String actionButtonString = actionButtonKey.getDefaultLocalizedValue(); IButton actionButton = getElementFactory().getButton(LocatorUtils.getLocator( new AndroidLocator(By.xpath(String.format(BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_ANDROID, bookNameForLocator, actionButtonString))), - new IosLocator(By.xpath(String.format(BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS, bookNameForLocator, actionButtonString)))), "Action button"); + new IosLocator(By.xpath(String.format(BUTTON_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS, bookNameForLocator, actionButtonString)))), "Action button to click"); ILabel lblAuthor = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.xpath(String.format(AUTHOR_BY_BOOK_NAME_AND_BUTTON_LOCATOR_ANDROID, bookNameForLocator, actionButtonString))), @@ -195,7 +197,7 @@ public CatalogBookModel clickActionButtonOnTheFirstBookAndGetBookInfo(BookType b String actionButtonString = actionButtonKey.getDefaultLocalizedValue(); IButton actionButton = getElementFactory().getButton(LocatorUtils.getLocator( new AndroidLocator(By.xpath(String.format(BUTTON_ON_THE_FIRST_BOOK_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_ANDROID, actionButtonString))), - new IosLocator(By.xpath(String.format(BUTTON_ON_THE_FIRST_BOOK_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS, actionButtonString)))), "Action button"); + new IosLocator(By.xpath(String.format(BUTTON_ON_THE_FIRST_BOOK_BY_BOOK_NAME_AND_BUTTON_NAME_LOC_IOS, actionButtonString)))), "Action button on the first book"); ILabel lblAuthor = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.xpath(String.format(AUTHOR_ON_THE_FIRST_BOOK_BY_BOOK_NAME_AND_BUTTON_LOC_ANDROID, actionButtonString))), new IosLocator(By.xpath(String.format(AUTHOR_ON_THE_FIRST_BOOK_BY_BOOK_NAME_AND_BUTTON_LOC_IOS, actionButtonString)))), "Author label"); @@ -216,15 +218,9 @@ public CatalogBookModel clickActionButtonOnTheFirstBookAndGetBookInfo(BookType b CatalogBookModel bookInfo = new CatalogBookModel(); - ActionProcessorUtils.doForIos(() -> { - bookInfo.setTitle(lblBookName.getAttribute(IosAttributes.NAME)) - .setAuthor(author); - }); + ActionProcessorUtils.doForIos(() -> bookInfo.setTitle(lblBookName.getAttribute(IosAttributes.NAME)).setAuthor(author)); - ActionProcessorUtils.doForAndroid(() -> { - bookInfo.setTitle(lblBookName.getText()) - .setAuthor(author); - }); + ActionProcessorUtils.doForAndroid(() -> bookInfo.setTitle(lblBookName.getText()).setAuthor(author)); actionButton.click(); if (actionButtonKey == ActionButtonsForBooksAndAlertsKeys.GET || actionButtonKey == ActionButtonsForBooksAndAlertsKeys.REMOVE diff --git a/src/test/java/screens/CatalogScreen.java b/src/test/java/screens/CatalogScreen.java index e6200a7..bad2026 100644 --- a/src/test/java/screens/CatalogScreen.java +++ b/src/test/java/screens/CatalogScreen.java @@ -20,6 +20,7 @@ import java.util.HashSet; import java.util.List; +import java.util.Random; import java.util.Set; import java.util.stream.Collectors; @@ -136,7 +137,7 @@ public boolean areCategoryNamesDisplayed() { new AndroidLocator(By.xpath(CATEGORY_LOCATOR_ANDROID)), new IosLocator(By.xpath(CATEGORY_LOCATOR_IOS)))).size() > COUNT_OF_CATEGORIES_TO_WAIT_FOR); List currentBooksNames = geListOfCategoriesNames(); - return currentBooksNames.size() > 0; + return !currentBooksNames.isEmpty(); } public boolean isMoreBtnPresent() { @@ -148,7 +149,8 @@ public boolean isMoreBtnPresent() { public String clickToMoreBtn() { List buttons = getMoreBtn(); - int randomNumber = 1 + (int) (Math.random() * buttons.size()); + Random random = new Random(); + int randomNumber = random.nextInt(buttons.size()) + 1; String sectionName = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.xpath(String.format(CURRENT_SECTION_LOCATOR_IN_CATALOG_ANDROID, randomNumber))), new IosLocator(By.xpath(String.format(CURRENT_SECTION_LOCATOR_IN_CATALOG_IOS, randomNumber)))), "Book section name").getText(); diff --git a/src/test/java/screens/SoftwareLicensesScreen.java b/src/test/java/screens/SoftwareLicensesScreen.java index 7cbcf75..f6deb14 100644 --- a/src/test/java/screens/SoftwareLicensesScreen.java +++ b/src/test/java/screens/SoftwareLicensesScreen.java @@ -9,8 +9,8 @@ import org.openqa.selenium.By; public class SoftwareLicensesScreen extends Screen { - private final String LINK_IOS = "//XCUIElementTypeLink[contains(@name, \"%s\")]"; - private final String LINK_ANDROID = "//android.widget.TextView[contains(@text, \"%s\")]"; + private static final String LINK_IOS = "//XCUIElementTypeLink[contains(@name, \"%s\")]"; + private static final String LINK_ANDROID = "//android.widget.TextView[contains(@text, \"%s\")]"; private final ILabel lblLicense = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//android.widget.TextView[@text=\"Palace License\"]")), diff --git a/src/test/java/screens/SubcategoryScreen.java b/src/test/java/screens/SubcategoryScreen.java index ff786a1..b3fe893 100644 --- a/src/test/java/screens/SubcategoryScreen.java +++ b/src/test/java/screens/SubcategoryScreen.java @@ -19,11 +19,11 @@ public class SubcategoryScreen extends Screen { private final ILabel lblFirstBookTitle = getElementFactory().getLabel(LocatorUtils.getLocator( - new AndroidLocator(By.xpath("//android.widget.TextView[contains(@resource-id, \"bookCellIdleTitle\")]")), - new IosLocator(By.xpath("//XCUIElementTypeCell//XCUIElementTypeStaticText[1]"))), "First book title label"); + new AndroidLocator(By.xpath(BOOK_NAME_LOCATOR_ANDROID)), + new IosLocator(By.xpath(BOOK_NAME_LOCATOR_IOS))), "First book title label"); private final ILabel lblFirstBookAuthor = getElementFactory().getLabel(LocatorUtils.getLocator( - new AndroidLocator(By.xpath("//android.widget.TextView[contains(@resource-id, \"bookCellIdleAuthor\")]")), - new IosLocator(By.xpath("//XCUIElementTypeCell//XCUIElementTypeStaticText[@name][2]"))), "First book author label"); + new AndroidLocator(By.xpath(AUTHOR_INFO_LOCATOR_ANDROID)), + new IosLocator(By.xpath(AUTHOR_INFO_LOCATOR_IOS))), "First book author label"); private final ILabel lblFirstBook = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//android.widget.ImageView[contains(@resource-id,\"bookCellIdleCover\")]")), new IosLocator(By.xpath("//XCUIElementTypeCell//XCUIElementTypeStaticText[1]"))), "First book label"); @@ -141,8 +141,4 @@ private List getValuesFromListOfLabels(By locator) { .map(IElement::getText) .collect(Collectors.toList()); } - - private List getElements(String xpath, ElementType label) { - return getElementFactory().findElements(By.xpath(xpath), label); - } } diff --git a/src/test/java/screens/UserAgreementScreen.java b/src/test/java/screens/UserAgreementScreen.java index bb16801..e51c425 100644 --- a/src/test/java/screens/UserAgreementScreen.java +++ b/src/test/java/screens/UserAgreementScreen.java @@ -9,7 +9,7 @@ import org.openqa.selenium.By; public class UserAgreementScreen extends Screen { - private final String LINK_IOS = "//XCUIElementTypeLink[contains(@name, \"%s\")]"; + private static final String LINK_IOS = "//XCUIElementTypeLink[contains(@name, \"%s\")]"; private final String LINK_ANDROID = "//android.widget.TextView[contains(@text, \"%s\")]"; private final ILabel lblAgreement = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//android.widget.TextView[contains(@text, \"License Agreement\")]")), diff --git a/src/test/java/screens/audiobook/AudioPlayerScreen.java b/src/test/java/screens/audiobook/AudioPlayerScreen.java index ad9b103..ae8ecaa 100644 --- a/src/test/java/screens/audiobook/AudioPlayerScreen.java +++ b/src/test/java/screens/audiobook/AudioPlayerScreen.java @@ -17,7 +17,6 @@ import org.openqa.selenium.By; import java.time.Duration; -import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -95,13 +94,6 @@ public AudioPlayerScreen() { sleepTimerScreen = new SleepTimerScreen(); } -// private static final Map speedNameIos = new HashMap() {{ -// put("2.0", "Two times normal speed. Fastest."); -// put("0.75", "Three quarters of normal speed. Slower."); -// put("1.25", "One and one quarter faster than normal speed."); -// put("1.5", "One and a half times faster than normal speed."); -// }}; - private static final Map speedNameIos = Stream.of( new String[]{"2.0", "Two times normal speed. Fastest."}, new String[]{"0.75", "Three quarters of normal speed. Slower."}, diff --git a/src/test/java/screens/audiobook/PlaybackSpeedScreen.java b/src/test/java/screens/audiobook/PlaybackSpeedScreen.java index 4aba4de..c1706cc 100644 --- a/src/test/java/screens/audiobook/PlaybackSpeedScreen.java +++ b/src/test/java/screens/audiobook/PlaybackSpeedScreen.java @@ -10,7 +10,6 @@ import models.IosLocator; import org.openqa.selenium.By; -import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -32,14 +31,6 @@ public PlaybackSpeedScreen() { new IosLocator(By.xpath("//XCUIElementTypeStaticText[@name=\"Playback Speed\"]"))), "Playback speed screen"); } -// private static Map speedNameIos = new HashMap() {{ -// put("2.0", "Two times normal speed. Fastest."); -// put("0.75", "Three quarters of normal speed. Slower."); -// put("1.25", "One and one quarter faster than normal speed."); -// put("1.5", "One and a half times faster than normal speed."); -// -// }}; - private static final Map speedNameIos = Stream.of( new String[]{"2.0", "Two times normal speed. Fastest."}, new String[]{"0.75", "Three quarters of normal speed. Slower."}, diff --git a/src/test/java/stepdefinitions/CredentialsSteps.java b/src/test/java/stepdefinitions/CredentialsSteps.java index e8ac7b8..94d059b 100644 --- a/src/test/java/stepdefinitions/CredentialsSteps.java +++ b/src/test/java/stepdefinitions/CredentialsSteps.java @@ -3,13 +3,13 @@ import aquality.appium.mobile.application.AqualityServices; import aquality.appium.mobile.application.PlatformName; import com.google.inject.Inject; -import constants.keysForContext.ScenarioContextKey; +import constants.keysforcontext.ScenarioContextKey; import enums.keysforcontext.ContextLibrariesKeys; import enums.localization.catalog.ActionButtonsForBooksAndAlertsKeys; import framework.configuration.Configuration; import framework.configuration.Credentials; import framework.utilities.ScenarioContext; -import framework.utilities.returningBooksUtil.APIUtil; +import framework.utilities.returningbooksutil.APIUtil; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import org.junit.Assert; diff --git a/src/test/java/stepdefinitions/GettingBooksStep.java b/src/test/java/stepdefinitions/GettingBooksStep.java index 0328ffe..5eba9af 100644 --- a/src/test/java/stepdefinitions/GettingBooksStep.java +++ b/src/test/java/stepdefinitions/GettingBooksStep.java @@ -10,11 +10,11 @@ import screens.menubar.MenuBar; import screens.menubar.MenuBarScreen; +import java.security.SecureRandom; import java.util.List; -import java.util.Random; public class GettingBooksStep { - private static final Random random = new Random(); + private static final SecureRandom random = new SecureRandom(); private static final CatalogScreen catalogScreen = new CatalogScreen(); private static final SearchScreen searchScreen = new SearchScreen(); private static final SortOptionsScreen sortOptionsScreen = new SortOptionsScreen(); diff --git a/src/test/java/stepdefinitions/SignInSteps.java b/src/test/java/stepdefinitions/SignInSteps.java index 8fb7ada..db2e413 100644 --- a/src/test/java/stepdefinitions/SignInSteps.java +++ b/src/test/java/stepdefinitions/SignInSteps.java @@ -3,12 +3,12 @@ import aquality.appium.mobile.application.AqualityServices; import aquality.appium.mobile.application.PlatformName; import com.google.inject.Inject; -import constants.keysForContext.ScenarioContextKey; +import constants.keysforcontext.ScenarioContextKey; import enums.localization.catalog.ActionButtonsForBooksAndAlertsKeys; import framework.configuration.Configuration; import framework.configuration.Credentials; import framework.utilities.ScenarioContext; -import framework.utilities.returningBooksUtil.APIUtil; +import framework.utilities.returningbooksutil.APIUtil; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import org.apache.commons.lang3.RandomStringUtils; diff --git a/src/test/java/stepdefinitions/XMLSteps.java b/src/test/java/stepdefinitions/XMLSteps.java index 6e497f6..5452197 100644 --- a/src/test/java/stepdefinitions/XMLSteps.java +++ b/src/test/java/stepdefinitions/XMLSteps.java @@ -3,7 +3,7 @@ import aquality.appium.mobile.application.AqualityServices; import com.google.inject.Inject; import framework.utilities.ScenarioContext; -import framework.utilities.feedXMLUtil.GettingBookUtil; +import framework.utilities.feedxmlutil.GettingBookUtil; import io.cucumber.java.en.When; import org.junit.Assert; import screens.MainToolBarScreen; From 6eabbd78260de173236ee0a43658ba3b6d379c45 Mon Sep 17 00:00:00 2001 From: AEkaterina Date: Tue, 24 Oct 2023 16:15:09 +0400 Subject: [PATCH 6/6] updated device list --- src/test/java/screens/CatalogScreen.java | 2 +- src/test/resources/devices.json | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/java/screens/CatalogScreen.java b/src/test/java/screens/CatalogScreen.java index bad2026..b3cf4e5 100644 --- a/src/test/java/screens/CatalogScreen.java +++ b/src/test/java/screens/CatalogScreen.java @@ -25,6 +25,7 @@ import java.util.stream.Collectors; public class CatalogScreen extends Screen { + private final Random random = new Random(); private final ILabel lblCatalog = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.xpath("//android.view.ViewGroup[contains(@resource-id, \"mainToolbar\")]/android.widget.TextView")), @@ -149,7 +150,6 @@ public boolean isMoreBtnPresent() { public String clickToMoreBtn() { List buttons = getMoreBtn(); - Random random = new Random(); int randomNumber = random.nextInt(buttons.size()) + 1; String sectionName = getElementFactory().getLabel(LocatorUtils.getLocator( new AndroidLocator(By.xpath(String.format(CURRENT_SECTION_LOCATOR_IN_CATALOG_ANDROID, randomNumber))), diff --git a/src/test/resources/devices.json b/src/test/resources/devices.json index 397f8ec..ea8eeba 100644 --- a/src/test/resources/devices.json +++ b/src/test/resources/devices.json @@ -11,6 +11,12 @@ "platformVersion": "16" } }, + "iPhone15ProMax_17": { + "capabilities": { + "deviceName": "iPhone 15 Pro Max", + "platformVersion": "17" + } + }, "iPhone12Mini_14": { "capabilities": { "deviceName": "iPhone 12 Mini",