Skip to content

Proof of concept for test automation using python and selenium

Notifications You must be signed in to change notification settings

mahsa2017/pythonselenium

Repository files navigation

Python Selenium Web Automation

Features

  • Support for browser:
    • Chrome (default)
    • Edge
    • Firefox
    • Safari
  • Support headless test runs
  • Selenium 4.7.0
  • Logging info for each action
  • HTML Report and HTML dashboard For more features, see SeleniumBase Features.

Installation

IDE used: PyCharm

Python Selenium Web Automation Framework requires Python v3+ and SeleniumBase to run. Once you install Python from their official website now it's time to Install SeleniumBase:

pip3 install seleniumbase

Note: If your python is version 3 above you will need to run pip3 otherwise pip will work

Next you need to install browser drive for instance chromeDrive through seleniumBase:

sbase get chromedriver latest 

Create a virtual environment on your local machine. See Pipenv & Virtual Environments for details.

Install the dependencies:

python3 -m pip install -r requirements.txt

Structure:

Folders:

  • assets: This folder will contain all the files like images, css files or json files or test data.
  • custom_Screenshot: This folder will save any screenshots that you make
  • latest_logs: This folder will be generated when a test fails to save any log and screenshots.
  • recordings: This folder will be generated when you use the recorder feature to store the test code generated.
  • tests: All the test cases python files will be kept here.
  • requirements.txt: This file stores information about all the libraries, modules, and packages which are specific to project.

Test report files:

  • dashboard.html
  • report.html

Run tests

To run each individual test, right-click on the test name on pyCharm IDE and select "run ". To run a test file, go to the terminal and type:

pytest -k <file name without .py> --dashboard --rs --html=report.html

or

pytest tests/<file name with .py> --dashboard --rs  --html=report.html

Some useful options pytest include --headless (without opening up a browser) and --demo (for showcasing the test run). To see a full list of options, go to the terminal and type:

sbase options

If you need cross browser testing for instance firefox you can provide it as a flag:

pytest -k <test_file_name> --browser=firefox

If you need parallel testing for instance you need 3 browser instance to speed up tests run:

pytest -n=3

Integrate with Azure pipelines

Read here.

Record, playback and export code

Read here.

Coming Up:

About

Proof of concept for test automation using python and selenium

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published