html - Find element by xpath selenium web driver -
i have webpage:
<div class="formfonttitle">wireless - general</div> <div style="margin-left:5px;margin-top:10px;margin-bottom:10px"><img src="/images/new_ui/export/line_export.png"></div> <div class="formfontdesc">set wireless related information below.</div> <table width="99%" border="1" align="center" cellpadding="4" cellspacing="0" id="wlgeneral" class="formtable"> <tr id="wl_unit_field"> <th>frequency</th> <td> <select name="wl_unit" class="input_option" onchange="_change_wl_unit(this.value);"> <option class="content_input_fd" value="0" >2.4ghz</option> <option class="content_input_fd" value="1" selected>5ghz</option> </select> </td> </tr>
i trying select "2.4ghz" using xpath. default "5ghz" option selected. doing python script , using selenium webdriver.
i doing this:
elements = mydriver.find_element_by_xpath("//div[@class='wl_unit']") title = elements[1].find_elements_by_xpath(".//div[@class='content_input_fd']")
but it's not working.
you can use following xpath find 2.4ghz option element, , peform 'click' on element selected :
option = mydriver.find_element_by_xpath("//select[@name='wl_unit']/option[@value='0']") option.click()
Comments
Post a Comment