public boolean elementExists(By locator) { try { driver.findElement(locator); } catch (NoSuchElementException e) { return false; } return true; }
private WebDriver getWebDriver(String browser) { try { WebDriver driver; switch (browser) { case "chrome": ChromeDriverManager.getInstance().setup(); driver = new ChromeDriver(); break; case "firefox": driver = new FirefoxDriver(); break; default: driver = new HtmlUnitDriver(); } driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); return driver; } catch (IllegalArgumentException ex) { // do nothing return null; } }
public WebElement findElement(By by) { return driver.findElement(by); }
public List<WebElement> findElements(By by) { return driver.findElements(by); }
public static void waitBetween(int time) { driver.manage().timeouts().implicitlyWait(time, TimeUnit.SECONDS); }