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

343
Visualizações
Cannot Select Option from Dropdown Menu in Selenium WebDriver using Javascript

I'm trying to select option from a dropdown menu by visible text using Javascript Executor:

JavascriptExecutor executor = (JavascriptExecutor)driver;
        
executor.executeScript("var select = arguments[0]; for(var i = 0; i < select.options.length; i++){ if(select.options[i].text == arguments[1]){ select.options[i].selected = true; } }", element, visibleText);

Although the code above does not throw an exception, the desired option is not selected (the default option remains selected). I am unable to select option using the native Selenium WebDriver Select class because there's a permanent overlay over the element. I tried hiding the permanent overlay with JS as suggested in this response but since the targeted element is a descendant of the overlay element if I hide the overlay element it automatically hides the targeted element too.

Why isn't the JS code selecting the desired option? Is there any other way to select option from drop down via JS/Javascript Executor that might work?

about 4 years ago · Juan Pablo Isaza
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