Soumya Sankar
Soumya Sankar

Reputation: 1

sendKeys is not entering the complete input all the time

I have written my script in Java and it is running in Chrome browser. I have a username field, password field and a login button. Even before completing the entry in username field, it is started performing action on password field/login button.

Here is my code,

driver.findElement(By.name("data[Student][email]")).sendKeys("[email protected]");                   
driver.findElement(By.name("data[Student][password]")).sendKeys("abc123");                
driver.findElement(By.xpath("//*[@class='btn btn-large btn-primary']")).click();

Upvotes: 0

Views: 207

Answers (2)

Shweta Bet
Shweta Bet

Reputation: 41

Try to use implicit wait as per below :

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

Upvotes: 1

Master Slave
Master Slave

Reputation: 28519

Try slowing down the execution by adding some sleep in between, something like

Thread.sleep(1000);
driver.findElement(By.name("data[Student][email]")).sendKeys("[email protected]");      
Thread.sleep(1000);             
driver.findElement(By.name("data[Student][password]")).sendKeys("abc123");                
Thread.sleep(1000);
driver.findElement(By.xpath("//*[@class='btn btn-large btn-primary']")).click();

Upvotes: 1

Related Questions