How can I ask the Selenium-WebDriver to wait for few seconds in Java?

0
0

I’m working on a Java Selenium-WebDriver. I added

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

and

WebElement textbox = driver.findElement(By.id("textbox"));

because my Applications takes few seconds to load the User Interface. So I set 2 seconds implicitwait. but I got unable to locate element textbox

Then I add Thread.sleep(2000);

Now it works fine. Which one is a better way?

  • You must to post comments
Showing 0 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website