Selenium webdriver drop-down box processing method

Source: Internet
Author: User

1. There are 2 kinds of drop-down boxes, 1 of which can be positioned to the entire drop-down box via F12, and the code HTML to navigate to
<select id= "Ctl00_maincontentplaceholder_noticemanage1_ddlnoticetype" class= "select" Name= "ctl00

$MainContentPlaceHolder $noticemanage1$ddlnoticetype ">
<option value= "0" > Please select </option>
<option value= "8" > Important News </option>
<option value= "9" > Securities News </option>
<option value= "Ten" > Competition rules </option>
<option value= "One" >21212</option>
</select>
In this case, you need to point to the drop-down box and assign a variable, and then use XPath to get the element under the variable and click it, such as:
Se=driver.find_element_by_name ("Ctl00$maincontentplaceholder$ddlmarketindustryreturnindex")
Se.find_element_by_xpath ("//option[@value = ' 3 ']"). Click () 2. Another situation is to be able to navigate to the drop-down button, you need to first navigate to the drop-down button by F12 and click, Then navigate to the optional element via F12 and click
Such as:
Driver.find_element_by_xpath ("//*[@id = ' valide-form ']/tbody/tr[3]/td[2]/span/span/span"). Click () #报价方式下拉按钮
Driver.find_element_by_xpath ("/html/body/div[2]/div/div[2]"). Click () #限价委托

Selenium webdriver drop-down box processing method

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.