Search in sources :

Example 41 with TimeoutException

use of org.openqa.selenium.TimeoutException in project flow by vaadin.

the class ComponentThemeLiveReloadIT method checkNoWebpackErrors.

private void checkNoWebpackErrors(String theme) {
    getLogEntries(java.util.logging.Level.ALL).forEach(logEntry -> {
        if (logEntry.getMessage().contains("Module build failed")) {
            Assert.fail(String.format("Webpack error detected in the browser console after " + "deleting '%s' component style sheet: %s\n\n", theme, logEntry.getMessage()));
        }
    });
    final By byErrorOverlayClass = By.className("v-system-error");
    try {
        waitForElementNotPresent(byErrorOverlayClass);
    } catch (TimeoutException e) {
        WebElement error = findElement(byErrorOverlayClass);
        Assert.fail(String.format("Webpack error overlay detected after deleting '%s' " + "component style sheet: %s\n\n", theme, error.getText()));
    }
}
Also used : By(org.openqa.selenium.By) WebElement(org.openqa.selenium.WebElement) TimeoutException(org.openqa.selenium.TimeoutException)

Example 42 with TimeoutException

use of org.openqa.selenium.TimeoutException in project carina by qaprosoft.

the class DriverHelper method refresh.

/**
 * Refresh browser.
 *
 * @param timeout long
 */
public void refresh(long timeout) {
    WebDriver drv = getDriver();
    Wait<WebDriver> wait = new FluentWait<WebDriver>(drv).pollingEvery(// there is no sense to refresh url address too often
    Duration.ofMillis(5000)).withTimeout(Duration.ofSeconds(timeout)).ignoring(WebDriverException.class).ignoring(// org.openqa.selenium.json.JsonException: Expected to read a START_MAP but instead have: END. Last 0 characters read
    JsonException.class);
    try {
        wait.until(new Function<WebDriver, Void>() {

            public Void apply(WebDriver driver) {
                drv.navigate().refresh();
                return null;
            }
        });
    } catch (ScriptTimeoutException | TimeoutException e) {
        Messager.FAIL_REFRESH.error();
    }
    Messager.REFRESH.info();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) EventFiringWebDriver(org.openqa.selenium.support.events.EventFiringWebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) FluentWait(org.openqa.selenium.support.ui.FluentWait) ScriptTimeoutException(org.openqa.selenium.ScriptTimeoutException) WebDriverException(org.openqa.selenium.WebDriverException) TimeoutException(org.openqa.selenium.TimeoutException) ScriptTimeoutException(org.openqa.selenium.ScriptTimeoutException)

Example 43 with TimeoutException

use of org.openqa.selenium.TimeoutException in project carina by qaprosoft.

the class DriverHelper method waitUntil.

/**
 * Wait until any condition happens.
 *
 * @param condition - ExpectedCondition.
 * @param timeout - timeout.
 * @return true if condition happen.
 */
public boolean waitUntil(ExpectedCondition<?> condition, long timeout) {
    boolean result;
    long startMillis = 0;
    final WebDriver drv = getDriver();
    Wait<WebDriver> wait = new WebDriverWait(drv, timeout, RETRY_TIME).ignoring(WebDriverException.class).ignoring(NoSuchSessionException.class);
    try {
        startMillis = System.currentTimeMillis();
        wait.until(condition);
        result = true;
        LOGGER.debug("waitUntil: finished true...");
    } catch (NoSuchElementException | TimeoutException e) {
        // don't write exception even in debug mode
        LOGGER.debug("waitUntil: NoSuchElementException | TimeoutException e..." + condition.toString());
        result = false;
    } catch (Exception e) {
        LOGGER.error("waitUntil: " + condition.toString(), e);
        result = false;
    } finally {
        long timePassed = System.currentTimeMillis() - startMillis;
        // timePassed is time in ms timeout in sec so we have to adjust
        if (timePassed > 2 * timeout * 1000) {
            LOGGER.error("Your retry_interval is too low: " + RETRY_TIME + " ms! Increase it or upgrade your hardware");
        }
    }
    return result;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) EventFiringWebDriver(org.openqa.selenium.support.events.EventFiringWebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException) JavascriptException(org.openqa.selenium.JavascriptException) NoSuchSessionException(org.openqa.selenium.NoSuchSessionException) ScriptTimeoutException(org.openqa.selenium.ScriptTimeoutException) WebDriverException(org.openqa.selenium.WebDriverException) UnhandledAlertException(org.openqa.selenium.UnhandledAlertException) JsonException(org.openqa.selenium.json.JsonException) NoAlertPresentException(org.openqa.selenium.NoAlertPresentException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) NoSuchElementException(org.openqa.selenium.NoSuchElementException) NoSuchWindowException(org.openqa.selenium.NoSuchWindowException) WebDriverException(org.openqa.selenium.WebDriverException) TimeoutException(org.openqa.selenium.TimeoutException) ScriptTimeoutException(org.openqa.selenium.ScriptTimeoutException)

