Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

406
Visualizações
Selenium (python) to select an item in dropdown menu

I am trying to use Selenium in python to select an item "Custom date" in the following dropdown menu: enter image description here

This is how the structure of divs looks like: enter image description here

I try to first select the topmost div with Selenium (python) and then progress down by clicking all the way to "Custom date" (see code below). However, I get the following error in the last line of code when I try to do that:

"ElementNotInteractableException: Message: element not interactable"

My attempt to click the desired field:

time.sleep(2)
element=chrome.find_element_by_xpath("//div[@class='Inputreact__StyledContainer-sc-3dr67n-0 iAeYiQ Selectreact__SelectInput-sc-1shssly-0 cJLIjY' ]")
element.click()
chrome.execute_script("arguments[0].click();", element)
element=chrome.find_element_by_xpath("//input[@value='7 days']")
chrome.execute_script("arguments[0].click();", element)
element=chrome.find_element_by_xpath("//input[@value='Custom date']")
chrome.execute_script("arguments[0].click();", element)

EDIT: I want to provide a bit more detail. In the case of user MANUALLY using the dropdown menu, the behavior below happens (note what the relevant divs are in the picture). I am stumped because selenium clicking on the div that ends in ePfTsZ DOES NOT EXPAND the dropdown menu, as happens when user manually does it in the browser.

enter image description here

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

In this case you need to use the Select class, will look something like this:

from selenium.webdriver.support.select import Select

selection = Select(chrome.find_element_by_xpath(
    "//div[@class='Inputreact__StyledContainer-sc-3dr67n-0 iAeYiQ Selectreact__SelectInput-sc-1shssly-0 cJLIjY' ]"))

After this you can select any item of the dropdown by index or by visible text.

selection.select_by_index(1)

or

selection.select_by_visible_text("A month")
about 4 years ago · Santiago Trujillo Relatório

0

If you want to go through all the option of the dropdown, then run a loop on index.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda