The design pattern being used is a Page Object Model. POM is used to have reusable WebElements/small helper methods separated from the actual test classes, allowing for cleaner code and easier test maintenance.
-
Install Python 3.x https://www.python.org/downloads/
Optionally, you can create a virtual env to isolate Python dependencies between projects -
In a terminal install the following packages:
pip install selenium
pip install pytest
-
Add Python 3.x to your PATH environment variable
How to add python PATH in windows
- Search 'env'
- Edit the System Environment Variables
- Click on 'Environment Variables' button
- Click on 'New' in the System Variable section
- Enter
PYTHONPATH
in the Variable name field - Enter in the Variable value field
C:\Python[version];C:\Python[version]\DLLs;C:\Python[version]\lib;C:\Python[version]\Scripts;
- Select and click Edit on 'path' the list of system variables
- add
%PYTHONPATH%
to the end existing Path variable value - open a terminal /cmd promp and type
python
. Should be able to run the interpreter and see the python version
- Clone repo to your local machine
A driver is separate executable that WebDriver uses to control Browsers. Use links below to get started:
#Note: Check Firefox + Chrome version & Selenium version compatibility before downloading geckodriver.
How to evoke browsers
- download chromedriver and extract the file
- copy file in desired location > Add path to executable_path variable in your tests
driver = webdriver.Chrome(executable_path = 'C:\\chromedriver.exe')
To execute the tests just browse to the path where the selenium project is located in your terminal and type:
py.test tests/home/login_tests.py
Directory structure - NOTE: Base, Config, Utils will be implemented at a later date
|__base: DriverFactory and PageFactory
|__config: For all configurations and credential files
|__page: Put your Page Objects in here
|__tests: Put your tests in here
|__utils: Base Loggers are kept in this folders
NOTE: Will be implemented in later date Log files are created with each test and if the test fails a screenshots is taken to provide further information about what happened if they failed. The screenshots reside in the ./screenshots directory and can be viewed locally in your IDE
a)py.test [options]
-s used to display the output on the screen
-v increase verbosity
-h help for more options
-n used to run tests in parallel
example: py.test -s -v sfcc/tests/login/login_tests.py