Search in sources :

Example 6 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 7 with TimeoutException

use of org.openqa.selenium.TimeoutException in project zeppelin by apache.

the class SparkParagraphIT method testSqlSpark.

@Test
public void testSqlSpark() throws Exception {
    if (!endToEndTestEnabled()) {
        return;
    }
    try {
        setTextOfParagraph(1, "%sql\\n" + "select * from bank limit 1");
        runParagraph(1);
        try {
            waitForParagraph(1, "FINISHED");
        } catch (TimeoutException e) {
            waitForParagraph(1, "ERROR");
            collector.checkThat("Paragraph from SparkParagraphIT of testSqlSpark status: ", "ERROR", CoreMatchers.equalTo("FINISHED"));
        }
        WebElement paragraph1Result = driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@id,\"_graph\")]/div/div/div/div/div[1]"));
        collector.checkThat("Paragraph from SparkParagraphIT of testSqlSpark result: ", paragraph1Result.getText().toString(), CoreMatchers.equalTo("age\n▼\njob\n▼\nmarital\n▼\neducation\n▼\nbalance\n▼\n30 unemployed married primary 1787"));
    } catch (Exception e) {
        handleException("Exception in SparkParagraphIT while testSqlSpark", e);
    }
}
Also used : WebElement(org.openqa.selenium.WebElement) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.junit.Test)

Example 8 with TimeoutException

use of org.openqa.selenium.TimeoutException in project zeppelin by apache.

the class SparkParagraphIT method testPySpark.

@Test
public void testPySpark() throws Exception {
    if (!endToEndTestEnabled()) {
        return;
    }
    try {
        setTextOfParagraph(1, "%pyspark\\n" + "for x in range(0, 3):\\n" + "    print \"test loop %d\" % (x)");
        runParagraph(1);
        try {
            waitForParagraph(1, "FINISHED");
        } catch (TimeoutException e) {
            waitForParagraph(1, "ERROR");
            collector.checkThat("Paragraph from SparkParagraphIT of testPySpark status: ", "ERROR", CoreMatchers.equalTo("FINISHED"));
        }
        WebElement paragraph1Result = driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@id,\"_text\")]"));
        collector.checkThat("Paragraph from SparkParagraphIT of testPySpark result: ", paragraph1Result.getText().toString(), CoreMatchers.equalTo("test loop 0\ntest loop 1\ntest loop 2"));
        // the last statement's evaluation result is printed
        setTextOfParagraph(2, "%pyspark\\n" + "sc.version\\n" + "1+1");
        runParagraph(2);
        try {
            waitForParagraph(2, "FINISHED");
        } catch (TimeoutException e) {
            waitForParagraph(2, "ERROR");
            collector.checkThat("Paragraph from SparkParagraphIT of testPySpark status: ", "ERROR", CoreMatchers.equalTo("FINISHED"));
        }
        WebElement paragraph2Result = driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@id,\"_text\")]"));
        collector.checkThat("Paragraph from SparkParagraphIT of testPySpark result: ", paragraph2Result.getText().toString(), CoreMatchers.equalTo("2"));
    } catch (Exception e) {
        handleException("Exception in SparkParagraphIT while testPySpark", e);
    }
}
Also used : WebElement(org.openqa.selenium.WebElement) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.junit.Test)

Example 9 with TimeoutException

use of org.openqa.selenium.TimeoutException in project zeppelin by apache.

the class ZeppelinIT method testSparkInterpreterDependencyLoading.

@Test
public void testSparkInterpreterDependencyLoading() throws Exception {
    if (!endToEndTestEnabled()) {
        return;
    }
    try {
        // navigate to interpreter page
        WebElement settingButton = driver.findElement(By.xpath("//button[@class='nav-btn dropdown-toggle ng-scope']"));
        settingButton.click();
        WebElement interpreterLink = driver.findElement(By.xpath("//a[@href='#/interpreter']"));
        interpreterLink.click();
        // add new dependency to spark interpreter
        driver.findElement(By.xpath("//div[@id='spark']//button[contains(.,'edit')]")).sendKeys(Keys.ENTER);
        WebElement depArtifact = pollingWait(By.xpath("//input[@ng-model='setting.depArtifact']"), MAX_BROWSER_TIMEOUT_SEC);
        String artifact = "org.apache.commons:commons-csv:1.1";
        depArtifact.sendKeys(artifact);
        driver.findElement(By.xpath("//div[@id='spark']//form//button[1]")).click();
        clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to update this interpreter and restart with new settings?')]" + "//div[@class='modal-footer']//button[contains(.,'OK')]"));
        try {
            clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to " + "update this interpreter and restart with new settings?')]//" + "div[@class='bootstrap-dialog-close-button']/button"));
        } catch (TimeoutException | StaleElementReferenceException e) {
        //Modal dialog got closed earlier than expected nothing to worry.
        }
        driver.navigate().back();
        createNewNote();
        // wait for first paragraph's " READY " status text
        waitForParagraph(1, "READY");
        setTextOfParagraph(1, "import org.apache.commons.csv.CSVFormat");
        runParagraph(1);
        waitForParagraph(1, "FINISHED");
        // check expected text
        WebElement paragraph1Result = driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@id,\"_text\")]"));
        collector.checkThat("Paragraph from ZeppelinIT of testSparkInterpreterDependencyLoading result: ", paragraph1Result.getText().toString(), CoreMatchers.containsString("import org.apache.commons.csv.CSVFormat"));
        //delete created notebook for cleanup.
        deleteTestNotebook(driver);
        ZeppelinITUtils.sleep(1000, false);
        // reset dependency
        settingButton.click();
        interpreterLink.click();
        driver.findElement(By.xpath("//div[@id='spark']//button[contains(.,'edit')]")).sendKeys(Keys.ENTER);
        WebElement testDepRemoveBtn = pollingWait(By.xpath("//tr[descendant::text()[contains(.,'" + artifact + "')]]/td[3]/button"), MAX_IMPLICIT_WAIT);
        testDepRemoveBtn.sendKeys(Keys.ENTER);
        driver.findElement(By.xpath("//div[@id='spark']//form//button[1]")).click();
        driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to update this interpreter and restart with new settings?')]" + "//div[@class='modal-footer']//button[contains(.,'OK')]")).click();
    } catch (Exception e) {
        handleException("Exception in ZeppelinIT while testSparkInterpreterDependencyLoading ", e);
    }
}
Also used : StaleElementReferenceException(org.openqa.selenium.StaleElementReferenceException) WebElement(org.openqa.selenium.WebElement) StaleElementReferenceException(org.openqa.selenium.StaleElementReferenceException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.junit.Test)

