Good afternoon, I’m a python beginner and tried several ways to use the select option but I did not succeed because he insists that the button is not visible or can not interact with it, but with the following code I was able to type the two options in the field and select them:
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.keys import Keys
url = "https://www.viprbrc.org/brc/vipr_genome_search.spg?method=ShowCleanSearch&decorator=flavi_dengue"
browser = webdriver.Chrome()
browser.get(url)
sleep(3)
browser.find_element_by_xpath('//div[@id="hosts"]').click()
input_field = browser.find_element_by_xpath('//input[@value="Choose a Host..."]')
hosts = ['Human', 'Mosquito']
for value in hosts:
input_field.send_keys(value)
input_field.send_keys(Keys.ENTER)
First of all I clicked on the div hosts and with it using : Selenium.webdriver.common.Keys I sent the texts Human and Mosquito to the input field pressing Enter right after, apparently something hides the actual selection.
EDIT
The problem of not being able to select select I believe it is because it is with the "display-style: None", even if I run to change it to "block" it can not make the selection, looking better the source saw that the selection actually occurs here:
What you can see with this code:
from selenium import webdriver
from time import sleep
url = "https://www.viprbrc.org/brc/vipr_genome_search.spg?method=ShowCleanSearch&decorator=flavi_dengue"
browser = webdriver.Chrome()
browser.get(url)
sleep(3)
menu = browser.find_element_by_xpath('//div[@id="hosts"]')
menu.click()
hosts = menu.find_elements_by_xpath('//div/ul/li[@class="active-result"]')
for value in hosts:
if value.text == 'Human':
value.click()
else:
pass
In this second example you would need only change to click the two values