- Verify that relevant and important elements and text are present on the page.
- Write a test that will go through the user flow to receive insurance quotes. With this test, you will need to enter the user, auto, and driver information.
- Selenium Webdriver with Python Bindings and PyTest as the unit test framework. 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.
- Reason for using this framework over JS / Mocha was famarilty with python/pytest and time constraints.
- Manually tested the user flow several times to get idea of how and what needs to tested
- "Whiteboarded" (pen and paper) the project layout
- Created the project dir and stubbed out the page methods for each page class
- Created a single test for the user flow
- Validated each element returned unique identifier then added locator attributes and interaction methods to the Page Objects
- Imported each module one at a time to Quote User flow test to that they were working as expected
- Added explict waits to most methods due to frequent "element not interactable" errors
- Ran out of time to built out PyTest Conftest, utilizing pytest fixtures for setup / teardown and create options for multiple browsers support
- Create more tests around error handling, and messaging.
- Add explicit waits method in a base class / custom driver for all interactions
-
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/car_insurnace_test.py
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 tests/car_insurnace_test.py