Search in sources :

Example 66 with TimeoutException

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

the class InterpreterModeActionsIT method testPerUserScopedAction.

@Test
public void testPerUserScopedAction() throws Exception {
    try {
        // step 1: (admin) login, set 'Per user in scoped' mode of python interpreter, logout
        InterpreterModeActionsIT interpreterModeActionsIT = new InterpreterModeActionsIT();
        interpreterModeActionsIT.authenticationUser("admin", "password1");
        pollingWait(By.xpath("//div/button[contains(@class, 'nav-btn dropdown-toggle ng-scope')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        clickAndWait(By.xpath("//li/a[contains(@href, '#/interpreter')]"));
        pollingWait(By.xpath("//input[contains(@ng-model, 'searchInterpreter')]"), MAX_BROWSER_TIMEOUT_SEC).sendKeys("python");
        ZeppelinITUtils.sleep(500, false);
        clickAndWait(By.xpath("//div[contains(@id, 'python')]//button[contains(@ng-click, 'valueform.$show();\n" + "                  copyOriginInterpreterSettingProperties(setting.id)')]"));
        clickAndWait(By.xpath("//div[contains(@id, 'python')]/div[2]/div/div/div[1]/span[1]/button"));
        clickAndWait(By.xpath("//div[contains(@id, 'python')]//li/a[contains(.,'Per User')]"));
        clickAndWait(By.xpath("//div[contains(@id, 'python')]/div[2]/div/div/div[1]/span[2]/button"));
        clickAndWait(By.xpath("//div[contains(@id, 'python')]//li/a[contains(.,'scoped per user')]"));
        JavascriptExecutor jse = (JavascriptExecutor) driver;
        jse.executeScript("window.scrollBy(0,250)", "");
        ZeppelinITUtils.sleep(500, false);
        clickAndWait(By.xpath("//div[contains(@id, 'python')]//div/form/button[contains(@type, 'submit')]"));
        clickAndWait(By.xpath("//div[@class='modal-dialog']//div[@class='bootstrap-dialog-footer-buttons']//button[contains(., 'OK')]"));
        clickAndWait(By.xpath("//a[@class='navbar-brand navbar-title'][contains(@href, '#/')]"));
        interpreterModeActionsIT.logoutUser("admin");
        // step 2: (user1) login, create a new note, run two paragraph with 'python', check result, check process, logout
        // paragraph: Check if the result is 'user1' in the second paragraph
        // System: Check if the number of python interpreter process is '1'
        // System: Check if the number of python process is '1'
        interpreterModeActionsIT.authenticationUser("user1", "password2");
        By locator = By.xpath("//div[contains(@class, 'col-md-4')]/div/h5/a[contains(.,'Create new" + " note')]");
        WebElement element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            createNewNote();
        }
        String user1noteId = driver.getCurrentUrl().substring(driver.getCurrentUrl().lastIndexOf("/") + 1);
        waitForParagraph(1, "READY");
        interpreterModeActionsIT.setPythonParagraph(1, "user=\"user1\"");
        waitForParagraph(2, "READY");
        interpreterModeActionsIT.setPythonParagraph(2, "print(user)");
        collector.checkThat("The output field paragraph contains", driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")).getText(), CoreMatchers.equalTo("user1"));
        String resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsPython, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python process is", resultProcessNum, CoreMatchers.equalTo("1"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsInterpreter, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python interpreter process is", resultProcessNum, CoreMatchers.equalTo("1"));
        interpreterModeActionsIT.logoutUser("user1");
        // step 3: (user2) login, create a new note, run two paragraph with 'python', check result, check process, logout
        // paragraph: Check if the result is 'user2' in the second paragraph
        // System: Check if the number of python interpreter process is '1'
        // System: Check if the number of python process is '2'
        interpreterModeActionsIT.authenticationUser("user2", "password3");
        locator = By.xpath("//div[contains(@class, 'col-md-4')]/div/h5/a[contains(.,'Create new" + " note')]");
        element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            createNewNote();
        }
        String user2noteId = driver.getCurrentUrl().substring(driver.getCurrentUrl().lastIndexOf("/") + 1);
        waitForParagraph(1, "READY");
        interpreterModeActionsIT.setPythonParagraph(1, "user=\"user2\"");
        waitForParagraph(2, "READY");
        interpreterModeActionsIT.setPythonParagraph(2, "print(user)");
        collector.checkThat("The output field paragraph contains", driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")).getText(), CoreMatchers.equalTo("user2"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsPython, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python process is", resultProcessNum, CoreMatchers.equalTo("2"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsInterpreter, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python interpreter process is", resultProcessNum, CoreMatchers.equalTo("1"));
        interpreterModeActionsIT.logoutUser("user2");
        // step 4: (user1) login, come back note user1 made, run second paragraph, check result,
        // restart python interpreter in note, check process again, logout
        // paragraph: Check if the result is 'user1' in the second paragraph
        // System: Check if the number of python interpreter process is '1'
        // System: Check if the number of python process is '1'
        interpreterModeActionsIT.authenticationUser("user1", "password2");
        locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user1noteId + "')]");
        element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user1noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        }
        runParagraph(2);
        try {
            waitForParagraph(2, "FINISHED");
        } catch (TimeoutException e) {
            waitForParagraph(2, "ERROR");
            collector.checkThat("Exception in InterpreterModeActionsIT while running Python Paragraph", "ERROR", CoreMatchers.equalTo("FINISHED"));
        }
        collector.checkThat("The output field paragraph contains", driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")).getText(), CoreMatchers.equalTo("user1"));
        clickAndWait(By.xpath("//*[@id='actionbar']//span[contains(@uib-tooltip, 'Interpreter binding')]"));
        clickAndWait(By.xpath("//div[@data-ng-repeat='item in interpreterBindings' and contains(., 'python')]//a"));
        clickAndWait(By.xpath("//div[@class='modal-dialog']" + "[contains(.,'Do you want to restart python interpreter?')]" + "//div[@class='bootstrap-dialog-footer-buttons']//button[contains(., 'OK')]"));
        locator = By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to restart python interpreter?')]");
        LOG.info("Holding on until if interpreter restart dialog is disappeared or not in testPerUserScopedAction");
        boolean invisibilityStatus = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.invisibilityOfElementLocated(locator));
        if (invisibilityStatus == false) {
            assertTrue("interpreter setting dialog visibility status", invisibilityStatus);
        }
        locator = By.xpath("//*[@id='actionbar']//span[contains(@uib-tooltip, 'Interpreter binding')]");
        element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            clickAndWait(By.xpath("//*[@id='actionbar']//span[contains(@uib-tooltip, 'Interpreter binding')]"));
        }
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsPython, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python process is", resultProcessNum, CoreMatchers.equalTo("1"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsInterpreter, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python interpreter process is", resultProcessNum, CoreMatchers.equalTo("1"));
        interpreterModeActionsIT.logoutUser("user1");
        // step 5: (user2) login, come back note user2 made, restart python interpreter in note, check process, logout
        // System: Check if the number of python interpreter process is '0'
        // System: Check if the number of python process is '0'
        interpreterModeActionsIT.authenticationUser("user2", "password3");
        locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user2noteId + "')]");
        element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            clickAndWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user2noteId + "')]"));
        }
        clickAndWait(By.xpath("//*[@id='actionbar']//span[contains(@uib-tooltip, 'Interpreter binding')]"));
        clickAndWait(By.xpath("//div[@data-ng-repeat='item in interpreterBindings' and contains(., 'python')]//a"));
        clickAndWait(By.xpath("//div[@class='modal-dialog']" + "[contains(.,'Do you want to restart python interpreter?')]" + "//div[@class='bootstrap-dialog-footer-buttons']//button[contains(., 'OK')]"));
        locator = By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to restart python interpreter?')]");
        LOG.info("Holding on until if interpreter restart dialog is disappeared or not in testPerUserScopedAction");
        invisibilityStatus = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.invisibilityOfElementLocated(locator));
        if (invisibilityStatus == false) {
            assertTrue("interpreter setting dialog visibility status", invisibilityStatus);
        }
        locator = By.xpath("//*[@id='actionbar']//span[contains(@uib-tooltip, 'Interpreter binding')]");
        element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            clickAndWait(By.xpath("//*[@id='actionbar']//span[contains(@uib-tooltip, 'Interpreter binding')]"));
        }
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsPython, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python process is", resultProcessNum, CoreMatchers.equalTo("0"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsInterpreter, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python interpreter process is", resultProcessNum, CoreMatchers.equalTo("0"));
        interpreterModeActionsIT.logoutUser("user2");
        // step 6: (user1) login, come back note user1 made, run first paragraph,logout
        // (user2) login, come back note user2 made, run first paragraph, check process, logout
        // System: Check if the number of python process is '2'
        // System: Check if the number of python interpreter process is '1'
        interpreterModeActionsIT.authenticationUser("user1", "password2");
        locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user1noteId + "')]");
        element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user1noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        }
        waitForParagraph(1, "FINISHED");
        runParagraph(1);
        try {
            waitForParagraph(1, "FINISHED");
        } catch (TimeoutException e) {
            waitForParagraph(1, "ERROR");
            collector.checkThat("Exception in InterpreterModeActionsIT while running Python Paragraph", "ERROR", CoreMatchers.equalTo("FINISHED"));
        }
        interpreterModeActionsIT.logoutUser("user1");
        interpreterModeActionsIT.authenticationUser("user2", "password3");
        locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user2noteId + "')]");
        element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user2noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        }
        runParagraph(1);
        try {
            waitForParagraph(1, "FINISHED");
        } catch (TimeoutException e) {
            waitForParagraph(1, "ERROR");
            collector.checkThat("Exception in InterpreterModeActionsIT while running Python Paragraph", "ERROR", CoreMatchers.equalTo("FINISHED"));
        }
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsPython, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python process is", resultProcessNum, CoreMatchers.equalTo("2"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsInterpreter, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python interpreter process is", resultProcessNum, CoreMatchers.equalTo("1"));
        interpreterModeActionsIT.logoutUser("user2");
        // step 7: (admin) login, restart python interpreter in interpreter tab, check process, logout
        // System: Check if the number of python interpreter process is 0
        // System: Check if the number of python process is 0
        interpreterModeActionsIT.authenticationUser("admin", "password1");
        pollingWait(By.xpath("//div/button[contains(@class, 'nav-btn dropdown-toggle ng-scope')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        clickAndWait(By.xpath("//li/a[contains(@href, '#/interpreter')]"));
        pollingWait(By.xpath("//input[contains(@ng-model, 'searchInterpreter')]"), MAX_BROWSER_TIMEOUT_SEC).sendKeys("python");
        ZeppelinITUtils.sleep(500, false);
        clickAndWait(By.xpath("//div[contains(@id, 'python')]" + "//button[contains(@ng-click, 'restartInterpreterSetting(setting.id)')]"));
        clickAndWait(By.xpath("//div[@class='modal-dialog']" + "[contains(.,'Do you want to restart this interpreter?')]" + "//div[@class='bootstrap-dialog-footer-buttons']//button[contains(., 'OK')]"));
        locator = By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to restart python interpreter?')]");
        LOG.info("Holding on until if interpreter restart dialog is disappeared or not in testPerUserScopedAction");
        invisibilityStatus = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.invisibilityOfElementLocated(locator));
        if (invisibilityStatus == false) {
            assertTrue("interpreter setting dialog visibility status", invisibilityStatus);
        }
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsPython, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python process is", resultProcessNum, CoreMatchers.equalTo("0"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsInterpreter, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python interpreter process is", resultProcessNum, CoreMatchers.equalTo("0"));
        interpreterModeActionsIT.logoutUser("admin");
    } catch (Exception e) {
        handleException("Exception in InterpreterModeActionsIT while testPerUserScopedAction ", e);
    }
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) By(org.openqa.selenium.By) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.junit.Test)

