List of usage examples for org.openqa.selenium JavascriptExecutor executeScript
Object executeScript(String script, Object... args);
From source file:javax.portlet.tck.driver.TCKTestDriver.java
License:Apache License
/** * Tries to access the page for the test case. Looks for the page link * and clicks it, waiting for the page to load. * //from w w w . j a va2 s. c o m * @return a list of elements for the TC (should only be one) */ protected List<WebElement> accessPage() throws Exception { List<WebElement> wels = driver.findElements(By.linkText(page)); debugLines.add(" Access page, link found: " + !wels.isEmpty() + ", page===" + page + "==="); if (wels.isEmpty()) { // retry through login page debugLines.add("accessPage: debugLines: logging in ... "); login(); wels = driver.findElements(By.linkText(page)); if (wels.isEmpty()) { throw new Exception("Page " + page + ": link could not be found."); } } WebElement wel = wels.get(0); if (scroll) { JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver; javascriptExecutor.executeScript( "window.scrollTo(0, (arguments[0].getBoundingClientRect().top + window.pageYOffset) - (window.innerHeight / 2));", wel); } click(wel); WebDriverWait wdw = new WebDriverWait(driver, timeout); wdw.until(ExpectedConditions.visibilityOfElementLocated(By.name(tcName))); wels = driver.findElements(By.name(tcName)); if (wels.isEmpty()) { throw new Exception("For test case " + tcName + ": no elements found."); } return wels; }
From source file:javax.portlet.tck.driver.TCKTestDriver.java
License:Apache License
/** * Looks for a link or button that can be clicked for the TC and clicks it if found. * //w ww . j a v a2 s .c om * First looks for a test case setup link or button and clicks it if found. Then it * looks for a test case execution link and clicks it if found. * * @return web element list containing the test case results. * @throws Exception */ @SuppressWarnings("unused") protected List<WebElement> processClickable(List<WebElement> wels) throws Exception { String setupId = tcName + Constants.SETUP_ID; String actionId = tcName + Constants.CLICK_ID; String resultId = tcName + Constants.RESULT_ID; String detailId = tcName + Constants.DETAIL_ID; String asyncId = tcName + Constants.ASYNC_ID; String notreadyId = tcName + Constants.NOTREADY_ID; List<WebElement> tcels = null; for (WebElement wel : wels) { tcels = wel.findElements(By.id(setupId)); if (!tcels.isEmpty()) break; } debugLines.add(" Setup link found: " + ((tcels != null) && !tcels.isEmpty())); // If were dealing with async, make sure the JavaScript is initialized List<WebElement> acels = driver.findElements(By.id(asyncId)); debugLines.add(" Async elements found: " + ((acels != null) && !acels.isEmpty())); if (acels != null && !acels.isEmpty()) { WebDriverWait wdw = new WebDriverWait(driver, timeout); wdw.until(ExpectedConditions.invisibilityOfElementLocated(By.id(notreadyId))); debugLines.add(" Async elements are now ready."); } // Click setup link if found if ((tcels != null) && !tcels.isEmpty()) { WebElement wel = tcels.get(0); if (scroll) { JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver; javascriptExecutor.executeScript( "window.scrollTo(0, (arguments[0].getBoundingClientRect().top + window.pageYOffset) - (window.innerHeight / 2));", wel); } try { wel.click(); } catch (StaleElementReferenceException e) { System.out.println("setup link: " + e.getClass().getName() + " caught when trying to use WebElements found with " + tcName); wels = driver.findElements(By.name(tcName)); for (WebElement welly : wels) { tcels = welly.findElements(By.id(setupId)); if (!tcels.isEmpty()) break; } wel = tcels.get(0); wel.click(); } debugLines.add(" Clicked setup link."); WebDriverWait wdw = new WebDriverWait(driver, timeout); String expr = "//*[@id='" + resultId + "'] | //*[@id='" + actionId + "']"; debugLines.add(" xpath string: ===" + expr + "==="); wdw.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(expr))); wels = driver.findElements(By.name(tcName)); debugLines.add(" Found elements: " + (!wels.isEmpty())); List<WebElement> xels = driver.findElements(By.xpath(expr)); for (WebElement w : xels) { debugLines.add(" Element: " + w.getTagName() + ", id=" + w.getAttribute("id")); } } // Now click the action link, if present for (WebElement wel : wels) { tcels = wel.findElements(By.id(actionId)); if (!tcels.isEmpty()) break; } debugLines.add(" Clickable link found: " + ((tcels != null) && !tcels.isEmpty())); if (tcels != null && !tcels.isEmpty()) { WebElement wel = tcels.get(0); if (scroll) { JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver; javascriptExecutor.executeScript( "window.scrollTo(0, (arguments[0].getBoundingClientRect().top + window.pageYOffset) - (window.innerHeight / 2));", wel); } try { wel.click(); } catch (StaleElementReferenceException e) { System.out.println("action link: " + e.getClass().getName() + " caught when trying to use WebElements found with " + tcName); wels = driver.findElements(By.name(tcName)); for (WebElement welly : wels) { tcels = welly.findElements(By.id(actionId)); if (!tcels.isEmpty()) break; } wel = tcels.get(0); wel.click(); } WebDriverWait wdw = new WebDriverWait(driver, timeout); wdw.until(ExpectedConditions.visibilityOfElementLocated(By.id(resultId))); wels = driver.findElements(By.name(tcName)); if ((wels == null) || wels.isEmpty()) { throw new Exception("Test case " + tcName + " failed. No results after action link click."); } } return wels; }
From source file:minium.web.internal.drivers.DefaultJavascriptInvoker.java
License:Apache License
@SuppressWarnings("unchecked") protected <T> T doInvoke(JavascriptExecutor wd, boolean async, String expression, Object... args) { try {// w ww .j av a 2s .com Object[] fullArgs = createLightInvokerScriptArgs(async, args); if (LOGGER.isTraceEnabled()) { LOGGER.trace("About to invoke light invoker:"); LOGGER.trace("async: {}", async); LOGGER.trace("expression: {}", expression); LOGGER.trace("fullArgs: {}", fullArgs); } Object result = async ? wd.executeAsyncScript(lightInvokerScript(expression), fullArgs) : wd.executeScript(lightInvokerScript(expression), fullArgs); LOGGER.trace("result: {}", result); List<?> response = getValidResponse(result); ResponseType type = ResponseType.of((String) response.get(0)); if (type == ResponseType.MINIUM_UNDEFINED) { // minium is not defined yet, we need to send all the necessary javascript fullArgs = createFullInvokerScriptArgs(async, args); if (LOGGER.isTraceEnabled()) { LOGGER.trace("About to invoke full invoker:"); LOGGER.trace("fullArgs: {}", fullArgs); } result = async ? wd.executeAsyncScript(fullInvokerScript(expression), fullArgs) : wd.executeScript(fullInvokerScript(expression), fullArgs); LOGGER.trace("result: {}", result); response = getValidResponse(result); type = ResponseType.of((String) response.get(0)); } return (T) extractValue(type, response); } catch (WebDriverException e) { throw new JavascriptInvocationFailedException(format("Failed invoking expression:\n", expression), e); } }
From source file:nikoladasm.examples.aspark_angularjs_rest.UITest.java
License:Open Source License
private void changeColor(String color, int interval, WebElement element, JavascriptExecutor js) { js.executeScript("arguments[0].style.backgroundColor = '" + color + "'", element); try {/*from ww w . j a v a2 s. c om*/ Thread.sleep(interval); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:org.apache.falcon.regression.ui.search.PageHeader.java
License:Apache License
/** * Useful in cases when selenium fails to click a link due to it's bugs. *//* w w w . j ava 2 s .co m*/ private void clickLink(WebElement link) { JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].click();", link); }
From source file:org.apache.zeppelin.integration.InterpreterModeActionsIT.java
License:Apache License
@Test public void testGloballyAction() throws Exception { try {/*from www . j a v a 2s . 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 {//from w w w . java2 s . c om //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 {//from w ww. j a v a2 s.c om //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.auraframework.integration.test.AccessChecksUITest.java
License:Apache License
private void clickCreateComponentButton() { getAuraUITestingUtil().waitForElement(By.className("testComponentAccess")); // Workaround for Webdriver tests run on Firefox. Calling WebElement.click() fails to click the button in some // situations but executing a javascript click like so seems to work. WebElement webElement = getDriver().findElement(By.className("testComponentAccess")); JavascriptExecutor executor = (JavascriptExecutor) getDriver(); executor.executeScript("arguments[0].click();", webElement); }
From source file:org.auraframework.integration.test.error.ErrorHandlingLoggingUITest.java
License:Apache License
/** * This is a workaround for click on Firefox Webdriver tests. *///from w ww . ja v a 2s .co m private void findAndClickElement(By locator) { getAuraUITestingUtil().waitForElement(locator); // Workaround for Webdriver tests run on Firefox. Calling WebElement.click() fails to click the button in some // situations but executing a javascript click like so seems to work. WebElement webElement = getDriver().findElement(locator); JavascriptExecutor executor = (JavascriptExecutor) getDriver(); executor.executeScript("arguments[0].click();", webElement); }