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