private WebElement findElement(final By locator) { (new WebDriverWait(driver, 30, 1000)) .until(ExpectedConditions.presenceOfElementLocated(locator)); (new WebDriverWait(driver, 30, 1000)) .until(ExpectedConditions.visibilityOfElementLocated(locator)); WebElement element = driver.findElement(locator); if (element.isEnabled() == false) ((JavascriptExecutor) driver).executeScript("arguments[0].disabled = false", element); return element; }
public void optionalClick(final By locator) { WebElement we = null; try { we = driver.findElement(locator); we.click(); } catch (StaleElementReferenceException ser) { } catch (NoSuchElementException nse) { } catch (Exception e) { // staticlogger.info( e.getMessage() ); } }