Python+selenium Study Notes 4

Source: Internet
Author: User

1.submit ()

The Submit () method is used to submit the form. You can use the Submit () method to simulate a query after entering a keyword in the search box and pressing ENTER. If you cannot press ENTER to enter the next step, you cannot use the submit () example, Baidu query submission.

1  fromSeleniumImportWebdriver2 3Dr =Webdriver. Firefox ()4Dr.get ("http://www.baidu.com")5 6DR.FIND_ELEMENT_BY_ID ("kw"). Send_keys ("Selenium")7DR.FIND_ELEMENT_BY_ID ("kw"). Submit ()8Dr.close ()

Submit () can be swapped with Click (), but click () is more widely used

2.get_attribute ()

Gets the attribute value of the element

1  fromSeleniumImportWebdriver2 3Dr =Webdriver. Firefox ()4Dr.get ("http://www.baidu.com")5 6ATTR1 = dr.find_element_by_id ("kw"). Get_attribute ("ID")7 Print("attr1 =%s"%attr1)8ATTR2 = dr.find_element_by_id ("kw"). Get_attribute ("name")9 Print("attr2 =%s"%attr2)TenATTR3 = dr.find_element_by_id ("kw"). Get_attribute ("class") One Print("ATTR3 =%s"%ATTR3) AATTR4 = dr.find_element_by_id ("kw"). Get_attribute ("value") - Print("ATTR4 =%s"%ATTR4) -Dr.close ()

Python+selenium Study Notes 4

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.