这是我的测试 HTML:
<tr>
<td >
<select>
<option selected="selected" value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
</tr>
我的代码就像
select_el=driver.find_element_by_xpath("//select")
Select(el_select).select_by_visible_text('1')
没有错误消息,但选项值没有改变?任何人都可以给我一些建议吗?
以本网站为例:https ://www-01.ibm.com/products/hardware/configurator/americas/bhui/launchNI.wss
driver.get("https://www-01.ibm.com/products/hardware/configurator/americas/bhui/launchNI.wss")
driver.find_element_by_id("modelnumber").send_keys('7383AC1')
driver.find_element_by_name("submit").click()
el_inputs=driver.find_elements_by_name('CID_CONTROL_VideoAdapter_MultiSelect')
FC='A1QU'
for el_input in el_inputs:
el_td=el_input.find_element_by_xpath("..")
if FC in el_td.get_attribute('innerHTML'):
print el_td.get_attribute('innerHTML')
el_tr=el_td.find_element_by_xpath("..")
el_select=el_tr.find_element_by_xpath("//select")
Select(el_select).select_by_visible_text('1')