[英]How to select item from drop down menu using Selenium with Python?
[英]Select drop down menu with input using Selenium
I'm trying to select a year in the dropdown menu in this web page: https://servicio.indecopi.gob.pe/buscadorResoluciones/competencia_elim_barrer_buroc.seam I was using Select, but it doesn't work:
Select(driver.find_element_by_xpath('//*[@id="FormListado1:cmd_vc_distcomboboxButton"]'))
它有下一個錯誤: Select only works on <select> elements, not on <input>
。 你知道我怎么可以 select 這個輸入元件嗎?
這不是 Select 而不是輸入元素,因此要打開下拉菜單,您可以使用以下命令:
driver.find_element_by_xpath('//input[contains(@id,"PrimeraNormalcomboboxButton")]').click()
現在您可以 select 像這樣打開菜單中的任何項目:
driver.find_element_by_xpath('//span[@class="rich-combobox-item" and text()="2015"]').click()
只需使用正確的年份值。
不要忘記添加等待/延遲。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.