package com.sayem.selenium.framework;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.util.UUID;
public class Utils {
private static WebDriver driver = BasePage.driver;
public static void waitForElementPresent(String xpath) {
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(
ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath)));
}
public static boolean isElementPresent(String xpath) {
return driver.findElements(By.xpath(xpath)).size() > 0;
}
public static boolean isElementPresent(By by) {
return driver.findElements(by).size() > 0;
}
public static String getText(String xpath) {
return driver.findElement(By.xpath(xpath)).getText();
}
public static String getUUID() {
return UUID.randomUUID().toString().substring(0,5);
}
}