Skip to content

This repository showcases the BrowserStack integration features with the Python Robot framework using the BrowserStack demo app: https://bstackdemo.com/

Notifications You must be signed in to change notification settings

BrowserStackCE/browserstack-examples-robot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

BrowserStack Examples Robot Framework Robot python

Introduction

Robot Framework is a generic open source automation framework which can be used for test automation. It is open and extensible and can be integrated with many tools to create powerful and flexible automation solutions. Robot Framework has easy syntax, utilising human-readable keywords and its capabilities can be extended by libraries implemented with Python or Java.

This BrowserStack Example repository demonstrates a Selenium test framework written in Robot Framework with parallel testing capabilities. The Selenium test scripts are written for the open source BrowserStack Demo web application (Github). This BrowserStack Demo App is an e-commerce web application which showcases multiple real-world user scenarios. The app is bundled with offers data, orders data and products data that contains everything you need to start using the app and run tests out-of-the-box.

The Selenium tests in this repo are run on BrowserStack real device/browser using various run configurations and test capabilities.


BrowserStack

BrowserStack provides instant access to 3,000+ real mobile devices and browsers on a highly reliable cloud infrastructure that effortlessly scales as testing needs grow.

Repository setup

  • Clone the repository

    git clone https://github.com/BrowserStackCE/browserstack-examples-robot.git
  • It is recommended to use a virtual environment to install dependencies. To create a virtual environment:

    python3 -m venv env
    source env/bin/activate # on Mac
    env\Scripts\activate # on Windows
  • Ensure you have the dependencies installed on the machine as mentioned in the requirements.txt file

    To Install the requirements:

    pip install -r requirements.txt

About the tests in this repository

This repository contains the following Selenium tests:

Module Test name Description
e2e E2E Test This test scenario verifies successful product purchase lifecycle end-to-end. It demonstrates the Page Object Model design pattern and is also the default test executed in all the single test run profiles.
login Check if Signin opens on clicking on favourites nav item This test verifies the login workflow with different types of valid login users.
login Check Login with locked_user This test verifies the login workflow error for a locked user.
offers Set GPS location to Mumbai and check offers This test mocks the GPS location for Mumbai and verifies that the product offers applicable for the Mumbai location are shown.
product Apply Apple And Samsung Filter This test verifies that the Apple products are only shown if the Apple vendor filter option is applied.
product Apply 'Lowest to Highest' Order By Filter This test verifies that the product prices are in ascending order when the product sort "Lowest to Highest" is applied.
user Check Login with image_not_loading_user This test verifies that the product images load for user: "image_not_loading_user" on the e-commerce application. Since the images do not load, the test case assertion fails.
user Check Order in existing_orders_user This test verifies that existing orders are shown for user: "existing_orders_user"

Running your tests on an On-Prem Browser

Running a single test on an On-Prem Browser

To execute a single test run the below command:

robot /path/to/test.robot

For eg:

robot ./src/test/suites/e2e/e2e.robot

Running parallel tests on On-Prem Browsers

To execute a single test run the below command:

pabot path/to/testsuiteFolder

For eg:

pabot ./src/test/suites

Running Your Tests on Browserstack

Prerequisites to run your tests on Browserstack

  • Create a new BrowserStack account or use an existing one.

  • Identify your BrowserStack username and access key from the BrowserStack Automate Dashboard and export them as environment variables using the below commands.

    • For *nix based and Mac machines:
    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>

    Alternatively, you can also hardcode username and access_key objects in the browserstack.yml sdk file.

Note:

  • You can use this SDK config generator BrowserStack SDK Configurator to create your browserstack.yml file and certainly update them based on your device / browser test requirements.

Run a specific test

  • How to run the test?

    To run a specific test scenario, use the command below:

    browserstack-sdk robot /path/to/test.robot
  • Output

    This run profile executes the specific test scenario in browserstack on the platforms configured in your browserstack.yml file.

Run the entire test suite

  • How to run the test?

    To run the entire test suite parallely in browserstack, you will require pabot dependency use the following command:

    browserstack-sdk pabot path/to/testsuiteFolder

    You can also use the other combinations as described in pabot to run your tests parallely.

  • Output

    This run profile executes the entire test suite parallely in browserstack on the platforms configured in your browserstack.yml file.


Run tests on BrowserStack which need Local Environment access

The only change you need to do here, is to add the respective options in the browserstack.yml file. The browserstack-sdk handles the starting and termination of BrowserStack Local Instance.

browserstackLocal: true

browserstackLocal is set to true in this repo.

Additional Resources

About

This repository showcases the BrowserStack integration features with the Python Robot framework using the BrowserStack demo app: https://bstackdemo.com/

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published