Web Automation Test Tool--selenium

Source: Internet
Author: User
Tags selenium python

In the recent web course design I have come into contact with the Selenium Web Automation test tool, which can be used to navigate to the target element through a series of find_element () methods, and to send an analog key operation to automate the operation.


First, use Pip to install the Selenium Python module.

Here are the routines I wrote. The Find_element_by_name method is to locate the element through the Name property and then send the analog key via Send_keys (). Based on this kind of operation can basically complete a variety of web simulation operations.

Import timefrom Selenium import webdriverfrom selenium.webdriver.common.keys import Keyschrome_driver_path = "/usr/ Local/lib/python2.7/dist-packages/selenium/webdriver/chrome/chromedriver "Driver = webdriver. Chrome (Chrome_driver_path) driver.get ("Http://localhost:8000/") driver.get ("Http://localhost:8000/login") assert " Bookstore "In driver.titleelem_username = Driver.find_element_by_name (" username ") Elem_username.send_keys (" Tiger1 ") Elem_password = driver.find_element_by_name ("password") Elem_password.send_keys ("Tiger1") Elem_password.send_keys ( Keys.return) Time.sleep (5) Driver.close ()



If you encounter the following error

Selenium.common.exceptions.WebDriverException:Message: ' Chromedriver executable needs to being available in the path.

Workaround in Http://selenium-python.readthedocs.org/faq.html#how-to-use-chromedriver

Web Automation test Tool--selenium

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.