I have been using thread.sleep(9000) almost after every line of code in selenium which is making me wait for long.Can anybody suggest me an alternate way to reduce this.As my application is taking time load a page it needs to wait until a particular page is loaded to perform any action.
WebElement un = driver.findElement(By.id("login_username_id"));
un.sendKeys(username);
WebElement pwd = driver.findElement(By.id("login_password_id"));
pwd.sendKeys(password);
try {
Thread.sleep(25000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
driver.findElement(By.id("login_submit_id")).click();
try {
Thread.sleep(9000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Я хочу сократить использование thread.sleep после каждой строки и использовать одну общую функцию, чтобы она ждала, когда это необходимо.