Testing with Python and Selenium

https://www.python.org/downloads/ – Download Python

Install Selenium

$ pip install selenium

Chrome Driver for Selenium

https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver – download Chrome Driver

Place Chrome Driver in directory: C:\Program Files (x86)\Google\chromedriver.exe

Google-test.py

#IMPORT
from selenium import webdriver
driver = webdriver.Chrome("C:\\Program Files (X86)\\Google\\chromedriver.exe")
from time import sleep

#NAVIGATE
driver.get("https://www.google.com/")
driver.maximize_window()
sleep(2)

#FILL OUT FIELDS
driver.find_element_by_id("lst-ib").send_keys("testing with python and selenium")

#CLICK SUBMIT BUTTON
driver.find_element_by_name("btnK").click()
driver.get_screenshot_as_file("search.png")
sleep(5)

#END PROGRAM
driver.close()

Tutorial

Here’s a good tutorial I watched to get started:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>