Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

A starter project structure for creating selenium tests with python

Notifications You must be signed in to change notification settings

chiedo/python-selenium-starter

Repository files navigation

Python-selenium-starter

Starter set up for writing selenium tests with Python. The Goal is to make it easier to write and run tests using Selenium for multiple browsers and devices. With this repo, you should be able to just start writing your tests and not be concerned with the basic set up of your test framework. This has options to also run on browserstack but could easily be modified to use another service with some elementary coding.

Installing Selenium

  • Install pip first if needed obviously (google is your friend here)
  • pip install -U selenium

Getting Started

  • You can add more tests by adding modules to the tests directory. Copy the structure in the examples and your tests should be executed automagically by the above.
  • You will likely want to update the data in the config.py file. But should not need to update anything in the run.py file unless you are applying a general fix to this repo that you plan to contribute..

General Examples

To run all tests on Firefox

python run.py

To override the base url you set in run.py

python run.py --base_url "http://google.com"

To only run one test

python run.py --test "example_a.py"

To see more options

python run.py --help

Browserstack options

export SELENIUM_AUTOMATE_USERNAME="REPLACE_THIS"
export SELENIUM_AUTOMATE_VALUE="REPLACE_THIS"
  • Then run the following in your terminal (remember to modify to ~/.bashrc if on linux)
source ~/.bash_profile

Open a tab and run the following to start the local testing server. That will make sure you can still access the site via the correct IP address, etc.

./local_testing_binaries/osx/BrowserStackLocal $SELENIUM_AUTOMATE_VALUE localhost,3000,0 -forcelocal -vv

Then Run the following to execute the tests and hook into the browser stack local testing server

python run.py --browserstack --use_local

Browserstack Examples

To run with only in the desktop browsers:

python run.py --browserstack --mobile

To run with only the in the desktop browsers:

python run.py --browserstack --desktop

To override the base url you set in run.py

python run.py --browserstack --capabilities "{'os_version': '7', 'browser_version': '8.0', 'os': 'Windows', 'resolution': '1024x768', 'browser': 'IE'}"

Browserstack Notes

About

A starter project structure for creating selenium tests with python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published