Example usage for org.openqa.selenium.support.ui ExpectedConditions invisibilityOfElementLocated

List of usage examples for org.openqa.selenium.support.ui ExpectedConditions invisibilityOfElementLocated

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui ExpectedConditions invisibilityOfElementLocated.

Prototype

public static ExpectedCondition<Boolean> invisibilityOfElementLocated(final By locator) 

Source Link

Document

An expectation for checking that an element is either invisible or not present on the DOM.

Usage

From source file:org.alfresco.po.PageElement.java

License:Open Source License

/**
 * Wait until the invisibility of given Element for given seconds.
 * @param locator CSS Locator/*from   w  w w.  j  av  a 2 s .c  o m*/
 * @param timeOutInSeconds Timeout In Seconds
 */
public void waitUntilElementDisappears(By locator, long timeOutInSeconds) {
    if (locator == null) {
        throw new IllegalArgumentException(LOCATOR_REQUIRED_ERR_MSG);
    }
    WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
    wait.until(ExpectedConditions.invisibilityOfElementLocated(locator));
}

From source file:org.alfresco.po.RenderElement.java

License:Open Source License

/**
 * Wait until the invisibility of given Element for given seconds.
 * @param driver WebDriver//from ww w. j ava  2 s. co m
 * @param locator CSS Locator
 * @param timeOutInSeconds Timeout In Seconds
 */
public void waitUntilElementDisappears(WebDriver driver, By locator, long timeOutInSeconds) {
    if (locator == null) {
        throw new IllegalArgumentException(LOCATOR_REQUIRED_ERR_MSG);
    }
    WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
    wait.until(ExpectedConditions.invisibilityOfElementLocated(locator));
}

From source file:org.alfresco.po.share.page.Message.java

License:Open Source License

/**
 * Wait for message to be hidden//from   w ww .j  a  v a  2s  . com
 */
public void waitUntillHidden() {
    boolean shown = false;
    try {
        webDriverWait(1).until(ExpectedConditions.visibilityOfElementLocated(MESSAGE_SELECTOR));
        shown = true;
    } catch (TimeoutException exception) {
        // do nothing and carry on           
    }

    if (shown == true) {
        try {
            webDriverWait().until(ExpectedConditions.invisibilityOfElementLocated(MESSAGE_SELECTOR));
        } catch (TimeoutException exception) {
            // do nothing and carry on
        }
    }
}

From source file:org.apache.zeppelin.AbstractZeppelinIT.java

License:Apache License

protected void createNewNote() {
    clickAndWait(//ww w .java2 s .co m
            By.xpath("//div[contains(@class, \"col-md-4\")]/div/h5/a[contains(.,'Create new" + " note')]"));

    WebDriverWait block = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC);
    block.until(ExpectedConditions.visibilityOfElementLocated(By.id("noteCreateModal")));
    clickAndWait(By.id("createNoteButton"));
    block.until(ExpectedConditions.invisibilityOfElementLocated(By.id("createNoteButton")));
}

From source file:org.apache.zeppelin.integration.InterpreterModeActionsIT.java

License:Apache License

@Test
public void testGloballyAction() throws Exception {
    try {/*w  ww  .j a v a 2  s. c  o m*/
        //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);
    }
}

From source file:org.apache.zeppelin.integration.InterpreterModeActionsIT.java

License:Apache License

@Test
public void testPerUserScopedAction() throws Exception {
    try {/*  w  w w  .  j  a v  a2s  .c o m*/
        //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()) {
            pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user2noteId + "')]"),
                    MAX_BROWSER_TIMEOUT_SEC).click();
        }
        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);
    }
}

From source file:org.apache.zeppelin.integration.InterpreterModeActionsIT.java

License:Apache License

@Test
public void testPerUserIsolatedAction() throws Exception {
    try {//w  w  w. j a v  a2s.c  o  m
        //step 1: (admin) login, set 'Per user in isolated' 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(.,'isolated 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 '2'
        //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("2"));
        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 testPerUserIsolatedAction");
        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()) {
            pollingWait(By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user2noteId + "')]"),
                    MAX_BROWSER_TIMEOUT_SEC).click();
        }
        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 testPerUserIsolatedAction");
        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 '2'
        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("2"));
        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 testPerUserIsolatedAction");
        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 testPerUserIsolatedAction ", e);
    }
}

From source file:org.cerberus.service.webdriver.impl.WebDriverService.java

License:Open Source License

@Override
public boolean isElementNotVisible(Session session, Identifier identifier) {
    By locator = this.getBy(identifier);
    MyLogger.log(WebDriverService.class.getName(), Level.DEBUG, "Waiting for Element to be not visible : "
            + identifier.getIdentifier() + "=" + identifier.getLocator());
    try {//from  w  w  w  . j  a va  2s .  co m
        WebDriverWait wait = new WebDriverWait(session.getDriver(),
                TimeUnit.MILLISECONDS.toSeconds(session.getCerberus_selenium_wait_element()));
        return wait.until(ExpectedConditions.invisibilityOfElementLocated(locator));
    } catch (TimeoutException exception) {
        MyLogger.log(WebDriverService.class.getName(), Level.FATAL,
                "Exception waiting for element to be not visible :" + exception);
        return false;
    }
}

From source file:org.eclipse.che.selenium.debugger.NodeJsDebugTest.java

License:Open Source License

@Test(priority = 0)
public void debugNodeJsTest() throws ExecutionException, JsonParseException, InterruptedException {
    String nameOfDebugCommand = "check_node_js_debug";
    menu.runCommand(TestMenuCommandsConstants.Run.RUN_MENU,
            TestMenuCommandsConstants.Run.EDIT_DEBUG_CONFIGURATION);
    debugConfig.createConfig(nameOfDebugCommand);
    menuPageObj.runCommand(TestMenuCommandsConstants.Run.RUN_MENU, TestMenuCommandsConstants.Run.DEBUG,
            TestMenuCommandsConstants.Run.DEBUG + "/" + nameOfDebugCommand);
    notifications.waitExpectedMessageOnProgressPanelAndClosed("Remote debugger connected");
    editorPageObj.waitTabFileWithSavedStatus(APP_FILE);
    editorPageObj.waitActiveEditor();/*from  w  w  w .j a  v  a2 s.c  o  m*/
    debugPanel.waitDebugHighlightedText("var greetings = require(\"./greetings.js\");");
    checkDebugStepsFeatures();
    checkEvaluationFeatures();

    //disconnect session, check highlighter is disappear
    debugPanel.clickOnButton(DebuggerButtonsPanel.RESUME_BTN_ID);
    new WebDriverWait(ide.driver(), REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
            .until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[text()='{/app.js:13} ']")));
    debugPanel.waitBreakPointsPanelIsEmpty();
}

From source file:org.eclipse.che.selenium.pageobject.ConfigureClasspath.java

License:Open Source License

/** wait the 'Configure Classpath' form is closed */
public void waitConfigureClasspathFormIsClosed() {
    loader.waitOnClosed();/*from  w w  w.  j  a  v  a2  s  .co m*/
    new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
            .until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(CONFIGURE_CLASSPATH_FORM)));
}