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(); } }); }