簡體   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