Xpath positioning and positioning difference CssSelector

1, Xpath basic syntax:

(1) "/": Select from the root node, lower node

(2) "//": Select any node

(3) "*": Select any tab

(4) "!": Select Properties

(5) "..": select the parent node of the current node

(6) "text ()": all matching nodes link text

(7) "contains (a, b)": link text part matched node

(8) "last ()" to select the last

2, Xpath and Css Selector difference:

Targeting Xpath Css Selector
find_element_by_id("id值") //*[@id="id值"] #id value
find_element_by_name("name值") //*[@name="name值"] [name="name值"]
find_element_by_class_name ( "one class name") One class name . A certain class name
find_element_by_tag_name ( "tag name") // tag name Label name
find_element_by_link_text ( "link text") // a [text () = "Link Text"] not support
find_element_by_partial_link_text ( "part of the link text") // a [contains (text (), "part of the link text")] not support

Guess you like

Origin www.cnblogs.com/confidencegirl/p/11529571.html