archick12 / qa_auto_5_ui

7 stars 8 forks source link

Update 'iselementPresent' method in BasePage #66

Closed mkuzmina-lohika-tix closed 6 years ago

mkuzmina-lohika-tix commented 6 years ago

Add waiting

spektorius commented 6 years ago

When trying to use catch (NoSuchElementException | TimeoutException e) { got a compilation error: Error:(209, 39) java: multi-catch statement is not supported in -source 1.5 (use -source 7 or higher to enable multi-catch statement)

The suggestion is to use only catch ( TimeoutException e) {

that should be enough for wait.until() construction @marinamv has proposed

mkuzmina-lohika-tix commented 6 years ago

Done. I left 2 exceptions protected boolean isElementPresent(By locator) { logger.info("WAIT ELEMENT TO BE PRESENT: " + locator); try { (new WebDriverWait(driver, defaultExplicitWaitInSeconds)) .until(ExpectedConditions.presenceOfElementLocated(locator)); return true; } catch (NoSuchElementException e) { return false; } catch (TimeoutException e) { return false; } }