Selenium grab elements exclude a specific class tag

Source: Internet
Author: User
Tags xpath

Exclude a factor, the first preferred to think of regular expression, helpless toss half a day without success, feeling is selenium on the elements of Attrs press re search in action, $ on the end of the string detection is useless.

The beautifulsoup can be detected using the class of the output element of the element[' class '), but the BeautifulSoup object is no longer in the click Operation and does not meet expectations . Selenium does not have such a syntax and is selected through XPath:

ItemList = Driver.find_elements_by_xpath ('//div[@id = "Choose-color"]//div[@class = "dd"]//div[not (Contains (@class, " Disabled "))]

StackOverflow has a reference: Http://stackoverflow.com/questions/11024080/how-to-use-not-contains-in-xpath


Supplemental XPath usage:

Xpath=xpathexpression:locate an element using an XPath expression.  xpath=//img[@alt = ' The image alt text '] xpath=//table[@id = ' table1 ']//tr[4]/td[2] xpath=//a[contains (@href, ' #id1 ')] Xpath=//a[contains (@href, ' #id1 ')]/@class xpath= (//table[@class = ' Stylee '])//th[text () = ' Theheadertext ']/. /td xpath=//input[@name = ' name2 ' and @value = ' yes '] xpath=//*[text () = "Right"]


Selenium grab elements exclude a specific class tag

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.