Nasrin Naher Nasrin Naher - 1 year ago 90
Java Question

How to wait a page before going to another page in Selenium WebDriver using Java?

I am new in Selenium. I am using Selenium WebDriver with Java. I'm using eclipse as IDE. I have written some code for Login page and it is run successfully. Now I want to go to desired page after successful login, but I want to wait for few time before transiting another page. How can I wait a page before loading another page?

Answer Source

As far as I know, there are 3 ways:

  1. Implicit wait: (It's applicable for all elements on the page)

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

  2. Explicit wait: (Applicable for a particular element)


More specific code is as below:

WebDriverWait wait = new WebDriverWait(driver, 40);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable("someid")));
  1. Using Thread:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download