Posted in Selenium

What is the difference between Implicit wait and Explicit wait in Selenium WebDriver?

Implicit wait()  is used to inform WebDriver that there could be cases When a page is loaded by the browser, the elements which we want to interact with may not load instantaneously. In those cases WebDriver has to continuously listen to DOM for a given amount of time until either the time expires or the element is found.

In implicit wait, we will actually define a wait time globally, so it is applied to all the elements in the script. Below Implicit Wait() says driver that hey wait for N number of seconds before you throw an error or exception.

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

Explicit Wait(): Explicit Wait will make your code to wait for certain condition to occur before moving forward.

Explicit Wait() is 2 types

  1. WebDriverWait :It is used to tell the Web Driver to wait for certain conditions (Expected Conditions) or the maximum timeout. 
 WebDriverWait wait = new WebDriverWait(driver, TimeOut);  
wait.until(ExpectedConditions.visiblityOfElementLocated(locator)); 

The following are the suggestions if you type ExpectedConditions.

  1. alertIsPresent()
  2. elementSelectionStateToBe()
  3. elementToBeClickable()
  4. elementToBeSelected()
  5. frameToBeAvaliableAndSwitchToIt()
  6. invisibilityOfTheElementLocated()
  7. invisibilityOfElementWithText()
  8. presenceOfAllElementsLocatedBy()
  9. presenceOfElementLocated()
  10. textToBePresentInElement()
  11. textToBePresentInElementLocated()
  12. textToBePresentInElementValue()
  13. titleIs()
  14. titleContains()
  15. visibilityOf()
  16. visibilityOfAllElements()
  17. visibilityOfAllElementsLocatedBy()
  18. visibilityOfElementLocated

2. Fluent Wait : fluent wait is used to tell the web driver to wait for a condition, as well as the frequency or poll with which your WebDriver monitors or listens to DOM.

Frequency or poll : Setting up a repeat cycle with the time frame to verify/check the condition at the regular interval of time

Wait wait = new FluentWait(driver)    
    .withTimeout(30, SECONDS)    
    .pollingEvery(5, SECONDS)   
    .ignoring(NoSuchElementException.class);

Ex: fluentwait 10 sec, polling 2 sec means every 2 sec it checks DOM for the element

Conclusion: Explicit Waits are smarter than Implicit Waits because they don’t wait for the max time out.  Instead it waits for the time till the condition becomes true.

Posted in Selenium

What is Serverless Architecture ? it’s Advantages?

 Serverless Architectures are internet-based systems where the application development does not use the usual server process. Instead, they rely solely on a combination of third-party services, client-side logic. Applications are broken up into individual functions that can be invoked and scaled individually.

Advantage of Serveless Architecture:

  1. Pricing: for years the cost of provisioning servers and maintaining that 24×7 server team which blew a hole in your pocket is gone. 
  2. It is beneficial for simple applications with few dependencies
  3.  Environments: Setting up different environments for Serverless is as easy as setting up a single environment