Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

408
Views
Selenium (python) para seleccionar un elemento en el menú desplegable

Estoy tratando de usar Selenium en python para seleccionar un elemento "Fecha personalizada" en el siguiente menú desplegable: ingrese la descripción de la imagen aquí

Así es como se ve la estructura de divs: ingrese la descripción de la imagen aquí

Intento seleccionar primero el div superior con Selenium (python) y luego avanzar hacia abajo haciendo clic en "Fecha personalizada" (ver el código a continuación). Sin embargo, aparece el siguiente error en la última línea de código cuando intento hacer eso:

"ElementNotInteractableException: Message: element not interactable"

Mi intento de hacer clic en el campo deseado:

 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)

EDITAR: Quiero proporcionar un poco más de detalle. En el caso de que el usuario use MANUALMENTE el menú desplegable, ocurre el siguiente comportamiento (observe cuáles son los divs relevantes en la imagen). Estoy perplejo porque el selenio al hacer clic en el div que termina en ePfTsZ NO EXPANDE el menú desplegable, como sucede cuando el usuario lo hace manualmente en el navegador.

ingrese la descripción de la imagen aquí

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

En este caso, debe usar la clase Select, se verá así:

 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' ]"))

Después de esto, puede seleccionar cualquier elemento del menú desplegable por índice o por texto visible.

 selection.select_by_index(1)

o

 selection.select_by_visible_text("A month")
about 4 years ago · Santiago Trujillo Report

0

Si desea revisar todas las opciones del menú desplegable, ejecute un ciclo en index.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!