content: package com.tmb.factories;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.support.ui.ExpectedConditions;
  import org.openqa.selenium.support.ui.WebDriverWait;
  
  import com.tmb.constants.FrameworkConstants;
  import com.tmb.driver.DriverManager;
  import com.tmb.enums.WaitStrategy;
  /**
   * Explicit wait factory produces different waits before operating on webelement
   * 
   * <pre>
   * <b>
   * <a href="https://www.youtube.com/channel/UC6PTXUHb6j4Oxf0ccdRI11A">Testing Mini Bytes Youtube channel</a>
   * </b>
   * </pre>
   * 
   * Jan 21, 2021 
   * @author Amuthan Sakthivel
   * @version 1.0
   * @since 1.0
   */
  public final class ExplicitWaitFactory {
  	/**
  	 * Private constructor to avoid external instantiation
  	 */
  	private ExplicitWaitFactory() {}
  
  	/**
  	 * 
  	 * @author Amuthan Sakthivel
  	 * Jan 21, 2021
  	 * @param waitstrategy Strategy to be applied to find a webelement {@link com.tmb.enums.WaitStrategy}
  	 * @param by By locator of the webelement
  	 * @return webelement Locates and return the webelement
  	 */
  	public static WebElement performExplicitWait(WaitStrategy waitstrategy, By by) {
  		WebElement element = null;
  		if(waitstrategy == WaitStrategy.CLICKABLE) {
  			element = 	new WebDriverWait(DriverManager.getDriver(), FrameworkConstants.getExplicitwait())
  					.until(ExpectedConditions.elementToBeClickable(by));
  		}
  		else if(waitstrategy == WaitStrategy.PRESENCE) {
  			element =	new WebDriverWait(DriverManager.getDriver(), FrameworkConstants.getExplicitwait())
  					.until(ExpectedConditions.presenceOfElementLocated(by));
  		}
  		else if(waitstrategy == WaitStrategy.VISIBLE) {
  			element =new WebDriverWait(DriverManager.getDriver(), FrameworkConstants.getExplicitwait())
  					.until(ExpectedConditions.visibilityOfElementLocated(by));
  		}
  		else if(waitstrategy == WaitStrategy.NONE) {
  			element = DriverManager.getDriver().findElement(by);
  		}
  		return element;
  	}
  
  }
  