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

341
Visualizações
how to select select in a form using selenium in javascript

I'm automating some tests of a process that contains a form where I'm able to get all the steps, but when I get to the select, I can't make it automate for him to click and choose the option I want in javascript.

my code;

    const {Builder, By, Key} = require("selenium-webdriver");

      async function example() {

        // launch the browser
        let driver = await new Builder().forBrowser("chrome").build();
        // navigate to our application
        await driver.get("https://dev.septemcompliance.com/designer/design.aspx? 
        c=0asrnQyA%2bharoubJy0g6zqq%2fVssaPaDM6m0yv7hD0hTwY8bXo%2bNQLRsUzDolSOAT")
        // add a todo
        await driver.findElement(By.id("TxtLogin")).sendKeys("joao")
        await driver.findElement(By.id("TxtPassword")).sendKeys("010445jv")
        await driver.findElement(By.id("BtnLogin")).click()
        await driver.findElement(By.id("HlOpenSimulation")).click()
        await driver.findElement(By.id("HlStartSimulation")).click()
        await driver.findElement(By.name("inp12082")).click();
        await driver.findElement(By.xpath("//* 
        [@id=td1secretaria_municipal]/select/option[1]")).click();

      }
      example()

In the inspection of the select code that I want to automate, this is code on the website.

<select label="Secretaria municipal" name="inp12082" xname="inpsecretaria_municipal" 
        xtype="SELECT" required="S" style="width:350px" 
onchange="controlValueChange(this);salvarSecretaria($(this));atualizarSecretariasExecutivas();" 
             data-c="DSe28HiL3BwUi7ITIAiFKoPYC2jIQnf-1ElLrN9eVsFFzP- 
             O91XnU@emdmWvie5Aqx3Arj6ROWUKqAGZrCQsDjwO5geI9nuTiU9JlTlMz2hbH5D3M1D-E5loLjoTSRcU">
  <option value="">Selecione</option><option value="1">SECRETARIA 1</option>
</select>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If I understood the problem correctly you just need a simply css selector and then use the click method.

<select>
  <option value="1" selected="selected">one</option>
  <option value="2">two</option>
</select>
const element = await driver.findElement(By.css('select option[value="2"]'));
await element.click();
about 4 years ago · Juan Pablo Isaza 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