Install python python installation guide
Install selenium library selenium installation files: pip install selenium
Add python path to enviroment variable
donwload browser drivers and put in python27 directory Guide for selenium installation
This is implementation of Selenium with python for sample project Before executing test please install pytest module by command :pip install pytest
to execute tests give command: python -m pytest to execute tests give command and get verbose results :py.test -v once command given pytest will execute test having names starting with test from subordinate directory (ex. test_*.py)
import pytest
@pytest.mark.skip(reason="I dont want to run test")
to see result with verbose and reason behind skip execute command: pytest -v -rxs
to execute selective tests only enter command: pytest -k It will execute all tests having in test name
add @pytest.mark.<tagName> code before test cases to tag
ex.
import pytest
@pytest.mark.<tagName>
def test_myTest1():
print("my test")
enter below command to execute tests with given tag name
pytest -m <tagName>
enter below command to execute tests not having tag as smoke
pytest -m "not smoke" -v
I have allure adapter to generate HTML reports. Please find steps to install and setup allure reproter in project:
Step 1.Install Allure adapter
pip install pytest-allure-adaptor
Step 2.download allure zip file in your system donwload allure zip
Step 3.extract downloaded zip file and add allure2.7.0/bin location to environment variable
Step 4.Verify pytest-allure-adapter is added in interpreter of pycharm
Step 5.create Report folder in project and run test case with below command
pytest --alluredir <path of report folder>
Step 6.After test is run xml files will be generated in reports folder. To create html report open command prompt and enter below command:
cd <path of report folder>
allure generate <path of report folder>
If you find any difficulty please refer this youtube video