Simple Object Positioning

Source: Internet
Author: User

Simple Object Positioning:

Webdriver provides a range of element positioning methods, which are commonly used in the following ways:

    • Id
    • Name
    • Class name
    • Tag name
    • Link text
    • Partial link text
    • Xpath
    • CSS Selector

The methods that correspond to Python webdriver are:

FIND_ELEMENT_BY_ID ()
Find_element_by_name ()
Find_element_by_class_name ()
Find_element_by_tag_name ()
Find_element_by_link_text ()
Find_element_by_partial_link_text ()
Find_element_by_xpath ()
Find_element_by_css_selector ()

1) ID and name locator:

ID and name are our most common targeting methods, because most elements have these two properties, and in the ID and name of the control
Naming usually makes it meaningful and takes a different name. These two properties make it fairly easy for us to find properties on a page.

HTML code:


<input id= "gs_htif0" class= "Gsfi" aria-hidden= "true" dir= "ltr" >
<input type= "Submit" Name= "BTNK" jsaction= "Sf.chk" value= "Google Search" >
<input type= "Submit" Name= "Btni" jsaction= "Sf.lck" value= "Good luck" >


The element is positioned with the ID and name attribute in the element:

Id= "Gs_htif0"
find_element_by_id ("gs_htif0")


Name= "BTNK"
Find_element_by_name ("BTNK")

Name= "Btni"
Find_element_by_name ("Btni")

Simple Object Positioning

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.