Example 10 with TimeoutException

use of org.openqa.selenium.TimeoutException in project zeppelin by apache.

the class WebDriverManager method getWebDriver.

public static WebDriver getWebDriver() {
    WebDriver driver = null;
    if (driver == null) {
        try {
            FirefoxBinary ffox = new FirefoxBinary();
            if ("true".equals(System.getenv("TRAVIS"))) {
                // xvfb is supposed to
                ffox.setEnvironmentProperty("DISPLAY", ":99");
            // run with DISPLAY 99
            }
            int firefoxVersion = WebDriverManager.getFirefoxVersion();
            LOG.info("Firefox version " + firefoxVersion + " detected");
            downLoadsDir = FileUtils.getTempDirectory().toString();
            String tempPath = downLoadsDir + "/firebug/";
            downloadFireBug(firefoxVersion, tempPath);
            final String firebugPath = tempPath + "firebug.xpi";
            final String firepathPath = tempPath + "firepath.xpi";
            FirefoxProfile profile = new FirefoxProfile();
            profile.setPreference("browser.download.folderList", 2);
            profile.setPreference("browser.download.dir", downLoadsDir);
            profile.setPreference("browser.helperApps.alwaysAsk.force", false);
            profile.setPreference("browser.download.manager.showWhenStarting", false);
            profile.setPreference("browser.download.manager.showAlertOnComplete", false);
            profile.setPreference("browser.download.manager.closeWhenDone", true);
            profile.setPreference("app.update.auto", false);
            profile.setPreference("app.update.enabled", false);
            profile.setPreference("dom.max_script_run_time", 0);
            profile.setPreference("dom.max_chrome_script_run_time", 0);
            profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-ustar,application/octet-stream,application/zip,text/csv,text/plain");
            profile.setPreference("network.proxy.type", 0);
            profile.addExtension(new File(firebugPath));
            profile.addExtension(new File(firepathPath));
            driver = new FirefoxDriver(ffox, profile);
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while FireFox Driver ", e);
        }
    }
    if (driver == null) {
        try {
            driver = new ChromeDriver();
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while ChromeDriver ", e);
        }
    }
    if (driver == null) {
        try {
            driver = new SafariDriver();
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while SafariDriver ", e);
        }
    }
    String url;
    if (System.getenv("url") != null) {
        url = System.getenv("url");
    } else {
        url = "http://localhost:8080";
    }
    long start = System.currentTimeMillis();
    boolean loaded = false;
    driver.manage().timeouts().implicitlyWait(AbstractZeppelinIT.MAX_IMPLICIT_WAIT, TimeUnit.SECONDS);
    driver.get(url);
    while (System.currentTimeMillis() - start < 60 * 1000) {
        // wait for page load
        try {
            (new WebDriverWait(driver, 30)).until(new ExpectedCondition<Boolean>() {

                @Override
                public Boolean apply(WebDriver d) {
                    return d.findElement(By.xpath("//i[@tooltip='WebSocket Connected']")).isDisplayed();
                }
            });
            loaded = true;
            break;
        } catch (TimeoutException e) {
            LOG.info("Exception in WebDriverManager while WebDriverWait ", e);
            driver.navigate().to(url);
        }
    }
    if (loaded == false) {
        fail();
    }
    return driver;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) IOException(java.io.IOException) TimeoutException(org.openqa.selenium.TimeoutException) SafariDriver(org.openqa.selenium.safari.SafariDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FirefoxBinary(org.openqa.selenium.firefox.FirefoxBinary) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) File(java.io.File) TimeoutException(org.openqa.selenium.TimeoutException)

Aggregations

TimeoutException (org.openqa.selenium.TimeoutException)11 WebElement (org.openqa.selenium.WebElement)9 Test (org.junit.Test)5 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)5 WebDriver (org.openqa.selenium.WebDriver)3 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 IOException (java.io.IOException)1 By (org.openqa.selenium.By)1 NoSuchElementException (org.openqa.selenium.NoSuchElementException)1 StaleElementReferenceException (org.openqa.selenium.StaleElementReferenceException)1 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)1 FirefoxBinary (org.openqa.selenium.firefox.FirefoxBinary)1 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)1 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)1 SafariDriver (org.openqa.selenium.safari.SafariDriver)1 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)1