Wait for page load in Selenium
I am new to coding and Automation testing. All I know in coding is if-else
, while
, do while
and for
, etc. Minor stuffs like that. The above is the link which I tried to checkout to make Selenium wait for a while, but couldn't make it happen.
The below is the following code that I have written in order to login to my gmail account but isn't working. Can anyone correct the code?
I think I need to delay the action of selenium and let the page loads first.
public class loginGmail {
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver", "E:\\eclipse\\Drivers\\geckodriver.exe");
FirefoxDriver d = new FirefoxDriver();
d.get("https://www.gmail.com");
d.findElement(By.id("Email"));
WebElement email = d.findElement(By.id("Email"));
email.sendKeys("[email protected]");
d.findElement(By.name("signIn"));
WebElement next = d.findElement(By.name("signIn"));
next.click();
d.findElement(By.id("Passwd"));
WebElement pass = d.findElement(By.id("Passwd"));
pass.sendKeys("********");
d.findElement(By.id("signIn"));
WebElement signIn = d.findElement(By.id("signIn"));
signIn.click();
}
}
This is a known bug in geckodriver. To get around it for now, use explicit waits