Selenium solution for Webdriver recognition of class attributes with spaces in multiple values

Source: Internet
Author: User

Beginners automated testing, it seems that everyone is nine out of ten are using Baidu website practiced hand, hereby thank Baidu.

The main http://www.baidu.com page is the search box and the Submit button:

Input box element properties: <input id= "kw" Name= "wd" class= "S_ipt" value= "" maxlength= "255" autocomplete= "Off" >

Main attributes include ID, name, class, etc.

Submit Button "Baidu" element properties: <input id= "su" value= "Baidu a Bit" class= "BG s_btn" type= "Submit" >

This includes the following: ID, class attribute (the value of the class attribute is included with a space, need to be processed)

The following workarounds are available:

1         #self.browser.find_element_by_class_name ("BG s_btn"). Submit () #使用class_name会报错2Self.browser.find_element_by_class_name ("s_btn"). Submit ()#First Solution: Class value one of them3Self.browser.find_element_by_class_name ("BG"). Submit ()#First Solution: Class value one of them4Self.browser.find_element_by_css_selector (". Bg.s_btn"). Submit ()#Second workaround: Use Css.selector, preceded by each class value.5Log.info ("identify the Name property and execute [find_element_by_name]")

Mark

Selenium solution for Webdriver recognition of class attributes with spaces in multiple values

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.