Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fd9e624
update: add SDk changes, remove extra files
Ankit098 Oct 7, 2022
f31e2e7
update: README with sdk
Ankit098 Oct 7, 2022
61aa0ac
chore: set command for adding env variables
Ankit098 Oct 20, 2022
80aefff
update: add SDk changes, remove extra files
Ankit098 Oct 7, 2022
1b1ed24
update: README with sdk
Ankit098 Oct 7, 2022
3b84685
chore: set command for adding env variables
Ankit098 Oct 20, 2022
041ce48
update: local tests with localIdentifier
Ankit098 Nov 16, 2022
e407f27
merge: upstream sdk
Ankit098 Nov 16, 2022
9833397
Merge pull request #5 from Ankit098/sdk
francisf Nov 17, 2022
248415b
chore: remove extra files, restructure files
Ankit098 Dec 28, 2022
7fe3a32
update: readme run commands
Ankit098 Dec 28, 2022
d7c0a65
update: sample yml
Ankit098 Dec 28, 2022
43d3bd3
Added github action
agarneha1331 Apr 10, 2023
cc2dff7
delete PR template
agarneha1331 Apr 10, 2023
bf07fdd
fix codeowners
agarneha1331 Apr 11, 2023
a1bb638
fix name in workflow file
agarneha1331 Apr 11, 2023
3f6fc02
Merge pull request #9 from agarneha1331/create_github_action
karanshah-browserstack Apr 12, 2023
f6d6fe6
Fix run commands
agarneha1331 Apr 13, 2023
e5e1f52
chore: remove version pin
Ankit098 Apr 18, 2023
8f42dc4
Merge pull request #14 from Ankit098/update/deps
Ankit098 Apr 19, 2023
2527dea
Added BStack to test cases
agarneha1331 Jun 19, 2023
90c03e7
Merge pull request #15 from agarneha1331/fix-session-name-sdk
karanshah-browserstack Jul 7, 2023
d47c6f2
delete sdk workflow
agarneha1331 Jul 10, 2023
16866d1
fix: safari failure
07souravkunda Dec 22, 2023
92b8662
Merge pull request #19 from 07souravkunda/fix_safari_failure
07souravkunda Dec 28, 2023
6a8d8ba
pin version for robotframework
sriteja777 Jan 19, 2024
c2484f1
Update requirements.txt
sriteja777 Jan 19, 2024
fbba4ac
Merge pull request #21 from sriteja777/sdk
kamal-kaur04 Jan 19, 2024
0520cfb
Merged sdk branch to merge_sdk_to_main
Jun 19, 2024
94b4aa1
Fixed linting issue
Jul 1, 2024
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ pabot_results/
.pabotsuitenames
.DS_Store
*.png
browserstack.err
env
72 changes: 43 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,60 @@

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

## Setup
* Clone the repo
* Install dependencies `pip install -r requirements.txt`

## Set BrowserStack Credentials
* Export the BrowserStack username and access key as environment variables
## Prerequisite
```
python3 should be installed
```

#### For Linux/MacOS
## Setup
* Clone the repo
```
export BROWSERSTACK_USERNAME=<browserstack-username>
export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
git clone -b sdk https://github.com/browserstack/robot-browserstack.git
```
#### For Windows
* It is recommended to use a virtual environment to install dependencies. To create a virtual environment:
```
setx BROWSERSTACK_USERNAME=<browserstack-username>
setx BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
python3 -m venv env
source env/bin/activate # on Mac
env\Scripts\activate # on Windows
```
* Install dependencies
```
pip install -r requirements.txt
```

## Set BrowserStack Credentials
* Add your BrowserStack username and access key in the `browserstack.yml` config fle.
* You can also export them as environment variables, `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY`:

#### For Linux/MacOS
```
export BROWSERSTACK_USERNAME=<browserstack-username>
export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
```
#### For Windows
```
set BROWSERSTACK_USERNAME=<browserstack-username>
set BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>

setx BROWSERSTACK_USERNAME=<browserstack-username>
setx BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
```

## Running tests