Example 67 with TimeoutException

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

the class InterpreterModeActionsIT method testGloballyAction.

@Test
public void testGloballyAction() throws Exception {
    try {
        // step 1: (admin) login, set 'globally in shared' mode of python interpreter, logout
        InterpreterModeActionsIT interpreterModeActionsIT = new InterpreterModeActionsIT();
        interpreterModeActionsIT.authenticationUser("admin", "password1");
        pollingWait(By.xpath("//div/button[contains(@class, 'nav-btn dropdown-toggle ng-scope')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        clickAndWait(By.xpath("//li/a[contains(@href, '#/interpreter')]"));
        pollingWait(By.xpath("//input[contains(@ng-model, 'searchInterpreter')]"), MAX_BROWSER_TIMEOUT_SEC).sendKeys("python");
        ZeppelinITUtils.sleep(500, false);
        clickAndWait(By.xpath("//div[contains(@id, 'python')]//button[contains(@ng-click, 'valueform.$show();\n" + "                  copyOriginInterpreterSettingProperties(setting.id)')]"));
        clickAndWait(By.xpath("//div[contains(@id, 'python')]/div[2]/div/div/div[1]/span[1]/button"));
        clickAndWait(By.xpath("//div[contains(@id, 'python')]//li/a[contains(.,'Globally')]"));
        JavascriptExecutor jse = (JavascriptExecutor) driver;
        jse.executeScript("window.scrollBy(0,250)", "");
        ZeppelinITUtils.sleep(500, false);
        clickAndWait(By.xpath("//div[contains(@id, 'python')]//div/form/button[contains(@type, 'submit')]"));
        clickAndWait(By.xpath("//div[@class='modal-dialog']//div[@class='bootstrap-dialog-footer-buttons']//button[contains(., 'OK')]"));
        clickAndWait(By.xpath("//a[@class='navbar-brand navbar-title'][contains(@href, '#/')]"));
        interpreterModeActionsIT.logoutUser("admin");
        // step 2: (user1) login, create a new note, run two paragraph with 'python', check result, check process, logout
        // paragraph: Check if the result is 'user1' in the second paragraph
        // System: Check if the number of python interpreter process is '1'
        // System: Check if the number of python process is '1'
        interpreterModeActionsIT.authenticationUser("user1", "password2");
        By locator = By.xpath("//div[contains(@class, 'col-md-4')]/div/h5/a[contains(.,'Create new" + " note')]");
        WebElement element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            createNewNote();
        }
        String user1noteId = driver.getCurrentUrl().substring(driver.getCurrentUrl().lastIndexOf("/") + 1);
        waitForParagraph(1, "READY");
        interpreterModeActionsIT.setPythonParagraph(1, "user=\"user1\"");
        waitForParagraph(2, "READY");
        interpreterModeActionsIT.setPythonParagraph(2, "print(user)");
        collector.checkThat("The output field paragraph contains", driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")).getText(), CoreMatchers.equalTo("user1"));
        String resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsPython, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python process is", resultProcessNum, CoreMatchers.equalTo("1"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsInterpreter, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python interpreter process is", resultProcessNum, CoreMatchers.equalTo("1"));
        interpreterModeActionsIT.logoutUser("user1");
        // step 3: (user2) login, create a new note, run two paragraph with 'python', check result, check process, logout
        // paragraph: Check if the result is 'user2' in the second paragraph
        // System: Check if the number of python interpreter process is '1'
        // System: Check if the number of python process is '1'
        interpreterModeActionsIT.authenticationUser("user2", "password3");
        locator = By.xpath("//div[contains(@class, 'col-md-4')]/div/h5/a[contains(.,'Create new" + " note')]");
        element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            createNewNote();
        }
        waitForParagraph(1, "READY");
        interpreterModeActionsIT.setPythonParagraph(1, "user=\"user2\"");
        waitForParagraph(2, "READY");
        interpreterModeActionsIT.setPythonParagraph(2, "print(user)");
        collector.checkThat("The output field paragraph contains", driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class, 'text plainTextContent')]")).getText(), CoreMatchers.equalTo("user2"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsPython, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python process is", resultProcessNum, CoreMatchers.equalTo("1"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsInterpreter, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python interpreter process is", resultProcessNum, CoreMatchers.equalTo("1"));
        interpreterModeActionsIT.logoutUser("user2");
        // step 4: (user1) login, come back note user1 made, run second paragraph, check result, check process,
        // restart python interpreter, check process again, logout
        // paragraph: Check if the result is 'user2' in the second paragraph
        // System: Check if the number of python interpreter process is '1'
        // System: Check if the number of python process is '1'
        interpreterModeActionsIT.authenticationUser("user1", "password2");
        locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user1noteId + "')]");
        element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user1noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        }
        waitForParagraph(2, "FINISHED");
        runParagraph(2);
        try {
            waitForParagraph(2, "FINISHED");
        } catch (TimeoutException e) {
            waitForParagraph(2, "ERROR");
            collector.checkThat("Exception in InterpreterModeActionsIT while running Python Paragraph", "ERROR", CoreMatchers.equalTo("FINISHED"));
        }
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsPython, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python process is", resultProcessNum, CoreMatchers.equalTo("1"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsInterpreter, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python interpreter process is", resultProcessNum, CoreMatchers.equalTo("1"));
        clickAndWait(By.xpath("//*[@id='actionbar']//span[contains(@uib-tooltip, 'Interpreter binding')]"));
        clickAndWait(By.xpath("//div[@data-ng-repeat='item in interpreterBindings' and contains(., 'python')]//a"));
        clickAndWait(By.xpath("//div[@class='modal-dialog']" + "[contains(.,'Do you want to restart python interpreter?')]" + "//div[@class='bootstrap-dialog-footer-buttons']//button[contains(., 'OK')]"));
        locator = By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to restart python interpreter?')]");
        LOG.info("Holding on until if interpreter restart dialog is disappeared or not testGloballyAction");
        boolean invisibilityStatus = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.invisibilityOfElementLocated(locator));
        if (invisibilityStatus == false) {
            assertTrue("interpreter setting dialog visibility status", invisibilityStatus);
        }
        locator = By.xpath("//*[@id='actionbar']//span[contains(@uib-tooltip, 'Interpreter binding')]");
        element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC)).until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            clickAndWait(By.xpath("//*[@id='actionbar']//span[contains(@uib-tooltip, 'Interpreter binding')]"));
        }
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsPython, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python process is", resultProcessNum, CoreMatchers.equalTo("0"));
        resultProcessNum = (String) CommandExecutor.executeCommandLocalHost(cmdPsInterpreter, false, ProcessData.Types_Of_Data.OUTPUT);
        resultProcessNum = resultProcessNum.trim().replaceAll("\n", "");
        collector.checkThat("The number of python interpreter process is", resultProcessNum, CoreMatchers.equalTo("0"));
        interpreterModeActionsIT.logoutUser("user1");
    } catch (Exception e) {
        handleException("Exception in InterpreterModeActionsIT while testGloballyAction ", e);
    }
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) By(org.openqa.selenium.By) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.junit.Test)

