package utility;
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.ElementNotVisibleException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class MyWait {
WebDriverWait wait;
WebDriver driver;
public MyWait(WebDriver driver){
this.driver = driver;
wait = new WebDriverWait(driver, 140);
wait.withTimeout(140, TimeUnit.SECONDS);
wait.pollingEvery(500, TimeUnit.MILLISECONDS);
wait.ignoring(NoSuchElementException.class);
wait.ignoring(ElementNotVisibleException.class);
}
public void alertIsPresent(){
wait.until(ExpectedConditions.alertIsPresent());
}
public void attributeContains(WebElement element, String attribute, String value){
wait.until(ExpectedConditions.attributeContains(element, attribute, value));
}
public void attributeToBe(WebElement element, String attribute, String value){
wait.until(ExpectedConditions.attributeToBe(element, attribute, value));
}
public void attributeToBeNotEmpty(WebElement element, String attribute){
wait.until(ExpectedConditions.attributeToBeNotEmpty(element, attribute));
}
public void elementSelectionStateToBe(WebElement element, boolean selected){
wait.until(ExpectedConditions.elementSelectionStateToBe(element, selected));
}
public void elementToBeClickable(WebElement element){
wait.until(ExpectedConditions.elementToBeClickable(element));
}
public void elementToBeSelected(WebElement element){
wait.until(ExpectedConditions.elementToBeSelected(element));
}
public void frameToBeAvailableAndSwitchToIt(WebElement frameLocator){
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(frameLocator));
}
public void numberOfWindowsToBe(int expectedNumberOfWindows){
wait.until(ExpectedConditions.numberOfWindowsToBe(expectedNumberOfWindows));
}
public void stalenessOf(WebElement element){
wait.until(ExpectedConditions.stalenessOf(element));
}
public void textToBePresentInElement(WebElement element, String text){
wait.until(ExpectedConditions.textToBePresentInElement(element, text));
}
public void textToBePresentInElementValue(WebElement element, String text){
wait.until(ExpectedConditions.textToBePresentInElementValue(element, text));
}
public void titleIs(String title){
wait.until(ExpectedConditions.titleIs(title));
}
public void titleContains(String subTitle){
wait.until(ExpectedConditions.titleContains(subTitle));
}
public void urlContains(String fraction){
wait.until(ExpectedConditions.urlContains(fraction));
}
public void urlContains(WebElement element){
wait.until(ExpectedConditions.visibilityOf(element));
}
}
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.ElementNotVisibleException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class MyWait {
WebDriverWait wait;
WebDriver driver;
public MyWait(WebDriver driver){
this.driver = driver;
wait = new WebDriverWait(driver, 140);
wait.withTimeout(140, TimeUnit.SECONDS);
wait.pollingEvery(500, TimeUnit.MILLISECONDS);
wait.ignoring(NoSuchElementException.class);
wait.ignoring(ElementNotVisibleException.class);
}
public void alertIsPresent(){
wait.until(ExpectedConditions.alertIsPresent());
}
public void attributeContains(WebElement element, String attribute, String value){
wait.until(ExpectedConditions.attributeContains(element, attribute, value));
}
public void attributeToBe(WebElement element, String attribute, String value){
wait.until(ExpectedConditions.attributeToBe(element, attribute, value));
}
public void attributeToBeNotEmpty(WebElement element, String attribute){
wait.until(ExpectedConditions.attributeToBeNotEmpty(element, attribute));
}
public void elementSelectionStateToBe(WebElement element, boolean selected){
wait.until(ExpectedConditions.elementSelectionStateToBe(element, selected));
}
public void elementToBeClickable(WebElement element){
wait.until(ExpectedConditions.elementToBeClickable(element));
}
public void elementToBeSelected(WebElement element){
wait.until(ExpectedConditions.elementToBeSelected(element));
}
public void frameToBeAvailableAndSwitchToIt(WebElement frameLocator){
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(frameLocator));
}
public void numberOfWindowsToBe(int expectedNumberOfWindows){
wait.until(ExpectedConditions.numberOfWindowsToBe(expectedNumberOfWindows));
}
public void stalenessOf(WebElement element){
wait.until(ExpectedConditions.stalenessOf(element));
}
public void textToBePresentInElement(WebElement element, String text){
wait.until(ExpectedConditions.textToBePresentInElement(element, text));
}
public void textToBePresentInElementValue(WebElement element, String text){
wait.until(ExpectedConditions.textToBePresentInElementValue(element, text));
}
public void titleIs(String title){
wait.until(ExpectedConditions.titleIs(title));
}
public void titleContains(String subTitle){
wait.until(ExpectedConditions.titleContains(subTitle));
}
public void urlContains(String fraction){
wait.until(ExpectedConditions.urlContains(fraction));
}
public void urlContains(WebElement element){
wait.until(ExpectedConditions.visibilityOf(element));
}
}
No comments:
Post a Comment