Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 146e295

Browse files
authoredSep 5, 2023
Add files via upload
1 parent 2020a2b commit 146e295

File tree

6 files changed

+126
-2
lines changed

6 files changed

+126
-2
lines changed
 

‎README.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,63 @@
1-
# Robot-framework_with_Python_for_Browserstack
2-
This is a sample code snippet for Robot framework with Python, to run Automated cross Browser and cross platform testing on Browserstack
1+
# BrowserStack Integration with Robot Framework Selenium (Python)
2+
3+
![BrowserStack Logo](https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-header.png?1469004780)
4+
5+
## Prerequisite
6+
```
7+
python3 should be installed
8+
```
9+
10+
## Setup
11+
* Clone the repo
12+
```
13+
git clone -b sdk https://github.com/browserstack/robot-browserstack.git
14+
```
15+
* It is recommended to use a virtual environment to install dependencies. To create a virtual environment:
16+
```
17+
python3 -m venv env
18+
source env/bin/activate # on Mac
19+
env\Scripts\activate # on Windows
20+
```
21+
* Install dependencies
22+
```
23+
pip install -r requirements.txt
24+
```
25+
26+
## Set BrowserStack Credentials
27+
* Add your BrowserStack username and access key in the `browserstack.yml` config fle.
28+
* You can also export them as environment variables, `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY`:
29+
30+
#### For Linux/MacOS
31+
```
32+
export BROWSERSTACK_USERNAME=<browserstack-username>
33+
export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
34+
```
35+
#### For Windows
36+
```
37+
set BROWSERSTACK_USERNAME=<browserstack-username>
38+
set BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
39+
40+
setx BROWSERSTACK_USERNAME=<browserstack-username>
41+
setx BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
42+
```
43+
44+
## Running tests
45+
46+
* To run sample tests:
47+
- To run the sample tests in parallel across the platforms defined in the `browserstack.yml` file, run:
48+
```
49+
browserstack-sdk robot ./tests/test-*.robot
50+
```
51+
* To run tests on locally hosted websites:
52+
- To run the local test in parallel across the platforms defined in the `browserstack.yml` file, run:
53+
```
54+
browserstack-sdk robot ./tests/local-test.robot
55+
```
56+
57+
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
58+
59+
## Additional Resources
60+
* [Documentation for writing Automate test scripts in Python](https://www.browserstack.com/automate/python)
61+
* [Customizing your tests on BrowserStack](https://www.browserstack.com/automate/capabilities)
62+
* [Browsers & mobile devices for selenium testing on BrowserStack](https://www.browserstack.com/list-of-browsers-and-platforms?product=automate)
63+
* [Using REST API to access information about your tests via the command-line interface](https://www.browserstack.com/automate/rest-api)

‎browserstack.err

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[object Object]

‎browserstack.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
userName: YOUR_USER_NAME
2+
accessKey: YOUR_ACCESS_KEY
3+
framework: robot
4+
platforms:
5+
- deviceName: iPhone 14 Pro
6+
osVersion: 16
7+
browserName: safari
8+
deviceOrientation: portrait
9+
- os: OS X
10+
osVersion: Ventura
11+
browserName: Safari
12+
browserVersion: 16.5
13+
- os: OS X
14+
osVersion: Big Sur
15+
browserName: Safari
16+
browserVersion: 14.1
17+
parallelsPerPlatform: 1
18+
browserstackLocal: true
19+
seleniumVersion: 4.11.0
20+
buildName: grandel-browserstack-robot
21+
projectName: BrowserStack Sample

‎requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
robotframework
2+
robotframework-seleniumlibrary
3+
robotframework-pabot
4+
browserstack-local
5+
selenium
6+
browserstack-sdk

‎resources/KeywordsFile.robot

Lines changed: 26 additions & 0 deletions
This file contains bidirectional or hidden Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
*** Settings ***
2+
Library SeleniumLibrary
3+
4+
*** Variables ***
5+
${remote_url}= http://localhost:4444/wd/hub
6+
7+
*** Keywords ***
8+
Open Session
9+
[Arguments] ${capabilities} ${test_url}
10+
open browser remote_url=${remote_url} desired_capabilities=${capabilities} url=${test_url}
11+
12+
Close Session
13+
close browser
14+
15+
Add Implicit Wait
16+
set selenium implicit wait 5
17+
18+
Get the page title
19+
get title
20+
21+
Verify Local Page
22+
Title Should be ‪GrandEL Dsouza‬ - ‪Google Scholar‬
23+
24+
Click on the link
25+
click element xpath=//*[@id="gsc_a_b"]/tr[1]/td[1]/a
26+

‎resources/TestCases.robot

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*** Settings ***
2+
Library SeleniumLibrary
3+
Resource ./KeywordsFile.robot
4+
5+
*** Keywords ***
6+
Add to Cart
7+
Add Implicit Wait
8+
Get the page title
9+
Click on the link

0 commit comments

Comments
 (0)
Please sign in to comment.