Skip to content

Commit

Permalink
Fix bug in running multi-user scenarios in BrowserStack.
Browse files Browse the repository at this point in the history
Added Github workflow for multi-user scenario in BrowserStack
  • Loading branch information
anandbagmar committed Aug 31, 2023
1 parent d37b2c9 commit 0cdc139
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 25 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/BrowserStack_MultiUser_Android_Web_CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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 will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: BrowserStack_MultiUser_Android_Web_CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Install Appium 2.0 and dependencies
run: |
node -v
npm install
- name: Run Multi-user Android & Web tests against Browserstack
run: |
RUN_IN_CI=true APPLITOOLS_API_KEY=${{ secrets.TESWIZ_APPLITOOLS_API_KEY }} IS_VISUAL=true CONFIG=./configs/theapp_browserstack_config.properties CLOUD_USERNAME=${{ secrets.BROWSERSTACK_CLOUD_USERNAME }} CLOUD_KEY=${{ secrets.BROWSERSTACK_CLOUD_KEY }} PLATFORM=android TAG="@multiuser-android-web and @theapp and @browserstack" ./gradlew run
28 changes: 14 additions & 14 deletions caps/theapp_browserstack_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,33 @@
"appPackage": "com.appiumpro.the_app",
"appActivity": "com.appiumpro.the_app.MainActivity",
"autoAcceptAlerts": true,
"automationName": "UIAutomator2",
"os_version": "12",
"platformName": "Android",
"device": "Samsung",
"autoGrantPermissions": true,
"newCommandTimeout": 300,
"noSign": true,
"launchTimeout": 90000,
"unicodeKeyboard": true,
"resetKeyboard": true,
"noReset": true,
"project": "teswiz",
"automationName": "UIAutomator2",
"browserstack.appium_version": "2.0.1",
"browserstack.enableCameraImageInjection": true,
"browserstack.debug": true,
"browserstack.geoLocation": "IN",
"browserstack.timezone": "Kolkata",
"browserstack.networkLogs": "true",
"browserstack.gpsLocation": "22,75",
"browserstack.locale": "IN"
"browserstack.locale": "IN",
"device": "Samsung",
"launchTimeout": 90000,
"newCommandTimeout": 300,
"noReset": true,
"noSign": true,
"os_version": "12",
"platformName": "Android",
"project": "teswiz",
"resetKeyboard": true,
"unicodeKeyboard": true
},
"web": {
"browserName": "chrome",
"browserstackOptions": {
"os": "Windows",
"osVersion": "11",
"browserVersion": "latest",
"seleniumVersion": "3.14.0",
"debug": "true",
"networkLogs": "true"
}
Expand All @@ -48,7 +47,8 @@
"url": "http://hub-cloud.browserstack.com",
"apiUrl": "https://api-cloud.browserstack.com/app-automate/",
"devices": [
]
],
"web": {}
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions caps/theapp_browserstack_web_capabilities.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"android": {
"platformName": "android",
"app": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/TheApp-release.apk",
"adbExecTimeout": 45000,
"appPackage": "com.appiumpro.the_app",
"automationName": "UiAutomator2",
"autoGrantPermissions": true,
"appPackage": "com.appiumpro.the_app",
"uiautomator2ServerInstallTimeout": 10000,
"adbExecTimeout": 45000,
"eventTimings": true,
"deviceName": "android",
"enablePerformanceLogging": true,
"eventTimings": true,
"noSign": true,
"platformName": "android",
"printPageSourceOnFindFailure": true,
"app": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/TheApp-release.apk",
"deviceName": "android",
"noSign": true
"uiautomator2ServerInstallTimeout": 10000
},
"web": {
"browserName": "chrome",
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/znsio/teswiz/runner/BrowserStackSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.exceptions.EnvironmentSetupException;
import com.znsio.teswiz.exceptions.InvalidTestDataException;
import com.znsio.teswiz.tools.JsonFile;
Expand Down Expand Up @@ -67,7 +68,7 @@ private static void setupLocalTesting(String authenticationKey, Map loadedPlatfo
static MutableCapabilities updateBrowserStackCapabilities(MutableCapabilities capabilities) {

String authenticationKey = Setup.getFromConfigs(Setup.CLOUD_KEY);
String platformName = Setup.getPlatform().name();
String platformName = Platform.web.name();
String capabilityFile = Setup.getFromConfigs(Setup.CAPS);

Map<String, Map> loadedCapabilityFile = JsonFile.loadJsonFile(capabilityFile);
Expand Down
5 changes: 3 additions & 2 deletions src/test/resources/com/znsio/teswiz/features/theapp.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ Feature: Scenarios for "The App"
When I go back
Then I can echo "how are you too?" in the message box

# CONFIG=./configs/theapp_local_config.properties TAG="@multiuser-android-web and @theapp" ./gradlew run
@multiuser-android-web @theapp
# CONFIG=./configs/theapp_local_android_config.properties TAG="@multiuser-android-web and @theapp" ./gradlew run
# RUN_IN_CI=true CONFIG=./configs/theapp_browserstack_config.properties CLOUD_USERNAME=$BROWSERSTACK_CLOUD_USERNAME CLOUD_KEY=$BROWSERSTACK_CLOUD_KEY TAG="@multiuser-android-web and @theapp and @browserstack" ./gradlew run
@multiuser-android-web @theapp @browserstack
Scenario: Orchestrating multiple users on different platforms as part of same test
Given "I" login with invalid credentials - "znsio1", "invalid password" on "android"
And "You" login with invalid credentials - "znsio2", "invalid password" on "web"
Expand Down

0 comments on commit 0cdc139

Please sign in to comment.