繁体   English   中英

硒 - 下拉 - python

[英]selenium - drop down - python

<input id="clusteredDownloadButton" name="clusteredDownloadButton" type="submit" value="Download" onclick="submitForm('download',1,{source:'clusteredDownloadButton'});return false;" class="submit">

xpath: //*[@id="downloadClusterSelectOneChoice"]

<option value="">Select One</option>
<option value="0">PSI-MITAB 2.5</option>

xpath: //*[@id="downloadClusterSelectOneChoice"]/option[2]

所以我需要选择 PSI-MITLAB 2.5 选项并下载这种类型的文档

<input id="clusteredDownloadButton" name="clusteredDownloadButton" type="submit" value="Download" onclick="submitForm('download',1,{source:'clusteredDownloadButton'});return false;" class="submit">

xpath: //*[@id="clusteredDownloadButton"]

我从网上找到的任何东西都尝试了很多东西,它一直给我一个错误。 请帮忙!

尝试的代码:

代码#1

driver.find_element_by_xpath('//*[@id="downloadClusterSelectOneChoice"]').click()
driver.select_by_visible_text("PSI-MITAB 2.5")

代码#2

driver.find_element_by_xpath('//*[@id="downloadClusterSelectOneChoice"]').click()
driver.find_element_by_xpath('//*[@id="downloadClusterSelectOneChoice"]/option[2]').click()

代码#3

dropdown = driver.find_element_by_xpath('//*[@id="downloadClusterSelectOneChoice"]')
dropdown.select_by_value('PSI-MITAB 2.5')

代码#4

dropdown = driver.find_element_by_xpath('//*[@id="downloadClusterSelectOneChoice"]/option[2]')
dropdown.select_by_value('PSI-MITAB 2.5')

他们都不断抛出错误!

使用select_by_valueselect_by_index

dropdown = driver.find_element_by_xpath(dropdown_xpath)
dropdown.select_by_value('PSI-MITAB 2.5')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM