diff --git a/.github/workflows/browserstack-accessibility.yml b/.github/workflows/browserstack-accessibility.yml new file mode 100644 index 0000000..7425362 --- /dev/null +++ b/.github/workflows/browserstack-accessibility.yml @@ -0,0 +1,24 @@ +name: BrowserStack Accessibility Tests (On-Prem) + +on: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout sdk branch + uses: actions/checkout@v4 + with: + ref: sdk + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '11' + cache: maven + + - name: Run Accessibility tests + run: mvn test -P scenario-onprem -B diff --git a/README.md b/README.md index 6d84572..084f399 100644 --- a/README.md +++ b/README.md @@ -67,18 +67,16 @@ This repository contains the following Cucumber Scenario tests: - [BrowserStack](#browserstack) --- -## Configuring the maximum parallel test threads for this repository +## Configuring the maximum parallel test threads for this repository[SDK] -For all the parallel run configuration profiles, tests will run with max parallels in your BrowserStack account, or you can configure the parallel test threads from the terminal +For all the parallel run configuration profiles, tests will run with max parallels in your BrowserStack account, or you can configure the parallel test threads from the browserstack.yml file - "-DthreadCount=xx" + parallelsPerPlatform |BrowserStack| onPrem | |--|--| | browserstack/conf/Run_Single_Test/single.testng.xml|testng.xml -browserstack/conf/Run_Parallel_Test/parallel.testng.xml | | -|browserstack/conf/Run_Local_Test/local.testng.xml| -|browserstack/conf/Run_Parallel_Test/parallel.testng.xml +browserstack/conf/Run_Parallel_Test/parallel.testng.xml | @@ -142,11 +140,8 @@ This infrastructure points to running the tests on your own machine using any br set BROWSERSTACK_ACCESS_KEY= ``` - Alternatively, you can also hardcode username and access_key objects in the respective json files: - - [single.conf.json](src/test/resources/browserstack/conf/Run_Single_Test/single.conf.json) file - - [parallel.conf.json](src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.conf.json) file - - [local.conf.json](src/test/resources/browserstack/conf/Run_Local_Test/local.conf.json) file - - [local.parallel.json](src/test/resources/browserstack/conf/Run_Local_Parallel/local.parallel.json) file + Alternatively, you can also hardcode username and access_key objects in the respective file: + - [browserstack.yml](browserstack.yml) file Note: @@ -158,7 +153,7 @@ Note: ### Run a specific test/entire test suite in parallel on a single BrowserStack browser -In this section, we will run the tests in parallel on a single browser on Browserstack. Refer to [single.conf.json](src/test/resources/browserstack/conf/Run_Single_Test/single.conf.json) file to change test capabilities for this configuration. +In this section, we will run the tests in parallel on a single browser on Browserstack. Refer to [browserstack.yml](browserstack.yml) file to change test capabilities for this configuration. - How to run the test? @@ -178,13 +173,13 @@ In this section, we will run the tests in parallel on a single browser on Browse - Note: By default, this execution would run maximum test threads based on the parallel quota on your BrowserStack Account. Thread count can be configured as below based on your requirements. ```sh - mvn test -P scenario-bs "-Dcucumber.filter.tags=@regresssion" "-DthreadCount=3" + mvn test -P scenario-bs "-Dcucumber.filter.tags=@regresssion" ``` ### Run the entire test suite in parallel on multiple BrowserStack browsers -In this section, we will run the tests in parallel on multiple browsers on Browserstack. Refer to the [parallel.conf.json](src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.conf.json) file to change test capabilities for this configuration. +In this section, we will run the tests in parallel on multiple browsers on Browserstack. Refer to the [browserstack.yml](browserstack.yml) file to change test capabilities for this configuration. - How to run the test? @@ -192,7 +187,7 @@ In this section, we will run the tests in parallel on multiple browsers on Brows Maven: ```sh - mvn test -P suite-cross-bs + mvn test -P scenario-bs ``` You can mention any scenario from the feature files using the `-Dcucumber.filter.tags`, tags defined at Feature level Eg. `@users` will run all the scenarios in the [Users Feature](src/test/resources/Features/Users.feature) file in parallel. Likewise `@regression` will run all the scenarios from all the Feature files in parallel across multiple browsers/devices. @@ -206,7 +201,7 @@ In this section, we will run the tests in parallel on multiple browsers on Brows git clone https://github.com/browserstack/browserstack-demo-app ``` - Please follow the README.md on the BrowserStack demo application repository to install and start the dev server on localhost. -- In this section, we will run a single test case to test the BrowserStack Demo app hosted on your local machine i.e. localhost. Refer to the [local.conf.json](src/test/resources/browserstack/conf/Run_Local_Test/local.conf.json) file to change test capabilities for this configuration. +- In this section, we will run a single test case to test the BrowserStack Demo app hosted on your local machine i.e. localhost. Refer to the [browserstack.yml](browserstack.yml) file to change test capabilities for this configuration. - Note: You may need to provide additional BrowserStackLocal arguments to successfully connect your localhost environment with BrowserStack infrastructure. (e.g if you are behind firewalls, proxy or VPN). - Further details for successfully creating a BrowserStackLocal connection can be found here: @@ -234,7 +229,7 @@ You can mention any scenario from the feature files using the `-Dcucumber.filter ### [Web application hosted on internal environment] Run the entire test suite in parallel on multiple BrowserStack browser using BrowserStackLocal -In this section, we will run the test cases to test the internally hosted website in parallel on multiple browsers/devices on Browserstack. Refer to the [local.parallel.json](src/test/resources/browserstack/conf/Run_Local_Parallel/local.parallel.json) file to change test capabilities for this configuration. +In this section, we will run the test cases to test the internally hosted website in parallel on multiple browsers/devices on Browserstack. Refer to the [browserstack.yml](browserstack.yml) file to change test capabilities for this configuration. - How to run the test? @@ -242,7 +237,7 @@ In this section, we will run the test cases to test the internally hosted websit Maven: ```sh - mvn test -P local-cross-bs + mvn test -P local-bs ``` - Output @@ -251,7 +246,7 @@ In this section, we will run the test cases to test the internally hosted websit - Note: By default, this execution would run maximum test threads based on the parallel quota on your BrowserStack Account. Thread count can be configured as below based on your requirements. ```sh - mvn test -P local-cross-bs "-Dcucumber.filter.tags=@e2e" "-DthreadCount=3" + mvn test -P local-bs "-Dcucumber.filter.tags=@e2e" ``` diff --git a/browserstack.yml b/browserstack.yml new file mode 100644 index 0000000..4dced8c --- /dev/null +++ b/browserstack.yml @@ -0,0 +1,107 @@ +# ============================= +# Set BrowserStack Credentials +# ============================= +# Add your BrowserStack userName and accessKey here or set BROWSERSTACK_USERNAME and +# BROWSERSTACK_ACCESS_KEY as env variables +userName: YOUR_USERNAME +accessKey: YOUR_ACCESS_KEY + +# ====================== +# BrowserStack Reporting +# ====================== +# The following capabilities are used to set up reporting on BrowserStack: +# Set 'projectName' to the name of your project. Example, Marketing Website +projectName: BrowserStack Cucumber TestNG # Automate - Map SDK +# Set `buildName` as the name of the job / testsuite being run +buildName: browserstack build +# `buildIdentifier` is a unique id to differentiate every execution that gets appended to +# buildName. Choose your buildIdentifier format from the available expressions: +# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution +# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30 +# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests +buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression} +buildTag: "regresson" +selfHeal: true +# ======================================= +# Platforms (Browsers / Devices to test) +# ======================================= +# Platforms object contains all the browser / device combinations you want to test on. +# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate) +platforms: + - os: OS X + osVersion: Big Sur + browserName: Chrome + browserVersion: 131.0 + - os: Windows + osVersion: 10 + browserName: Edge + browserVersion: 131.0 + - deviceName: Samsung Galaxy S2* + browserName: chrome # Try 'samsung' for Samsung browser + osVersion: "[12131415]" + - deviceName: iPhone 1* + browserName: safari + osVersion: "[15161718]" +# ======================= +# Parallels per Platform +# ======================= +# The number of parallel threads to be used for each platform set. +# BrowserStack's SDK runner will select the best strategy based on the configured value +# +# Example 1 - If you have configured 3 platforms and set `parallelsPerPlatform` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack +# +# Example 2 - If you have configured 1 platform and set `parallelsPerPlatform` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack +parallelsPerPlatform: 2 +framework: cucumber-testng #junit,testng,java,cucumber-testng,serenity,cucumber-junit +source: cucumber-testng:intellij:v1.1.2 +staticWebDriver: true +browserstackAutomation: true +# ========================================== +# BrowserStack Local +# (For localhost, staging/private websites) +# ========================================== +# Set browserStackLocal to true if your website under test is not accessible publicly over the internet +# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction +browserstackLocal: false # (Default false) + +# Options to be passed to BrowserStack local in-case of advanced configurations +#browserStackLocalOptions: + # localIdentifier: # (Default: null) Needed if you need to run multiple instances of local. + # forceLocal: false # (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel. + # Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections + +# =================== +# Debugging features +# =================== +debug: true # # Set to true if you need screenshots for every selenium command ran +networkLogs: true # Set to true to enable HAR logs capturing +consoleLogs: errors # Remote browser's console debug levels to be printed (Default: errors) +# Available options are `disable`, `errors`, `warnings`, `info`, `verbose` (Default: errors) + +# Test Observability is an intelligent test reporting & debugging product. It collects data using the SDK. Read more about what data is collected at https://www.browserstack.com/docs/test-observability/references/terms-and-conditions +# Visit observability.browserstack.com to see your test reports and insights. To disable test observability, specify `testObservability: false` in the key below. +testObservability: true +accessibility: true +accessibilityOptions: + wcagVersion: wcag21aaa # Default: wcag21aa + includeIssueType: + bestPractice: true # Default: false + needsReview: true # Default: true + experimental: true # Default: true + #includeTagsInTestingScope: [ '@users' ] # Tags for test cases to include + #excludeTagsInTestingScope: [ 'old', 'deprecated' ] # Tags for test cases to exclude + +performance: assert +percy: true +percyCaptureMode: auto +#logLevel: debug +browserProfiling: true + +testOrchestrationOptions: + retryTestsOnFailure: + enabled: true + maxRetries: 2 + runSmartSelection: + enabled: true + mode: relevantFirst + runPreviouslyFailedFirst: true diff --git a/check-quality-gate.sh b/check-quality-gate.sh new file mode 100644 index 0000000..553cc83 --- /dev/null +++ b/check-quality-gate.sh @@ -0,0 +1,99 @@ +#!/bin/bash +set -e # Exit immediately if a command exits with a non-zero status. + +# --- Configuration --- +# These values are read from Azure DevOps Pipeline variables. +project_name="BrowserStack Cucumber TestNG" +build_name="$BROWSERSTACK_BUILD_NAME" +username="$BROWSERSTACK_USERNAME" +access_key="$BROWSERSTACK_ACCESS_KEY" + +# --- Script Parameters --- +max_attempts=20 # Max number of times to poll the API (20 attempts * 30s = 10 minutes) +build_tags="" # Optional: Set build tags if needed + +# --- Script Functions --- + +# Function to URL-encode a string +sanitize_name() { + local name="$1" + echo "$name" | sed 's/ /%20/g' +} + +# Function to get the UUID of the latest build +get_latest_build_uuid() { + local sanitized_project_name + local sanitized_build_name + sanitized_project_name=$(sanitize_name "$project_name") + sanitized_build_name=$(sanitize_name "$build_name") + + # API call relies on project and build name, which is most reliable in CI. + local url="https://api-automation.browserstack.com/ext/v1/builds/latest?project_name=$sanitized_project_name&build_name=$sanitized_build_name" + + # Add optional build tags to the query if they are set + if [ -n "$build_tags" ]; then + local sanitized_build_tags + sanitized_build_tags=$(sanitize_name "$build_tags") + url="$url&build_tags=$sanitized_build_tags" + fi + + echo "Querying for build..." >&2 + + # Fetch the JSON response. This goes to standard output. + curl -s --retry 3 --connect-timeout 10 -u "$username:$access_key" "$url" +} + +# Function to get the status of the Quality Gate for a given build UUID +get_quality_gate_result() { + local build_uuid="$1" + local qg_url="https://api-automation.browserstack.com/ext/v1/quality-gates/$build_uuid" + + # Fetch the JSON response. This goes to standard output. + curl -s -H --retry 3 --connect-timeout 10 -u "$username:$access_key" "$qg_url" +} + +# --- Main Script Execution --- + +echo "--- BrowserStack Quality Gate Check ---" >&2 + +build_info_json=$(get_latest_build_uuid) +build_uuid=$(echo "$build_info_json" | jq -r '.build_id') + +if [ "$build_uuid" == "null" ] || [ -z "$build_uuid" ]; then + echo "Error: Failed to retrieve a valid Build UUID from the API." >&2 + echo "API Response: $build_info_json" >&2 + exit 1 +fi + +echo "Successfully found Build UUID: $build_uuid" >&2 +echo "Waiting 20 seconds before polling Quality Gate..." >&2 +sleep 20 + +# Polling loop +attempt=0 +while [[ $attempt -lt $max_attempts ]]; do + attempt=$((attempt + 1)) + echo "Polling attempt #$attempt..." >&2 + + quality_gate_json=$(get_quality_gate_result "$build_uuid") + status=$(echo "$quality_gate_json" | jq -r '.status') + + echo "Current status is: '$status'" >&2 + + if [ "$status" != "running" ]; then + echo "Final Quality Gate Result: $quality_gate_json" + + if [ "$status" == "passed" ]; then + echo "✅ Quality Gate Passed" >&2 + exit 0 + else + echo "❌ Quality Gate Failed" >&2 + exit 1 + fi + fi + + sleep 30 +done + +echo "Error: Timed out waiting for Quality Gate results after $max_attempts attempts." >&2 +exit 1 diff --git a/pom.xml b/pom.xml index edddd83..c69281d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,4 @@ - - + 4.0.0 org.BrowserStack @@ -9,14 +6,13 @@ 1.0-SNAPSHOT - 7.2.2 + 7.3.0 UTF-8 - 1.8 - 1.8 + 11 + 11 + 3.0.0-M5 7.4.0 3.0.0-M5 - - https://bstackdemo.com/ @@ -47,17 +43,18 @@ org.seleniumhq.selenium selenium-java - 4.1.0 + 4.22.0 io.github.bonigarcia webdrivermanager - 5.0.3 + LATEST + test commons-io commons-io - 2.11.0 + LATEST tech.grasshopper @@ -79,6 +76,11 @@ okhttp 5.0.0-alpha.10 + + com.browserstack + browserstack-java-sdk + LATEST + @@ -90,13 +92,25 @@ ${suiteXmlFile} - + -javaagent:"${com.browserstack:browserstack-java-sdk:jar}" ${browser-type} ${Application_url} + + maven-dependency-plugin + 3.3.0 + + + getClasspathFilenames + + properties + + + + @@ -104,7 +118,7 @@ scenario-onprem - chrome + firefox testng.xml @@ -115,27 +129,12 @@ src/test/resources/browserstack/conf/Run_Single_Test/single.testng.xml - - suite-cross-bs - - remote - src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.testng.xml - - local-bs remote http://localhost:3000/ - src/test/resources/browserstack/conf/Run_Local_Test/local.testng.xml - - - - local-cross-bs - - remote - http://localhost:3000/ - src/test/resources/browserstack/conf/Run_Local_Parallel/localParallel.testng.xml + src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.testng.xml diff --git a/src/test/java/Runner/CucumberTest.java b/src/test/java/Runner/CucumberTest.java index fa7602b..4efc161 100644 --- a/src/test/java/Runner/CucumberTest.java +++ b/src/test/java/Runner/CucumberTest.java @@ -28,9 +28,10 @@ import java.util.Map; @CucumberOptions(features = "src/test/resources/Features", glue = {"StepDefinitions"}, - plugin = {"pretty", - "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"}, - monochrome = true + plugin = {"pretty","json:target/cucumber-reports/Cucumber.json" + //"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:" + }, + monochrome = true,publish = true ) @Listeners(BrowserstackTestStatusListener.class) public class CucumberTest { @@ -98,8 +99,15 @@ public void setUpHooks(String config_file, String environment) throws Exception new URL("https://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities)); }else throw new AssertionError("Invalid input for browser"); - if(!capabilities.toString().contains("realMobile")) + Map deviceInfo = new HashMap<>(); + JavascriptExecutor jse = (JavascriptExecutor) getDriver(); + try{ + deviceInfo = (Map) jse.executeScript("mobile:deviceInfo"); + }catch(Exception e){ + } + if(deviceInfo.isEmpty()) getDriver().manage().window().maximize(); + } public static synchronized WebDriver getDriver(){ @@ -109,8 +117,8 @@ public static synchronized WebDriver getDriver(){ @Test(dataProvider = "scenarios") public void scenario(PickleWrapper pickleWrapper, FeatureWrapper featureWrapper) throws MalformedURLException { JavascriptExecutor jse = (JavascriptExecutor)getDriver(); - if(System.getProperty("browser-type").equalsIgnoreCase("remote")) - jse.executeScript("browserstack_executor: {\"action\": \"setSessionName\", \"arguments\": {\"name\":\" "+ pickleWrapper.getPickle().getName() +" \" }}"); + //if(System.getProperty("browser-type").equalsIgnoreCase("remote")) + //jse.executeScript("browserstack_executor: {\"action\": \"setSessionName\", \"arguments\": {\"name\":\" "+ pickleWrapper.getPickle().getName() +" \" }}"); testNGCucumberRunner.runScenario(pickleWrapper.getPickle()); } @DataProvider(parallel = true) @@ -120,7 +128,8 @@ public Object[][] scenarios(){ @AfterClass(alwaysRun = true) public void tearDownClass() { - testNGCucumberRunner.finish(); + //testNGCucumberRunner.finish(); //Conflict with the SDK Runner.CucumberTest.tearDownClass + // NoSuchMethod org.yaml.snakeyaml.constructor.Constructor. } @AfterSuite public void shutLocal() throws Exception { diff --git a/src/test/java/StepDefinitions/ApplicationHooks.java b/src/test/java/StepDefinitions/ApplicationHooks.java index 153b056..99f5eb1 100644 --- a/src/test/java/StepDefinitions/ApplicationHooks.java +++ b/src/test/java/StepDefinitions/ApplicationHooks.java @@ -17,12 +17,4 @@ public void screenshot(Scenario sc){ sc.attach(sourcePath,"image/png",screenshotName); } - private void markTestStatus(String status, String reason, WebDriver driver) { - try { - JavascriptExecutor jse = (JavascriptExecutor) driver; - jse.executeScript("browserstack_executor: {\"action\": \"setSessionStatus\", \"arguments\": {\"status\": \"" + status + "\", \"reason\": \"" + reason + "\"}}"); - } catch (Exception e) { - System.out.print("Error executing javascript" + e); - } - } } diff --git a/src/test/java/StepDefinitions/E2ESteps.java b/src/test/java/StepDefinitions/E2ESteps.java index 6295f58..9a84208 100644 --- a/src/test/java/StepDefinitions/E2ESteps.java +++ b/src/test/java/StepDefinitions/E2ESteps.java @@ -12,7 +12,11 @@ import io.cucumber.java.en.When; import org.openqa.selenium.JavascriptExecutor; import org.testng.Assert; +import org.yaml.snakeyaml.Yaml; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -36,7 +40,7 @@ public void getScenario(Scenario scenario){ this.sc = scenario; } @Given("User is on home page") - public void user_is_on_home_page() { + public void user_is_on_home_page() throws FileNotFoundException { JavascriptExecutor jse = (JavascriptExecutor) hooks.driver; Map deviceInfo = new HashMap<>(); try{ @@ -48,6 +52,14 @@ public void user_is_on_home_page() { hooks.driver.get(System.getProperties().getProperty("Application_url").replaceAll("localhost","bs-local.com")); else hooks.driver.get(System.getProperties().getProperty("Application_url")); + Yaml yaml = new Yaml(); + InputStream inputStream = new FileInputStream("browserstack.yml"); + HashMap yamlMap = yaml.load(inputStream); + if(yamlMap.get("browserstackAutomation").toString().equalsIgnoreCase("true")) { + jse.executeScript("browserstack_executor: {\"action\":\"lighthouseAudit\",\"arguments\":{\"url\":\"" + hooks.driver.getCurrentUrl() + "\",\"executorOutput\":\"json\"}}"); + + jse.executeScript("browserstack_executor: {\"action\":\"lighthouseAudit\",\"arguments\":{\"url\":\"" + hooks.driver.getCurrentUrl() + "\",\"assertResult\":{\"categories\":{\"performance\":40,\"best-practices\":50},\"metrics\":{\"first-contentful-paint\":{\"moreThan\":50,\"metricUnit\":\"score\"},\"largest-contentful-paint\":{\"lessThan\":4000,\"metricUnit\":\"numeric\"},\"total-blocking-time\":{\"lessThan\":600,\"metricUnit\":\"numeric\"},\"cumulative-layout-shift\":{\"moreThan\":50,\"metricUnit\":\"score\"}}}}}"); + } } @When("User clicks on sign in link") public void user_clicks_on_sign_in_link() { diff --git a/src/test/java/StepDefinitions/UsersSteps.java b/src/test/java/StepDefinitions/UsersSteps.java index 234ddbf..55e1dd3 100644 --- a/src/test/java/StepDefinitions/UsersSteps.java +++ b/src/test/java/StepDefinitions/UsersSteps.java @@ -8,8 +8,14 @@ import io.cucumber.java.en.Then; import io.cucumber.java.en.When; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Map; + +import org.testng.Assert; + +import com.browserstack.accessibility.AccessibilityUtils; public class UsersSteps { @@ -68,6 +74,43 @@ public void gets_your_account_has_been_locked(String user) throws InterruptedExc }else throw new AssertionError("Locked user "+user+" logged in!"); + // Accessibility assertion using BrowserStack Accessibility results summary + // Documentation reference: + // https://www.browserstack.com/docs/accessibility/automated-tests/add-accessibility-assertions + Map summary = AccessibilityUtils.getResultsSummary(hooks.driver); + + // Debug logging to understand NPE / null values + System.out.println("Accessibility summary: " + summary); + sc.log("Accessibility summary: " + String.valueOf(summary)); + + if (summary == null) { + sc.log("Accessibility summary is null, skipping accessibility assertions."); + return; + } + + Object severityMapObj = summary.get("issueCountBySeverity"); + if (!(severityMapObj instanceof Map)) { + sc.log("issueCountBySeverity is missing or not a Map in accessibility summary, skipping assertions."); + return; + } + + Map severityMap = (Map) severityMapObj; + Object criticalObj = severityMap.get("critical"); + sc.log("Critical issue count (raw): " + String.valueOf(criticalObj)); + + if (criticalObj == null) { + sc.log("Critical issue count is null in accessibility summary, skipping assertions."); + return; + } + + // Fetch and log detailed accessibility results as well + ArrayList> results = AccessibilityUtils.getResults(hooks.driver); + System.out.println("Accessibility detailed results: " + results); + sc.log("Accessibility detailed results: " + String.valueOf(results)); + + int criticalIssueCount = Integer.parseInt(String.valueOf(criticalObj)); + Assert.assertTrue(criticalIssueCount < 1, "Critical issue count breached the threshold!"); + } } diff --git a/src/test/java/com/qa/util/BrowserstackTestStatusListener.java b/src/test/java/com/qa/util/BrowserstackTestStatusListener.java index 77ed674..194ac8b 100644 --- a/src/test/java/com/qa/util/BrowserstackTestStatusListener.java +++ b/src/test/java/com/qa/util/BrowserstackTestStatusListener.java @@ -21,7 +21,7 @@ private void markTestStatus(String status, String reason, WebDriver driver) { public void onTestSuccess(ITestResult result) { Object currentClass = result.getInstance(); WebDriver driver = ((CucumberTest) currentClass).getDriver(); - markTestStatus("passed", "", driver); + //markTestStatus("passed", "", driver); driver.quit(); } @@ -31,7 +31,7 @@ public void onTestFailure(ITestResult result) { WebDriver driver = ((CucumberTest) currentClass).getDriver(); String message = result.getThrowable().getMessage(); String reason = (message != null && message.length() > 254) ? message.substring(0, 254) : message; - markTestStatus("failed", reason.replaceAll("[^a-zA-Z0-9._-]", " "), driver); + //markTestStatus("failed", reason.replaceAll("[^a-zA-Z0-9._-]", " "), driver); driver.quit(); } diff --git a/src/test/resources/Features/E2E.feature b/src/test/resources/Features/E2E.feature index 52d509c..90055d7 100644 --- a/src/test/resources/Features/E2E.feature +++ b/src/test/resources/Features/E2E.feature @@ -3,7 +3,7 @@ #Description: Demonstrate Cucumber Java framework with BS Automate product @e2e @regression Feature: E2E Flow - Scenario Outline: Signed in User makes a Purchase for a product with Price and Vendor filters + Scenario Outline: TC-3294 Signed in User makes a Purchase for a product with Price and Vendor filters Given User is on home page When User clicks on sign in link And User enters and and clicks on sign in @@ -16,4 +16,4 @@ Feature: E2E Flow Then User can see the order id for the product Examples: |username|password|first|last|address|state|postal| - |"demouser"|"testingisfun99"|"first"|"last"|"test"|"test state"|1234| \ No newline at end of file + |"demouser"|"testingisfun99"|"first"|"last"|"test"|"test state"|1234| diff --git a/src/test/resources/Features/Users.feature b/src/test/resources/Features/Users.feature index dc3aec0..22b3911 100644 --- a/src/test/resources/Features/Users.feature +++ b/src/test/resources/Features/Users.feature @@ -8,7 +8,7 @@ Feature: Different Users use cases in BStackDemo When User clicks on sign in link @noimage @fail - Scenario Outline: Login as User with no image loaded + Scenario Outline: TC-5883 Login as User with no image loaded When User enters and and clicks on sign in And is signed in to the App Then Product images are not loaded for the @@ -17,7 +17,7 @@ Feature: Different Users use cases in BStackDemo |"image_not_loading_user"|"testingisfun99"| @orders - Scenario Outline: Login as existing user to verify orders + Scenario Outline: TC-5884 Login as existing user to verify orders When User enters and and clicks on sign in And is signed in to the App And User clicks on Orders @@ -27,7 +27,7 @@ Feature: Different Users use cases in BStackDemo |"existing_orders_user"|"testingisfun99"| @locked - Scenario Outline: Login as a locked User + Scenario Outline: TC-5885 Login as a locked User When User enters and and clicks on sign in Then gets Your account has been locked. Examples: diff --git a/src/test/resources/browserstack/conf/Run_Local_Parallel/local.parallel.json b/src/test/resources/browserstack/conf/Run_Local_Parallel/local.parallel.json deleted file mode 100644 index 801495b..0000000 --- a/src/test/resources/browserstack/conf/Run_Local_Parallel/local.parallel.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "server": "hub-cloud.browserstack.com", - "user": "", - "key": "", - - "capabilities": { - "projectName": "Local BDD", - "buildName": "BDD-Local-Parallel-7", - "sessionName": "BS Suite", - "local": "true", - "debug": "true", - "networkLogs": "true", - "consoleLogs": "errors" - }, - - "environments": { - "env1": { - "browser": "Safari", - "browser_version": "15.3", - "envOptions": { - "os": "OS X", - "osVersion": "Monterey" - } - }, - "env2":{ - "browser": "Edge", - "browser_version": "latest", - "envOptions": { - "os": "Windows", - "osVersion": "11" - } - },"env3":{ - "envOptions": { - "osVersion": "15", - "deviceName": "iPhone 13 Pro Max", - "realMobile": "true" - } - }, - "env4":{ - "envOptions": { - "osVersion": "12.0", - "browserName": "samsung", - "deviceName": "Samsung Galaxy S22 Ultra", - "realMobile": "true" - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/browserstack/conf/Run_Local_Parallel/localParallel.testng.xml b/src/test/resources/browserstack/conf/Run_Local_Parallel/localParallel.testng.xml deleted file mode 100644 index fcb49a1..0000000 --- a/src/test/resources/browserstack/conf/Run_Local_Parallel/localParallel.testng.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/browserstack/conf/Run_Local_Test/local.conf.json b/src/test/resources/browserstack/conf/Run_Local_Test/local.conf.json deleted file mode 100644 index 34f464a..0000000 --- a/src/test/resources/browserstack/conf/Run_Local_Test/local.conf.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "server": "hub-cloud.browserstack.com", - "user": "", - "key": "", - - "capabilities": { - "projectName": "Local BDD", - "buildName": "Local_BS_BDD_2", - "sessionName": "Local_Test", - "debug": "true", - "networkLogs": "true", - "local": true , - "consoleLogs":"errors" - }, - - "environments": { - "env": { - "browserName": "Chrome", - "browserVersion": "latest", - "envOptions": { - "os": "Windows", - "osVersion": "11" - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/browserstack/conf/Run_Local_Test/local.testng.xml b/src/test/resources/browserstack/conf/Run_Local_Test/local.testng.xml deleted file mode 100644 index 4d85002..0000000 --- a/src/test/resources/browserstack/conf/Run_Local_Test/local.testng.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.conf.json b/src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.conf.json index a1fc52e..ae18182 100644 --- a/src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.conf.json +++ b/src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.conf.json @@ -9,39 +9,24 @@ "sessionName": "BS Suite", "debug": "true", "networkLogs": "true", - "seleniumVersion": "4.0.0", "consoleLogs": "errors" }, "environments": { "env1": { - "browser": "Edge", - "browser_version": "latest", - "envOptions": { - "os": "Windows", - "osVersion": "11" - } - }, - "env2":{ - "browser": "Safari", - "browser_version": "15.3", - "envOptions": { - "os": "OS X", - "osVersion": "Monterey" - } - },"env3":{ + "browser": "Edge", + "browser_version": "latest", "envOptions": { - "osVersion": "15", - "deviceName": "iPhone 13 Pro Max", - "realMobile": "true" + "os": "Windows", + "osVersion": "11" } }, - "env4":{ + "env2":{ + "browser": "Safari", + "browser_version": "15.3", "envOptions": { - "osVersion": "12.0", - "browserName": "chrome", - "deviceName": "Samsung Galaxy S22 Ultra", - "realMobile": "true" + "os": "OS X", + "osVersion": "Monterey" } } } diff --git a/src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.testng.xml b/src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.testng.xml index 2931e53..28058f2 100644 --- a/src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.testng.xml +++ b/src/test/resources/browserstack/conf/Run_Parallel_Test/parallel.testng.xml @@ -1,6 +1,6 @@ - + @@ -11,22 +11,4 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/resources/browserstack/conf/Run_Single_Test/single.conf.json b/src/test/resources/browserstack/conf/Run_Single_Test/single.conf.json index 21be2da..590f319 100644 --- a/src/test/resources/browserstack/conf/Run_Single_Test/single.conf.json +++ b/src/test/resources/browserstack/conf/Run_Single_Test/single.conf.json @@ -9,7 +9,6 @@ "sessionName": "BS Suite", "debug": "true", "networkLogs": "true", - "seleniumVersion": "4.0.0", "consoleLogs": "errors" },