Common WebDriver operations controlled by Python scripts & lt; 8 & gt; simple object locating

Source: Internet
Author: User

The content in this part will be a demonstration of the positioning Element Method in WebDriver, which is a combination of methods used in the WebDriver of Selenium element locating command.

For a review of element locating methods in Selenium, refer:

 

 

The positioning and operation of the test object is the core content of webdriver, and the operation is based on the positioning, so object positioning becomes more and more important.

Objects are usually located for the following purposes:

  • Operation object
  • Obtains the attributes of an object, such as the class attribute and name attribute of the test object.
  • Obtain the text of an object
  • Get the number of objects

Webdriver provides a series of object locating methods, which are commonly used in the following scenarios:

  • Id
  • Name
  • Class name
  • Link text
  • Partial link text
  • Tag name
  • Xpath
  • Css selector

The HTML code used for locating the example is as follows:

                  Form                                 simple login form                        Email                                                          Password                                                                                                Sign in            register                              

 

 

The Python script is as follows:

 

 selenium  time    os.environ:  os.environ[== + os.path.abspath(dr.find_element_by_id(dr.find_element_by_name(dr.find_element_by_tag_name().get_attribute(e = dr.find_elements_by_class_name(5link = dr.find_element_by_link_text(5link = dr.find_element_by_partial_link_text(5div = dr.find_element_by_css_selector(55

 

Related Article

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.