This repository demonstrates how to run Appium Java tests on BrowserStack App Automate using the BrowserStack SDK. All device, credential, and build configuration is managed via browserstack.yml — no hardcoded capabilities in test code.
-
Java 8+
-
Maven
Navigate to the java_8 directory and run:
cd java_8/
mvn clean installUpload your Android (.apk / .aab) or iOS (.ipa) app to BrowserStack using the REST API:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
-F "file=@/path/to/your/app"Note the app_url value (e.g. bs://xxxxxxx) returned in the response — you'll need it in the next step.
Don't have an app? Use the BrowserStack sample apps:
Open java_8/browserstack.yml and set your credentials, app, and target devices.
# =====================
# BrowserStack Credentials
# =====================
# Either set values directly here, or export as environment variables:
# export BROWSERSTACK_USERNAME=your_username
# export BROWSERSTACK_ACCESS_KEY=your_access_key
userName: YOUR_USERNAME
accessKey: YOUR_ACCESS_KEY
# =====================
# Reporting
# =====================
projectName: First Java Project
buildName: browserstack-build-1
buildIdentifier: '#${BUILD_NUMBER}'
# =====================
# App under test
# =====================
app: bs://<app-id> # Replace with the app_url from Step 1
# =====================
# Target devices
# =====================
platforms:
- deviceName: <device-name>
platformVersion: <os-version>
platformName: <android/ios>
parallelsPerPlatform: 1
# =====================
# Local Testing (optional)
# =====================
browserstackLocal: <true/false> # Set to true for local/internal environment testsMake sure you are inside the java_8/ directory before running any of the following commands.
mvn test -P android-first-testmvn test -P ios-first-testmvn test -P android-local-testmvn test -P ios-local-testLocal Testing lets you test apps that access resources on your internal or staging environments.
To enable it, set the following in browserstack.yml:
browserstackLocal: trueThe SDK will automatically start and stop the BrowserStack Local tunnel — no manual binary setup needed. Then run the local test profile:
# Android
mvn test -P android-local-test
# iOS
mvn test -P ios-local-testNote for macOS users: If you encounter Apple permission issues with the Local binary, go to:
System Preferences → Security & Privacy → General → Allow app
This module uses io.appium:java-client:8.x. Key differences from 7.x:
- Use
AppiumByinstead of the deprecatedMobileBy. MobileElement,IOSElement,AndroidElementare removed — useWebElementinstead.WebDriverWaitrequires aDurationargument:// java-client 7.x new WebDriverWait(driver, 30) // java-client 8.x new WebDriverWait(driver, Duration.ofSeconds(30))
See the full v7 to v8 migration guide for details.
After running your tests, visit the App Automate Dashboard to see:
- Test status (pass/fail)
- Video recordings
- Device logs
- Network logs
If you run into any issues, check the BrowserStack Support page or contact us.