Creating the first script using Selenium with Pytest

Selenium is one of the topmost tool used for web automation. You can download the selenium package and interact with the applications using web drivers. Selenium package available here and can be download using pip command

pip install selenium  

Selenium requires a driver to interface with the chosen browser. Chrome, for example, requires chromedriver, which needs to be installed before the below examples can be run. Make sure it’s in your PATH

Yes, you've completed the required installation. Now we can write a simple script to launch the testodev.
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('start-maximized')
driver = webdriver.Chrome(
    options=options, executable_path=r".\\chromedriver\\chromedriver.exe")
driver.get("https://www.testodev.com/")
You run the script via command line using the command pytest <script name> 
The script launches the testodev via chromedriver. 
Previous Post Next Post