-
Create python GitHub pipeline
-
Setup pipeline to install python verion
-
Install all dependencies from requirements.txt file
-
Install geckodriver
-
Setup geckodriver path
import os os.environ['PATH'] += ':/driver/geckodriver'
-
Setup webdriver to run in headless mode
from selenium.webdriver.firefox.options import Options options = Options() options.headless = True driver = webdriver.Firefox(options=options)
-
Clone the remote repository into your local machine
-
Launch vscode application
-
Open the folder in the vscode
-
Click the Testing icon bar
-
Click configure Python tests button
-
Select the pytest framework
-
Select the directory where your tests resides
-
A file (settings.json) should be created
//command line arguments should be given in the pytestArgs values { "github.copilot.editor.enableCodeActions": true, "python.testing.pytestArgs": [ "tests", "--browser_name=chrome" ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true }
-
In the Testing activity bar, you will be able to see the complete tests
pytest -v -m "login" --browser_name chrome --html reports/testing.html tests/test_login_page/test_login_page.py
Note: To debug, add the breakpoint and click debug test on any of the test file.
- Install pip & python
- Add python path to the PATH env variable. So that the terminal knows where the python exists in.
- Install firefox - https://ftp.mozilla.org/pub/firefox/releases/99.0b8/linux-x86_64/en-GB/
- Set the firefox executable path to PATH variable
- Install geckodriver
- Set the geckodriver executable path to PATH variable
- Check the pip, python, firefox and geckodriver version
- Now you will be able to run the selenium tests
Documentation:
https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location/
https://dev.to/eugenedorfling/installing-the-firefox-web-driver-on-linux-for-selenium-d45
https://gist.github.com/stephenharris/90bb468bf80e7f7b02e8b8afe694de4f
https://ftp.mozilla.org/pub/firefox/releases/99.0b8/linux-x86_64/en-GB/
https://pytest-with-eric.com/introduction/how-to-run-pytest-in-vscode/#Setting-Up-Pytest-In-VS-Code