Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ output/
__pycache__/
*.pyc
.env

# BrowserStack SDK sample
env/
.venv/
node_modules/
local.log
log/
*.log
57 changes: 57 additions & 0 deletions README-SDK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Robot Framework with BrowserStack

This sample demonstrates the BrowserStack Python SDK with Robot Framework and Playwright
running on real Android devices via BrowserStack App Automate. The SDK reads
`browserstack.yml`, routes the Playwright session to the Android device platforms defined
there using `playwright.android.connect()`, and reports results to the App Automate
dashboard. No capabilities or CDP URLs are constructed by hand.

> Note: This SDK sample lives alongside the existing (non-SDK) sample in this repository.
> SDK files: `browserstack.yml`, `requirements-sdk.txt`, `sdk_sample_test.robot`,
> `sdk_sample_local_test.robot`, and this `README-SDK.md`.

## Prerequisites

- Python >= 3.9
- Node.js (required by the `robotframework-browser` / Playwright `Browser` library)
- A [BrowserStack](https://www.browserstack.com/) account (username + access key)

## Setup

```bash
git clone https://github.com/browserstack/playwright-robot-android-browserstack.git
cd playwright-robot-android-browserstack

python3 -m venv env
source env/bin/activate # on Windows: env\Scripts\activate

pip install -r requirements-sdk.txt
rfbrowser init # installs the Playwright Node dependencies for the Browser library
```

Set your credentials as environment variables (or edit `userName` / `accessKey` in
`browserstack.yml`):

```bash
export BROWSERSTACK_USERNAME=<your_username>
export BROWSERSTACK_ACCESS_KEY=<your_access_key>
```

## Run Sample Test

```bash
browserstack-sdk robot sdk_sample_test.robot
```

## Run Local Test

```bash
browserstack-sdk robot sdk_sample_local_test.robot
```

## Notes

- This combination (Robot Framework + Playwright on real Android devices via
`playwright.android.connect()`, routed to App Automate) is newly supported by the SDK and
should be human-reviewed before publishing.
- View your test results on the [BrowserStack App Automate dashboard](https://app-automate.browserstack.com/).
21 changes: 21 additions & 0 deletions browserstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
userName: YOUR_USERNAME
accessKey: YOUR_ACCESS_KEY
projectName: BrowserStack Samples
buildName: browserstack build
buildIdentifier: '#${BUILD_NUMBER}'
framework: robotframework
platforms:
- deviceName: Samsung Galaxy S23
osVersion: 13.0
platformName: android
- deviceName: Google Pixel 7
osVersion: 13.0
platformName: android
parallelsPerPlatform: 1
browserstackAutomation: true
browserstackLocal: true
source: playwright-robot-android-browserstack:sample-sdk:v1.0
testObservability: true
debug: false
networkLogs: false
consoleLogs: errors
4 changes: 4 additions & 0 deletions requirements-sdk.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
robotframework-browser
robotframework
browserstack-local
browserstack-sdk @ https://sdk-assets.browserstack.com/python/browserstack_sdk-latest.tar.gz
17 changes: 17 additions & 0 deletions sdk_sample_local_test.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*** Settings ***
Documentation BrowserStack SDK local test (Robot Framework + Playwright on real
... Android devices via App Automate). With browserstackLocal: true in
... browserstack.yml, the SDK starts the BrowserStack Local tunnel so the
... Android device can reach the local endpoint exposed at bs-local.com.

Library Browser


*** Test Cases ***
Verify Local Page Title
[Documentation] Open the BrowserStack Local endpoint and assert the page title.
New Browser chromium
New Page http://bs-local.com:45454
${title}= Get Title
Should Be Equal ${title} BrowserStack Local
Close Browser
23 changes: 23 additions & 0 deletions sdk_sample_test.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
*** Settings ***
Documentation BrowserStack SDK sample test (Robot Framework + Playwright on real
... Android devices via App Automate). The BrowserStack SDK reads
... browserstack.yml, routes the Playwright session to the Android device
... platforms defined there, and reports results to the App Automate
... dashboard. No CDP URL or capabilities are built by hand.

Library Browser


*** Test Cases ***
Add First Product To Cart
[Documentation] Open bstackdemo, add the first product to the cart, and assert the
... product name shown in the cart pane matches the listing.
New Browser chromium
New Page https://bstackdemo.com/
${productText}= Get Text xpath=//*[@id="1"]/p
Click xpath=//*[@id="1"]/div[4]
Wait For Elements State css=.float-cart__content visible
${productCartText}= Get Text
... xpath=//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]
Should Be Equal ${productCartText} ${productText}
Close Browser
Loading