vendredi 14 septembre 2018

Trying to get sql query parameter and automate script

i am using selenium and java.1.every time when I execute my test is hast to create new log in credentials

2.I enter usernames (everytime it is created randomly) This my method to create unique username

    String username=’’ ’’ +(int)(Math.random()*Integer.MAX_VALUE);
    String emailID=”USER”+username+”@gmail.com”;
    driver.findElement(by.id(“userNameID)).sendKeys(emailID);
    system.out.println(emailID);

It creates unique username

3.After it will ask for verification code it is coming from DB and I have to pass it in “verification textbox” I have my JDBC Connections, Usually when I already know my username I use :

   String query=”Select SecretCode from createlogincode where 
   username=qacustomer@gmail.com”;
   String secretCode=rs.getString(1);
   System.out.println(“Verification Code is ”+secretCode);
   driver.findElement(by.id(“secretcode”)).sendKeys(secretCode);

and this methods works perfectly, But with creating randomly username I am not able to write correct query to pass and get verification code.Is there is any methods maybe to store new username then pass it into the query. I was doing

     String query=”Select SecretCode from createlogincode where username= 
 +emailID”;

but this is absolutely incorrect

Aucun commentaire:

Enregistrer un commentaire