Пример #1
0
 public boolean elementExists(By locator) {
   try {
     driver.findElement(locator);
   } catch (NoSuchElementException e) {
     return false;
   }
   return true;
 }
Пример #2
0
  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;
    }
  }
Пример #3
0
 public WebElement findElement(By by) {
   return driver.findElement(by);
 }
Пример #4
0
 public List<WebElement> findElements(By by) {
   return driver.findElements(by);
 }
Пример #5
0
 public static void waitBetween(int time) {
   driver.manage().timeouts().implicitlyWait(time, TimeUnit.SECONDS);
 }