Search in sources :

Example 1 with TimeoutException

use of org.openqa.selenium.TimeoutException in project selenium-tests by Wikia.

the class ChatPage method isMessageOnChat.

public boolean isMessageOnChat(String message) {
    try {
        WebElement userPostedMessage = userPostedMessage(message);
        wait.forElementVisible(userPostedMessage);
        return true;
    } catch (TimeoutException | NoSuchElementException ex) {
        PageObjectLogging.log("Message on chat not displayed", ex, true);
        return false;
    }
}
Also used : WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 2 with TimeoutException

use of org.openqa.selenium.TimeoutException in project acceptance-test-harness by jenkinsci.

the class LocalController method diagnose.

@Override
public void diagnose(Throwable cause) {
    if (cause instanceof TimeoutException) {
        FailureDiagnostics diagnostics = injector.getInstance(FailureDiagnostics.class);
        String td = getThreaddump();
        if (td != null) {
            diagnostics.write("threaddump.log", td);
        }
    }
    if (getenv("INTERACTIVE") != null && getenv("INTERACTIVE").equals("true")) {
        if (cause instanceof MultipleFailureException) {
            System.out.println("Multiple exceptions occurred:");
            for (Throwable c : ((MultipleFailureException) cause).getFailures()) {
                out.println();
                c.printStackTrace(out);
                out.println();
            }
        } else {
            cause.printStackTrace(out);
        }
        out.println("Commencing interactive debugging. Browser session was kept open.");
        synchronized (this) {
            try {
                this.wait();
            } catch (InterruptedException e) {
                return;
            }
        }
    }
}
Also used : MultipleFailureException(org.junit.runners.model.MultipleFailureException) FailureDiagnostics(org.jenkinsci.test.acceptance.junit.FailureDiagnostics) TimeoutException(org.openqa.selenium.TimeoutException)

Example 3 with TimeoutException

use of org.openqa.selenium.TimeoutException in project acceptance-test-harness by jenkinsci.

the class DiskUsage method reloaded.

public static Matcher<DiskUsage> reloaded() {
    return new Matcher<DiskUsage>("disk usage reloaded") {

        private Exception cause;

        @Override
        public boolean matchesSafely(DiskUsage item) {
            JenkinsLogger logger = item.getJenkins().getLogger("all");
            try {
                logger.waitForLogged(Pattern.compile("Finished Project disk usage. \\d+ ms"));
                return true;
            } catch (TimeoutException ex) {
                // v0.22 and newer
                cause = ex;
            }
            try {
                logger.waitForLogged(Pattern.compile("Finished Calculation of builds disk usage.*"));
                logger.waitForLogged(Pattern.compile("Finished Calculation of job directories.*"));
                logger.waitForLogged(Pattern.compile("Finished Calculation of workspace usage.*"));
                return true;
            } catch (TimeoutException ex) {
                cause = ex;
                return false;
            }
        }

        @Override
        public void describeMismatchSafely(DiskUsage item, Description dsc) {
            dsc.appendText(cause.getMessage());
        }
    };
}
Also used : Description(org.hamcrest.Description) Matcher(org.jenkinsci.test.acceptance.Matcher) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException) JenkinsLogger(org.jenkinsci.test.acceptance.po.JenkinsLogger) TimeoutException(org.openqa.selenium.TimeoutException)

Example 4 with TimeoutException

use of org.openqa.selenium.TimeoutException in project ORCID-Source by ORCID.

the class BlackBoxBase method adminUnlockAccount.

public void adminUnlockAccount(String adminUserName, String adminPassword, String orcidToUnlock) {
    // Login Admin
    adminSignIn(adminUserName, adminPassword);
    try {
        // Unlock the account
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='unlockProfileDiv']/p[1]/a[2]")));
        BBBUtil.ngAwareClick(webDriver.findElement(By.xpath("//div[@id='unlockProfileDiv']/p[1]/a[2]")), webDriver);
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
        WebElement unLockProfileOrcidId = webDriver.findElement(By.id("orcid_to_unlock"));
        unLockProfileOrcidId.sendKeys(orcidToUnlock);
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.visibilityOfElementLocated(By.id("bottom-confirm-unlock-profile")));
        BBBUtil.ngAwareClick(webDriver.findElement(By.id("bottom-confirm-unlock-profile")), webDriver);
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.visibilityOfElementLocated(By.id("btn-unlock")));
        BBBUtil.ngAwareClick(webDriver.findElement(By.id("btn-unlock")), webDriver);
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
    } catch (TimeoutException t) {
    // Account might be already unlocked
    }
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement) TimeoutException(org.openqa.selenium.TimeoutException)

Example 5 with TimeoutException

use of org.openqa.selenium.TimeoutException in project ORCID-Source by ORCID.

the class OauthAuthorizationPageHelper method clickAuthorizeOnAuthorizeScreen.

public static void clickAuthorizeOnAuthorizeScreen(final WebDriver webDriver, boolean longLife) {
    if (webDriver.getTitle().equals("ORCID Playground")) {
        return;
    } else {
        try {
            BBBUtil.extremeWaitFor(ExpectedConditions.presenceOfElementLocated(By.xpath("//p[contains(text(),'has asked for the following access to your ORCID Record')]")), webDriver);
            if (longLife == false) {
                // disablePersistentToken
                WebElement persistentElement = webDriver.findElement(By.id("enablePersistentToken"));
                if (persistentElement.isDisplayed()) {
                    if (persistentElement.isSelected()) {
                        persistentElement.click();
                    }
                }
            }
            WebElement authorizeButton = webDriver.findElement(By.id("authorize"));
            authorizeButton.click();
        } catch (TimeoutException e) {
            // It might be the case that we are already in the ORCID Playground page, so, lets check for that case
            (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {

                public Boolean apply(WebDriver d) {
                    return d.getTitle().equals("ORCID Playground");
                }
            });
        }
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) TimeoutException(org.openqa.selenium.TimeoutException)

Aggregations

TimeoutException (org.openqa.selenium.TimeoutException)72 WebElement (org.openqa.selenium.WebElement)37 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)30 NoSuchElementException (org.openqa.selenium.NoSuchElementException)23 Test (org.junit.Test)17 MessageEvent (org.cerberus.engine.entity.MessageEvent)16 By (org.openqa.selenium.By)15 WebDriverException (org.openqa.selenium.WebDriverException)13 IOException (java.io.IOException)10 AnswerItem (org.cerberus.util.answer.AnswerItem)10 WebDriver (org.openqa.selenium.WebDriver)10 BFElementNotFoundException (com.capgemini.ntc.selenium.core.exceptions.BFElementNotFoundException)6 Actions (org.openqa.selenium.interactions.Actions)5 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)5 URISyntaxException (java.net.URISyntaxException)4 TimeUnit (java.util.concurrent.TimeUnit)3 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)3 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)3 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)3 NgWebElement (com.github.sergueik.jprotractor.NgWebElement)2