CSS positioning of Selenium+python automation

Source: Internet
Author: User
Tags xpath

First, CSS: property positioning

The 1.CSS can bedirectly anchored to the three general properties of the element's ID,class, and tag.

2. The following is the HTML code of the Baidu input box :

<input id= "kw" class= "S_ipt" type= "text" autocomplete= "Off" maxlength= "+" name= "wd"/>

3.css uses the # sign for label Properties , such as:#kw

for 4.css. represents The class attribute, such as:. S_ipt

5.css directly with the label name, without any identifiers, such as:input

Second, CSS: Other Properties

1.css In addition to the label,class,ID, the three general properties can be located outside, but also through other properties to locate

2. The following are the formats for locating other properties

Third, CSS: label

a 1.css page can be used to position elements by combining labels with attributes

Four, CSS: Hierarchical Relationships

1. in the previous XPath , we talked about hierarchical relationship positioning, where CSS can achieve the same effect

2. such as XPath://form[@id = ' form ']/span/input and //form[@class = ' FM ']/span/input can also be used CSS Implementation

Five, CSS: Index

1. as an example, follow the previous article

2.css can also be indexed by the option:nth-child (1) to locate the child element, which is the XPath The wording is very different, in fact, very good understanding, direct translation came to the first few children

Six, CSS: Logical Operations

1.css can also implement a logical operation, matching two properties, which is not the same as XPath, no need to write the and keyword

Seven, CSS: Fuzzy Matching

1.css Fuzzy matching contains (' xxx '), although the Internet with a variety of data display can be used, but the small part of the test in person, has been an error.

2. after the various Baidu found the answer: youcan ' t does this with the CSS selectors, because there is the no such Thing As:contains () in CSS. It was a proposal the was abandoned years ago. Unfortunately, this syntax has been abandoned, so there is no further research.

CSS positioning of Selenium+python automation

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.