Skip to content

[pull] master from browserstack:master #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fba9253
simple sdk sample
mattonem Nov 24, 2022
51f8061
clean up
mattonem Nov 30, 2022
7184e75
running local tests correctly for ios
mattonem Dec 1, 2022
cb4943c
w3c upgrade
mattonem Dec 1, 2022
0fafad0
typo
mattonem Dec 1, 2022
6a3249e
upgrade appium and selenium versions
mattonem Dec 1, 2022
88194a2
fixing selenium 4 deps
mattonem Dec 5, 2022
0a69fdf
renaming packages
mattonem Dec 5, 2022
17ff189
newlines
mattonem Dec 6, 2022
1ccea6c
end of line
mattonem Dec 6, 2022
a37646b
end of lines
mattonem Dec 6, 2022
19a7e1d
end of line again
mattonem Dec 6, 2022
071b33a
readme and MutableCapabilities
mattonem Dec 20, 2022
155510d
update readme
mattonem Dec 20, 2022
0f7492b
Update android/testng-examples/browserstack.yml
mattonem Jan 4, 2023
20b970f
Update ios/testng-examples/browserstack.yml
mattonem Jan 4, 2023
ae71996
Merge pull request #24 from mattonem/simple-sdk
avinash-bharti Jan 4, 2023
9f9207e
update: readme and config updation
kamal-kaur04 Jan 4, 2023
3a17b37
update: sample Apps for local test working with localIdentifier
kamal-kaur04 Jan 9, 2023
a4c3d3a
chore: comment down localOptions ios directory
kamal-kaur04 Jan 9, 2023
196b58f
chore: modify source key and project as consistent with AA
kamal-kaur04 Jan 10, 2023
f9ceadf
update: project name aligned with sdk flow for AUT
kamal-kaur04 Jan 12, 2023
6567a1f
Merge pull request #25 from kamal-kaur04/readme-and-command-changes
kamal-kaur04 Jan 12, 2023
64e8dbd
run sample test by default
kamal-kaur04 Apr 18, 2023
0538261
Merge pull request #26 from kamal-kaur04/run-sample-test-by-default
kamal-kaur04 Apr 18, 2023
78e0a76
update: appium driver to android driver
07souravkunda Aug 11, 2023
430f81c
Merge pull request #29 from 07souravkunda/update_appium_android_driver
karanshah-browserstack Aug 11, 2023
cd9fb46
Fix Rotatable issue
karanshah-browserstack Aug 24, 2023
0777cd1
Merge branch 'sdk' of https://github.com/browserstack/testng-appium-a…
karanshah-browserstack Aug 24, 2023
7687a6c
Fix Rotatable Issue
karanshah-browserstack Aug 24, 2023
5da67f3
fix: version bump selenium-java 4.13.0
kamal-kaur04 Oct 12, 2023
a92bcea
fix: version bump selenium-java 4.9.1
kamal-kaur04 Oct 12, 2023
2f71c1d
fix: version bump selenium-java 4.13.0
kamal-kaur04 Oct 12, 2023
4ddbcf2
Merge pull request #31 from kamal-kaur04/bump-selenium-version
karanshah-browserstack Oct 12, 2023
6ffa3bd
Update pom.xml
sriteja777 Apr 5, 2024
9586aa8
Update pom.xml
sriteja777 Apr 5, 2024
92409d1
Merge pull request #32 from browserstack/set_compatible_versions
karanshah-browserstack Apr 8, 2024
3cb2e95
Merge branch 'sdk' of https://github.com/browserstack/testng-appium-a…
Jun 19, 2024
8c3a218
Fixed linting issue
Jul 1, 2024
8956a14
Merge pull request #33 from browserstack/merge_sdk_to_master
yashdsaraf Jul 5, 2024
cd9d761
Change device name from iPhone XS (14) to iPhone 15 Plus (17)
sriteja777 Nov 18, 2024
10d1b02
empty commit to run tests
sriteja777 Nov 20, 2024
2092c7d
Merge pull request #35 from browserstack/update_device
karanshah-browserstack Nov 21, 2024
810851a
added step for new version of app
rahulpsq Dec 17, 2024
1bcd892
changed apk name
rahulpsq Dec 17, 2024
594796a
Merge pull request #36 from browserstack/sample_modification_appa11y
kamal-kaur04 Dec 18, 2024
b6b5da5
Add Gradle support for TestNG and Appium
rhisav-25 Mar 25, 2025
0790f6c
Resolving comments and making consistent
rhisav-25 Apr 2, 2025
82a29e3
Merge pull request #41 from rhisav-25/gradle-support-testng-appium
rajpatta Apr 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/maven-workflow-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ jobs:
cd android/testng-examples
mvn compile
mvn test -P sample-local-test -D"browserstack.app"="./LocalSample.apk"
- name: Run Gradle sample-test for testng Android
run: |
cd android/testng-examples
gradle clean sampleTest
- name: Run Gradle sampleLocalTest for testng Android
run: |
cd android/testng-examples
gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.apk"
- name: Run mvn test for testng ios
run: |
cd ios/testng-examples
Expand All @@ -82,6 +90,14 @@ jobs:
cd ios/testng-examples
mvn compile
mvn test -P sample-local-test -D"browserstack.app"="./LocalSample.ipa"
- name: Run Gradle sample-test for testng ios
run: |
cd ios/testng-examples
gradle clean sampleTest
- name: Run Gradle sampleLocalTest for testng ios
run: |
cd ios/testng-examples
gradle clean sample-local-test -D"browserstack.app"="./LocalSample.ipa"
- if: always()
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
id: status-check-completed
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ target/
local.log
.idea
*.iml
**/logs/*
.DS_Store
build
gradle
.gradle
gradlew*
43 changes: 32 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# testng-appium-app-browserstack

This repository demonstrates how to run Appium tests in [TestNG](http://testng.org) on BrowserStack App Automate.
This repository demonstrates how to run Appium tests in [TestNG](http://testng.org) on BrowserStack App Automate using BrowserStack SDK.

![BrowserStack Logo](https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-header.png?1469004780)

Expand All @@ -14,10 +14,14 @@ This repository demonstrates how to run Appium tests in [TestNG](http://testng.o
- For Windows, download latest java version from [here](https://java.com/en/download/) and run the installer executable
- For Mac and Linux, run `java -version` to see what java version is pre-installed. If you want a different version download from [here](https://java.com/en/download/)

2. Maven
2. Maven (Only required if using Maven as the build tool)
- If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi)
- For installation, follow the instructions [here](https://maven.apache.org/install.html)

3. Gradle (Only required if using Gradle as the build tool)
- If Gradle is not downloaded, download it from [here](https://gradle.org/releases/)
- For installation, follow the instructions [here](https://gradle.org/install/)

### Install the dependencies

To install the dependencies for Android tests, run :
Expand All @@ -39,20 +43,37 @@ mvn clean

Getting Started with Appium tests in TestNg on BrowserStack couldn't be easier!

### **Run first test :**
### **Run Sample test :**

- Switch to one of the following directories: [Android examples](android/testng-examples) or [iOS examples](ios/testng-examples)
- **For Maven:** Run the following command to execute tests in the Maven environment:
```sh
mvn test -P sample-test
```
- **For Gradle:** Run the following command to execute tests in the Gradle environment:
```sh
gradle clean sampleTest
```

- Switch to `run_first_test` directory under [Android examples](android/testng-examples) or [iOS examples](ios/testng-examples)
- Follow the steps outlined in the documentation - [Get Started with your first test on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/testng)
### **Use Local testing for apps that access resources hosted in development or testing environments :**

### **Speed up test execution with parallel testing :**
- Simply configure the `browserstackLocal` parameter in the `browserstack.yml` file accordingly in [Android examples](android/testng-examples) or [iOS examples](ios/testng-examples).
```
browserstackLocal: true
```
- You can use the `LocalSample` app provided in both folder [Android examples](android/testng-examples) or [iOS examples](ios/testng-examples) to run your test. Change the app parameter in the `browserstack.yml` file.

- Switch to `run_parallel_test` directory under [Android examples](android/testng-examples/) or [iOS examples](ios/testng-examples/)
- Follow the steps outlined in the documentation - [Get Started with parallel testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/testng/parallelize-tests)
- **For Maven:** Run the following command to execute tests in the Maven environment:
```sh
mvn test -P sample-local-test
```
- **For Gradle:** Run the following command to execute tests in the Gradle environment:
```sh
gradle clean sampleLocalTest
```

### **Use Local testing for apps that access resources hosted in development or testing environments :**
-similarly for gradle you can do :- gradle clean sampleLocalTest

- Switch to `run_local_test` directory under [Android examples](android/testng-examples/) or [iOS examples](ios/testng-examples/)
- Follow the steps outlined in the documentation - [Get Started with Local testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/testng/local-testing)

**Note**: If you are facing any issues, refer [Getting Help section](#Getting-Help)

Expand Down
Binary file added android/testng-examples/LocalSample.apk
Binary file not shown.
Binary file added android/testng-examples/WikipediaSample.apk
Binary file not shown.
79 changes: 79 additions & 0 deletions android/testng-examples/browserstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# =============================
# Set BrowserStack Credentials
# =============================
# Add your BrowserStack userName and acccessKey here or set BROWSERSTACK_USERNAME and
# BROWSERSTACK_ACCESS_KEY as env variables
userName: BROWSERSTACK_USERNAME
accessKey: BROWSERSTACK_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 Samples
# 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}
# Set `framework` of your test suite. Example, `testng`, `cucumber`, `cucumber-testng`
# This property is needed to send test context to BrowserStack (test name, status)
framework: testng

source: testng:appium-sample-sdk:v1.1

app: ./WikipediaSample.apk
#app: ./LocalSample.apk #For running local tests

# =======================================
# 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:
- deviceName: Samsung Galaxy S22 Ultra
osVersion: 12.0
platformName: android
- deviceName: Samsung Galaxy S21
osVersion: 11.0
platformName: android
- deviceName: Google Pixel 6 Pro
osVersion: 12.0
platformName: android

# =======================
# 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: 1

# ==========================================
# 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: true # <boolean> (Default false)
#browserStackLocalOptions:
#Options to be passed to BrowserStack local in-case of advanced configurations
# localIdentifier: # <string> (Default: null) Needed if you need to run multiple instances of local.
# forceLocal: true # <boolean> (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: false # <boolean> # Set to true if you need screenshots for every selenium command ran
networkLogs: false # <boolean> Set to true to enable HAR logs capturing
consoleLogs: errors # <string> Remote browser's console debug levels to be printed (Default: errors)
# Available options are `disable`, `errors`, `warnings`, `info`, `verbose` (Default: errors)
47 changes: 47 additions & 0 deletions android/testng-examples/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
plugins {
id 'java'
}

repositories { mavenCentral() }

dependencies {
testImplementation 'org.testng:testng:7.5'
implementation 'org.seleniumhq.selenium:selenium-java:4.13.0'
implementation 'io.appium:java-client:8.6.0'
implementation 'commons-io:commons-io:2.11.0'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
implementation 'com.browserstack:browserstack-java-sdk:latest.release'
}

group = 'com.browserstack'
version = '1.0-SNAPSHOT'
description = 'testng-browserstack'
sourceCompatibility = '1.8'

def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

tasks.withType(Test) {
systemProperties = System.properties
}

task sampleTest(type: Test) {
useTestNG() {
dependsOn cleanTest
useDefaultListeners = true
suites "src/test/resources/com/browserstack/sample-test.testng.xml"
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
}
}

task sampleLocalTest(type: Test) {
useTestNG() {
dependsOn cleanTest
useDefaultListeners = true
suites "src/test/resources/com/browserstack/sample-local-test.testng.xml"
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
}
}
Loading