[英]selenium - drop down - python
<input id="clusteredDownloadButton" name="clusteredDownloadButton" type="submit" value="Download" onclick="submitForm('download',1,{source:'clusteredDownloadButton'});return false;" class="submit">
the xpath: //*[@id="downloadClusterSelectOneChoice"] xpath: //*[@id="downloadClusterSelectOneChoice"]
<option value="">Select One</option>
<option value="0">PSI-MITAB 2.5</option>
the xpath: //*[@id="downloadClusterSelectOneChoice"]/option[2] xpath: //*[@id="downloadClusterSelectOneChoice"]/option[2]
so i need to select the PSI-MITLAB 2.5 option and the download this type of document所以我需要选择 PSI-MITLAB 2.5 选项并下载这种类型的文档
<input id="clusteredDownloadButton" name="clusteredDownloadButton" type="submit" value="Download" onclick="submitForm('download',1,{source:'clusteredDownloadButton'});return false;" class="submit">
the xpath: //*[@id="clusteredDownloadButton"] xpath: //*[@id="clusteredDownloadButton"]
I tried a lot of things from whatever I found online, it keeps giving me an error.我从网上找到的任何东西都尝试了很多东西,它一直给我一个错误。 Please help!请帮忙!
attempted code:尝试的代码:
code#1代码#1
driver.find_element_by_xpath('//*[@id="downloadClusterSelectOneChoice"]').click()
driver.select_by_visible_text("PSI-MITAB 2.5")
code#2代码#2
driver.find_element_by_xpath('//*[@id="downloadClusterSelectOneChoice"]').click()
driver.find_element_by_xpath('//*[@id="downloadClusterSelectOneChoice"]/option[2]').click()
code#3代码#3
dropdown = driver.find_element_by_xpath('//*[@id="downloadClusterSelectOneChoice"]')
dropdown.select_by_value('PSI-MITAB 2.5')
code#4代码#4
dropdown = driver.find_element_by_xpath('//*[@id="downloadClusterSelectOneChoice"]/option[2]')
dropdown.select_by_value('PSI-MITAB 2.5')
all of them keep throwing an error!他们都不断抛出错误!
Use select_by_value
or select_by_index
.使用select_by_value
或select_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.