Css_selector Positioning Summary

Source: Internet
Author: User
Tags tag name

css_selector Positioning detailed

Driver.find_element_by_css_selector ()

CSS positioning can be divided into four categories: ID, class, other attributes, paths.

1 #id方式

Either way, you can add the tag name to the front, or you can add

Driver.find_element_by_css_selector (' #id_value ')

Driver.find_element_by_css_selector (' Tag_name#id_value ')

2. Class Mode

Two ways, plus tag name, can also not add. If the tag name is not added, the point cannot be omitted.

Driver.find_element_by_css_selector ('. Class_value ')

Driver.find_element_by_css_selector (' Tag_name.class_value ')

Some class_value longer, and there are spaces in the middle, you cannot write the space as it is, so it cannot be recognized. At this point, the space with a dot instead, the front to add tag_name.

Driver.find_element_by_css_selector (' Div.panel.panel-email '). Click ()

3 other attribute modes

Either way, you can add the tag name to the front or not.

Driver.find_element_by_css_selector ("[Attri_name= ' Attri_value ']")

Driver.find_element_by_css_selector ("input[type= ' password ')"). Send_keys (' I want to learn from the Internet ')

Driver.find_element_by_css_selector ("[type= ' password ']"). Send_keys (' I want to learn from the Internet ')

1.3.4 Path Method

Either way, you can add the tag name to the front or not. Note that its hierarchical relationship uses the greater than sign ">".

Driver.find_element_by_css_selector ("form#loginform>ul>input[type= ' password ')"). Send_keys (' 111222333 ')

Transferred from: https://www.cnblogs.com/yahutiaotiao/p/8044849.html

Css_selector Positioning Summary

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.