* To run local test, run `robot tests/LocalTest.robot`
* To run parallel tests we will be using the [Pabot](https://pabot.org/) library:
1. To run test suites in parallel (Testcases within respective test suites will be sequential)
* Run - `pabot --processes <count_of_parallels> tests/parallel/*.robot`
* Alternate method: `pabot --processes <count_of_parallels> <name_of_suites_to_run>`
<br/>Eg: `pabot --processes 2 tests/parallel/Suite01.robot tests/parallel/Suite02.robot`
2. To run all test cases within a test suite in parallel
* Run - `pabot --testlevelsplit <test_suite_file_name>`
<br/>Eg: `pabot --testlevelsplit tests/parallel/Suite01.robot`
3. Run all testcases across all Test Suites in parallel
* Run - `pabot --testlevelsplit --processes <count_of_parallels> tests/parallel/*.robot`
<br/>**Note: If the process count exceeds the parallel threads available on BrowserStack, the sessions will automatically get queued.**
* To run sample tests:
- To run the sample tests in parallel across the platforms defined in the `browserstack.yml` file, run:
```
browserstack-sdk robot ./tests/test-*.robot
```
* To run tests on locally hosted websites:
- To run the local test in parallel across the platforms defined in the `browserstack.yml` file, run:
```
browserstack-sdk robot ./tests/local-test.robot
```

Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)

## Notes
* This repository only works for Selenium 3 as of now. Desired Capabilities do not get honoured for Selenium 4. The open issue on SeleniumLibrary can be found [here](https://github.com/robotframework/SeleniumLibrary/issues/1774).
* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate)
* To test on a different set of browsers, check out our [platform configurator](https://www.browserstack.com/automate/capabilities)

## Additional Resources
* [Documentation for writing Automate test scripts in Python](https://www.browserstack.com/automate/python)
* [Customizing your tests on BrowserStack](https://www.browserstack.com/automate/capabilities)
Expand Down
74 changes: 74 additions & 0 deletions browserstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# =============================
# 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 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}

# =======================================
# 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: latest
- os: Windows
osVersion: 10
browserName: Edge
browserVersion: latest
- deviceName: Samsung Galaxy S22 Ultra
browserName: chrome # Try 'samsung' for Samsung browser
osVersion: 12.0

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

source: robot-browserstack:sample-sdk:v1.0

# ===================
# 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)
37 changes: 0 additions & 37 deletions config/Config.py

This file was deleted.

60 changes: 0 additions & 60 deletions config/KeywordsFile.robot

This file was deleted.

19 changes: 0 additions & 19 deletions config/manage-local-testing.py

This file was deleted.

9 changes: 0 additions & 9 deletions config/mark-test-status.py

This file was deleted.

7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
robotframework
robotframework-seleniumlibrary==5.1.3
robotframework==6.1.1
robotframework-seleniumlibrary==6.2.0
robotframework-pabot
browserstack-local
selenium==3.141.0
selenium
browserstack-sdk
30 changes: 30 additions & 0 deletions resources/KeywordsFile.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
*** Settings ***
Library SeleniumLibrary

*** Variables ***
${remote_url}= http://localhost:4444/wd/hub

*** Keywords ***
Open Session
[Arguments] ${capabilities} ${test_url}
open browser remote_url=${remote_url} browser=chrome desired_capabilities=${capabilities} url=${test_url}

Close Session
close browser

Add Implicit Wait
set selenium implicit wait 5

Get the page title
get title

Verify Local Page
Title Should be BrowserStack Local

Add first product to cart
click element xpath=//*[@id="1"]/div[4]

Verify product is added to cart
${product_name} get text xpath=//*[@id="1"]/p
${product_incart} get text css=p.title
element should contain css=p.title ${product_name}
10 changes: 10 additions & 0 deletions resources/TestCases.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*** Settings ***
Library SeleniumLibrary
Resource ./KeywordsFile.robot

*** Keywords ***
Add to Cart
Add Implicit Wait
Get the page title
Add first product to cart
Verify product is added to cart
27 changes: 0 additions & 27 deletions tests/LocalTest.robot

This file was deleted.

Loading