A short tutorial to automate web UI testing with Python and Selenium
- What is automated testing?
- Python Selenium bindings
- Locating elements in the HTML DOM
- Navigating through pages
- Waits
Once you have installed python, python-selenium bindings and the web driver, let's test if the setup is complete
from selenium import webdriver
import time
driver= webdriver.Chrome()
driver.get('http://seleniumhq.org')
time.sleep(2)
driver.close()
- Download the file html_code_01
- Use the path of this file in your automation script and locate the element by ID loginForm
- Download the file html_code_01
- Use the path of this file in your automation script and locate the element by name username
- Download the file html_code_01
- Use the path of this file in your automation script and locate the login form element using relative xpath, absolute xpath and using xpath with an attribute
- Download the file html_code_01
- Use the path of this file in your automation script and locate the element by class name content
- Go to http://www.seleniumhq.org/
- Locate the element by id q
- Locate the element by name q
- Locate the element heading What is Selenium? by xpath
- Find element by class selenium-sponsors
- Navigate to http://python.org
- Find the search bar
- Perform a search for pycon
- Download the file html_code_02
- Use the path of this file in your automation script
- Locate the select element by name numReturnSelect and select values by index, visible text and value
- Submit the selection made
- Navigate to http://jqueryui.com/droppable
- Use ActionChains to drag and drop elements by offset or from a source to a target
- Go to https://wiki.python.org/moin/FrontPage
- Perform a Search for the text Beginner
- In the left side menubar, change the value of the select from 'More Options' to 'Raw Text'
- Navigate to http://www.python.org
- Add an explicit wait of 10 seconds for the element with id start-shell
- Navigate to http://www.python.org
- Add an implicit wait of 10 seconds for the element with id start-shell