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

150
Visualizações
Random values ​in selenium

I'm new to Selenium, and I can't quite figure out how to insert random values to a Send.Key in a findElement. I'm using Selenium web driver with Java.

Here's my code:

driver.findElement(By.id("id1")).click();
    {
        int T;
        double M=0;
        boolean S = true;
        boolean x = false;
        double p = 1;
        for (T = 0; T == (int) Math.floor(T / 10);)
            p = (p + T % 10 * (9 - M++ % 6)) % 11;
        //return S?S-1:'k';


        alert(x ? p - 1 : 'k');

        double alert;
        driver.findElement(By.id("id1")).sendKeys(alert);

    }

Could someone tell me how to do this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

driver.findElement(By.id("id1")).click();       


 String Capital_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            String Small_chars = "abcdefghijklmnopqrstuvwxyz";
            String numbers = "0123456789";
    int length = 8; // You can change the lenght of the random string as per your requirement
    String values = Capital_chars + Small_chars + numbers ;
            Random randomGenerator = new Random();  
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < length; i++) {
    
                  // generate random index number
                  int index = randomGenerator.nextInt(values.length());
    
                  // get character specified by index
                  // from the string
                  char randomChar = values.charAt(index);
    
                  // append the character to string builder
                  sb.append(randomChar);
                }
            System.out.println("sb===="+sb.toString()); 

driver.findElement(By.id("id1")).sendKeys(sb.toString());
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