Best Online Selenium Training Hyderabad



Different types of Selenium WebDriver Waits

      The web driver user with two geneses of waits to handle the recurring page loads. It loads appearance of windows, pop ups and error messages reflection of web elements on the web page.  

  •   Implicit Wait
  •   Explicit Wait


WebDriver Implicit Wait

    Implicit waits use to provide a default waiting time. The consecutive test step/command across the test script. Thus, next test steps the 30 seconds after executing the previous test step/command.  

Key Notes


  • The implicit wait is a single line of a code and can declare in the setup method of the test script.
  •   When compared to Explicit wait, the Implicit wait is transparent and uncomplicated. The syntax and approach are simpler than explicit wait.

  It gives rise to the test script execution time as each of the commands. It would stop to wait for a stipulated amount of time before resuming the execution.     Thus to troubleshoot this issue. WebDriver introduces Explicit waits can apply the executing each of the test steps.  

Import Statements

    import java.util.concurrent.TimeUnit To access and apply implicit wait in our test scripts. We are bound to import this package into our test script.  


drv.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);   The line of code into test script after instantiation of WebDriver instance variable. Thus, this needs to set an implicit wait into your test script.  

Code Walkthrough

  The implicit wait mandates to pass two values as parameters. The first argument indicates the time in the numeric digits system needs to wait. The second argument indicates the time measurement scale. Thus we have mentioned the “30” seconds as default wait time and the time unit has been set to “seconds”.  

WebDriver Explicit Wait

  Explicit waits use to halt the execution till the time a particular condition met. The greatest time has elapsed. Unlike Implicit waits, Explicit waits apply for a particular instance only. WebDriver introduces like WebDriverWait and ExpectedConditions to Explicit waits into the test scripts. In the ambit of this discussion, we will use “” as a specimen.    

Scenario to be automating


  1.  1.  Launch the web browser and open the “
  2. Enter a valid username
  3. Enter a valid password
  4. Click on the sign in button
  5. Wait for Compose button to be visible after page load

Expected Condition

  The “wait” reference variable of WebDriverWait class created with Expected Conditions class. An actual condition expected to occur. The program control would move to the next execution step waiting for the entire 30 seconds. We wait for the “compose” button to be present loaded as a part of home page load. then we move forward with calling the click command on the “compose” button.  

Types of Expected Conditions

  Expected Conditions class provides a great help to deal with scenarios. We have to learn for a condition to before executing the actual test step.   Expected Conditions class comes with a wide range of expected conditions. The WebDriverWait method is a reference to the variable and until () method.  

Let us discuss a few of them at length:


#1) elementToBeClickable()

The expected condition waits for an element to be clickable. It should be present/displayed/visible on the screen as well as enabled.   Sample Code wait.until(ExpectedConditions.elementToBeClickable(By.xpath(“//div[contains(text(),’COMPOSE’)]”)));  

#2) textToBePresentInElement()

The expected condition waits for an element having a certain string pattern. Sample Code wait.until(ExpectedConditions.textToBePresentInElement(By.xpath(“//div[@id= ‘forgotPass'”), “text to be found”));  

#3) alertIsPresent()

The expected condition waits for an alert box to appear. Sample Code wait.until(ExpectedConditions.alertIsPresent()) !=null);


#4) titleIs()

The expected condition waits for a page with a specific title. Sample Code wait.until(ExpectedConditions.titleIs(“gmail”));  

#5) frameToBeAvailableAndSwitchToIt()

  The expected condition waits for a frame to be available. The control switches to it automatic.  

Sample Code


 Navigation Using WebDriver

There is a very common user action clicks on the back and forward buttons of the web browser. The n forth to navigate to the different web pages visited in the current session on the browser’s history. So many actions performed by the users of WebDriver introduces Navigate commands.  

Let us examine these commands in detail


#1) navigate().back()

This command lets the user navigate to the previous web page.

Sample code:

driver.navigate().back(); The command requires no parameters. It takes back the user to the previous web page in the web browser’s history.  

#2) navigate().forward()

This command lets the user navigate to the next web page with reference to the browser’s history.  

Sample code:

driver.navigate().forward(); The command requires no parameters. It takes forward the user to the next web page in the web browser’s history.  

#3) navigate().refresh()

  The user to fresh the current web page thereby reloading all the web elements.

Sample code:

driver.navigate().refresh(); The above command requires no parameters and reloads the web page.  

#4) navigate().to()

This command lets the user launch a new web browser window and navigate to the specified URL.

Sample code:

driver.navigate().to(“”); The command requires a web URL as a parameter. Then it opens the specified URL in a launched web browser.  

Best Online Selenium Training Hyderabad

  Best Online Selenium Training Hyderabad: We Provides Best Online Selenium Training Hyderabad by real time experts. We offer online & classroom Training.