Example 44 with TimeoutException

use of org.openqa.selenium.TimeoutException in project carina by qaprosoft.

the class AbstractUIObjectListHandler method waitUntil.

/**
 * Wait until any condition happens.
 *
 * @param condition - ExpectedCondition.
 * @return true if condition happen.
 */
@SuppressWarnings("unchecked")
private boolean waitUntil(ExpectedCondition<?> condition) {
    boolean result;
    long timeout = Configuration.getLong(Parameter.EXPLICIT_TIMEOUT);
    long RETRY_TIME = Configuration.getLong(Parameter.RETRY_INTERVAL);
    @SuppressWarnings("rawtypes") Wait wait = new WebDriverWait(webDriver, timeout, RETRY_TIME).ignoring(WebDriverException.class).ignoring(NoSuchSessionException.class);
    try {
        wait.until(condition);
        result = true;
        LOGGER.debug("waitUntil: finished true...");
    } catch (NoSuchElementException | TimeoutException e) {
        // don't write exception even in debug mode
        LOGGER.debug("waitUntil: NoSuchElementException | TimeoutException e..." + condition.toString());
        result = false;
    } catch (Exception e) {
        LOGGER.error("waitUntil: " + condition.toString(), e);
        result = false;
    }
    return result;
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) Wait(org.openqa.selenium.support.ui.Wait) NoSuchElementException(org.openqa.selenium.NoSuchElementException) WebDriverException(org.openqa.selenium.WebDriverException) InvalidElementStateException(org.openqa.selenium.InvalidElementStateException) StaleElementReferenceException(org.openqa.selenium.StaleElementReferenceException) InvocationTargetException(java.lang.reflect.InvocationTargetException) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException) NoSuchSessionException(org.openqa.selenium.NoSuchSessionException) WebDriverException(org.openqa.selenium.WebDriverException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 45 with TimeoutException

use of org.openqa.selenium.TimeoutException in project devonfw-testing by devonfw.

the class DriverExtention method waitUntilElementIsClickable.

public WebElement waitUntilElementIsClickable(final By by) {
    BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
    long startTime = System.currentTimeMillis();
    WebElement element = null;
    try {
        element = webDriverWait().until(ExpectedConditions.elementToBeClickable(by));
    } catch (TimeoutException | NoSuchElementException e) {
        boolean isTimeout = true;
        throw new BFElementNotFoundException(by, isTimeout, BasePage.EXPLICITYWAITTIMER);
    }
    BFLogger.logTime(startTime, "waitUntilElementIsClickable()", by.toString());
    return element;
}
Also used : BFElementNotFoundException(com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Aggregations

TimeoutException (org.openqa.selenium.TimeoutException)249 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)109 WebElement (org.openqa.selenium.WebElement)87 NoSuchElementException (org.openqa.selenium.NoSuchElementException)52 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)40 WebDriver (org.openqa.selenium.WebDriver)39 WebDriverException (org.openqa.selenium.WebDriverException)39 AutomatorException (com.testsigma.automator.exceptions.AutomatorException)31 MessageEvent (org.cerberus.engine.entity.MessageEvent)27 ExpectedConditions (org.openqa.selenium.support.ui.ExpectedConditions)27 Reporter (com.coveros.selenified.utilities.Reporter)26 Test (org.junit.Test)25 By (org.openqa.selenium.By)22 Test (org.testng.annotations.Test)20 Element (com.coveros.selenified.element.Element)17 IOException (java.io.IOException)17 AnswerItem (org.cerberus.util.answer.AnswerItem)17 Dimension (org.openqa.selenium.Dimension)14 Point (org.openqa.selenium.Point)14 Constants (com.coveros.selenified.utilities.Constants)13