Example 68 with TimeoutException

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

the class PersonalizeActionsIT method testGraphAction.

@Test
public void testGraphAction() throws Exception {
    try {
        // step 1 : (admin) create a new note, run a paragraph, change active graph to 'Bar chart', turn on personalized mode
        AuthenticationIT authenticationIT = new AuthenticationIT();
        authenticationIT.authenticationUser("admin", "password1");
        By locator = By.xpath("//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + " note')]");
        WebDriverWait wait = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC);
        WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            createNewNote();
        }
        String noteId = driver.getCurrentUrl().substring(driver.getCurrentUrl().lastIndexOf("/") + 1);
        setTextOfParagraph(1, "%python print(\"%table " + "name\\\\tsize\\\\n" + "sun\\\\t100\\\\n" + "moon\\\\t10\")");
        runParagraph(1);
        try {
            waitForParagraph(1, "FINISHED");
        } catch (TimeoutException e) {
            waitForParagraph(1, "ERROR");
            collector.checkThat("Exception in PersonalizeActionsIT while testGraphAction, status of 1st Spark Paragraph ", "ERROR", CoreMatchers.equalTo("FINISHED"));
        }
        pollingWait(By.xpath("//*[@id='actionbar']" + "//button[contains(@uib-tooltip, 'Switch to personal mode')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" + "]//div[@class='modal-footer']//button[contains(.,'OK')]"));
        pollingWait(By.xpath(getParagraphXPath(1) + "//button[contains(@uib-tooltip, 'Bar Chart')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        collector.checkThat("The output of graph mode is changed", driver.findElement(By.xpath(getParagraphXPath(1) + "//button[contains(@class," + "'btn btn-default btn-sm ng-binding ng-scope active')]//i")).getAttribute("class"), CoreMatchers.equalTo("fa fa-bar-chart"));
        authenticationIT.logoutUser("admin");
        driver.navigate().refresh();
        // step 2 : (user1) make sure it is on personalized mode and active graph is 'Bar chart',
        // try to change active graph to 'Table' and then check result
        authenticationIT.authenticationUser("user1", "password2");
        locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]");
        element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        }
        collector.checkThat("The personalized mode enables", driver.findElement(By.xpath("//*[@id='actionbar']" + "//button[contains(@class, 'btn btn-default btn-xs ng-scope ng-hide')]")).getAttribute("uib-tooltip"), CoreMatchers.equalTo("Switch to personal mode (owner can change)"));
        collector.checkThat("Make sure the output of graph mode is", driver.findElement(By.xpath(getParagraphXPath(1) + "//button[contains(@class," + "'btn btn-default btn-sm ng-binding ng-scope active')]//i")).getAttribute("class"), CoreMatchers.equalTo("fa fa-bar-chart"));
        pollingWait(By.xpath(getParagraphXPath(1) + "//button[contains(@uib-tooltip, 'Table')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        collector.checkThat("Change to table", driver.findElement(By.xpath(getParagraphXPath(1) + "//button[contains(@class," + "'btn btn-default btn-sm ng-binding ng-scope active')]//i")).getAttribute("class"), CoreMatchers.equalTo("fa fa-table"));
        authenticationIT.logoutUser("user1");
        driver.navigate().refresh();
        // step 3: (admin) Admin view is still table because of it's personalized!
        authenticationIT.authenticationUser("admin", "password1");
        locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]");
        element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        }
        collector.checkThat("Make sure the output of graph mode is", driver.findElement(By.xpath(getParagraphXPath(1) + "//button[contains(@class," + "'btn btn-default btn-sm ng-binding ng-scope active')]//i")).getAttribute("class"), CoreMatchers.equalTo("fa fa-bar-chart"));
        authenticationIT.logoutUser("admin");
    } catch (Exception e) {
        handleException("Exception in PersonalizeActionsIT while testGraphAction ", e);
    }
}
Also used : By(org.openqa.selenium.By) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement) IOException(java.io.IOException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.junit.Test)

