Automated test Selenium----CSS Selector summary

Source: Internet
Author: User

Selector Selector Example Describe
* * Match any element
Element Div Tag selector that matches all elements that use div tags
. class . Tips Class selector that matches all elements of the class attribute that contain info. A.B matches elements that contain both A and B
#id #username An ID selector that matches an element with an id attribute of username
Element,element Div,span Multi-element Selector, select all div and span complete, use, separate
Element element DIV SPAN Descendant Meta selector that matches all of the div's span descendant elements, separated by spaces in the middle
Elemen> telement Div>span child element Selector, matching the span child elements of all div, middle use > delimited
elemen+ telement Div+span Adjacent to the element selector, matching the sibling span element immediately following the DIV (only one) is not necessarily one behind the same div
Elemen~ telement DIV~SPAN A sibling element selector that matches the sibling span elements behind all the div, and can be separated by other elements
[Attribute] [ATT] All elements containing the ATT attribute
[Attribute=vlaue] DIV [att= ' Val '] Match all the att attributes of the div element to Val
[attribute^=vlaue] [Attribute|=vlaue] DIV[att^= ' val '] A DIV element that matches all ATT attributes starting with Val w3s is used |
[attribute$=vlaue] DIV[att$= ' val '] Match all ATT attributes to the div element ending in Val
[Attribute*=vlaue] [Attribute~=vlaue] DIV[att*= ' val '] Match all att attributes containing the div element of Val
[attr1=vla1] [attr2*=VLA2] DIV [att1= ' v1 '][att2*= ' v2 '] Match all att attributes to v1,att2 attribute contains v2 div element
[attr1=vla1], [attr2*=VLA2] DIV [att1= ' v1 '],[att2*= ' v2 '] Ibid. or relationship
: Link A: Link Select all links that have not been visited
: Visited A: Visited Select all links that have been visited
: Active A: Active Select all active Links
: hover A: hover Select the link where the mouse pointer is located
: Focus Input: Focus Select the input element that gets focus
: First-child P:first-child Select all p elements that conform to the following rules, and P must be the first child of its parent element
: Last-child P:last-child Select all p elements that conform to the following rules, and P must be the last child of its parent element
: First-of-type P:first-of-type Select the collection of the first p child element of the parent element, and the first-child difference is that the first child element of the parent element may not be preceded by a non-P element
: Last-of-type P:last-of-type Select the collection of the last p child element of the parent element, and the last-child difference is that it can be followed by a non-p element, not necessarily the last child element of the parent element
: Only-of-type P:only-of-type Select a collection of only a single p child element of the parent element
: Nth-child (N) P:nth-child (2) Select each <p> element that belongs to the second child element of its parent element
: Nth-last-child (N) P:nth-last-child (2) Ibid., counting from the last element
: Nth-of-type (N) P:nth-of-type (2) Select the collection of the second p child element of the parent element, and : Nth-child (n) The difference is that you can have a non-P element before and after it, not necessarily the second child element of a parent element
: Nth-last-of-type (N) P:nth-last-of-type (2) Ibid., counting from the last element
: Root : Root Select the root element of the document
: Empty P:empty Select a P element with no child nodes to contain a text node
: Enabled Input:enabled Select each INPUT element that is enabled
:d isabled Input:disabled Select each of the disabled input elements
: Checked Input:checked Select each input element that is selected
: Not (selector) : Not (P) Select all non-P elements
Selenium is used in the The CSS3 from Sizzle. Positioning the extension, its syntax is more flexible and understandable.
: Nth (N): eq (n) Li:nth (2) Li:eq (2) with : Nth-child (N), but starting from 0
: First Li:first Same as : First-child
: Last Li:last Same as : Last-child
: Even Li:even A collection of even digits in the collection of Li child elements in its parent element
: Odd Li:odd The collection of odd digits in the collection of Li child elements in its parent element
: LT (N) LI:LT (2) A collection of all elements that precede the nth bit in the collection of Li child elements in its parent element (n is not included), and N starts at 0
: GT (N) LG:LT (2) A collection of all elements (without n) in the collection of Li child elements in its parent element that follows the nth bit, starting with n 0
: Only-child Div:only-child Same as: Only-of-type
: Empty P:empty Same CSS native selector : Empty
: input : input Gets the elements of all input types (including input, select, textarea)
: Text,: checkbox,: File,:p Assword,: Submit,: Image,: Reset,: Button ... Gets the element of the specified type

Automated test Selenium----CSS Selector 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.