Example 69 with TimeoutException

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

the class PersonalizeActionsIT method testDynamicFormAction.

@Test
public void testDynamicFormAction() throws Exception {
    try {
        // step 1 : (admin) login, create a new note, run a paragraph with data of spark tutorial, logout.
        AuthenticationIT authenticationIT = new AuthenticationIT();
        authenticationIT.authenticationUser("admin", "password1");
        By locator = By.xpath("//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + " note')]");
        WebDriverWait wait = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC);
        WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            createNewNote();
        }
        String noteId = driver.getCurrentUrl().substring(driver.getCurrentUrl().lastIndexOf("/") + 1);
        setTextOfParagraph(1, "%spark println(\"Status: \"+z.textbox(\"name\", \"Before\")) ");
        runParagraph(1);
        try {
            waitForParagraph(1, "FINISHED");
        } catch (TimeoutException e) {
            waitForParagraph(1, "ERROR");
            collector.checkThat("Exception in PersonalizeActionsIT while testDynamicFormAction, status of 1st Spark Paragraph ", "ERROR", CoreMatchers.equalTo("FINISHED"));
        }
        collector.checkThat("The output of graph mode is changed", driver.findElement(By.xpath(getParagraphXPath(1) + "//input[contains(@name, 'name')]")).getAttribute("value"), CoreMatchers.equalTo("Before"));
        pollingWait(By.xpath("//*[@id='actionbar']" + "//button[contains(@uib-tooltip, 'Switch to personal mode')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" + "]//div[@class='modal-footer']//button[contains(.,'OK')]"));
        authenticationIT.logoutUser("admin");
        // step 2 : (user1) make sure it is on personalized mode and  dynamic form value is 'Before',
        // try to change dynamic form value to 'After' and then check result
        authenticationIT.authenticationUser("user1", "password2");
        locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]");
        element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
        if (element.isDisplayed()) {
            pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC).click();
        }
        collector.checkThat("The personalized mode enables", driver.findElement(By.xpath("//*[@id='actionbar']" + "//button[contains(@class, 'btn btn-default btn-xs ng-scope ng-hide')]")).getAttribute("uib-tooltip"), CoreMatchers.equalTo("Switch to personal mode (owner can change)"));
        collector.checkThat("The output of graph mode is changed", driver.findElement(By.xpath(getParagraphXPath(1) + "//input[contains(@name, 'name')]")).getAttribute("value"), CoreMatchers.equalTo("Before"));
        pollingWait(By.xpath(getParagraphXPath(1) + "//input[contains(@name, 'name')]"), MAX_BROWSER_TIMEOUT_SEC).clear();
        pollingWait(By.xpath(getParagraphXPath(1) + "//input[contains(@name, 'name')]"), MAX_BROWSER_TIMEOUT_SEC).sendKeys("After");
        runParagraph(1);
        try {
            waitForParagraph(1, "FINISHED");
        } catch (TimeoutException e) {
            waitForParagraph(1, "ERROR");
            collector.checkThat("Exception in PersonalizeActionsIT while testDynamicFormAction, status of 1st Spark Paragraph ", "ERROR", CoreMatchers.equalTo("FINISHED"));
        }
        collector.checkThat("The output of graph mode is changed", driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'text plainTextContent')]")).getText(), CoreMatchers.equalTo("Status: Before"));
        authenticationIT.logoutUser("user1");
    } catch (Exception e) {
        handleException("Exception in PersonalizeActionsIT while testGraphAction ", e);
    }
}
Also used : By(org.openqa.selenium.By) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement) IOException(java.io.IOException) TimeoutException(org.openqa.selenium.TimeoutException) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.junit.Test)

Example 70 with TimeoutException

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

the class ZeppelinIT method testSparkInterpreterDependencyLoading.

// It is a flaky test, disable it temporary, should fix it later. ZEPPELIN-5528
// @Test
public void testSparkInterpreterDependencyLoading() throws Exception {
    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)

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