List of usage examples for org.openqa.selenium Keys ENTER
Keys ENTER
To view the source code for org.openqa.selenium Keys ENTER.
Click Source Link
From source file:org.alfresco.po.share.site.document.EditHtmlDocumentPage.java
License:Open Source License
/** * Edit the editor, enter new text line, count the lines and save it. * /*from www . j av a 2 s .com*/ * @param txtLine String */ public void editText(String txtLine) { try { driver.switchTo().frame(IFRAME_ID); WebElement element = findAndWait(By.cssSelector("#tinymce")); element.sendKeys(txtLine); element.sendKeys(Keys.chord(Keys.ENTER)); driver.switchTo().defaultContent(); } catch (TimeoutException toe) { logger.error("Tinymce Editor is not found", toe); } }
From source file:org.alfresco.po.share.site.document.EditHtmlDocumentPage.java
License:Open Source License
/** * Edit the editor, enter new text line, count the lines and save it. * * @param txtLine String//from w w w . ja va 2s.c o m */ public void addTextToTinyMCE(String txtLine) { try { driver.switchTo().defaultContent(); TinyMceEditor tinyMceEditor = new TinyMceEditor(); tinyMceEditor.setTinyMce(); String oldText = tinyMceEditor.getContent(); tinyMceEditor.setText(oldText + txtLine); driver.switchTo().frame(IFRAME_ID); WebElement element = findAndWait(By.cssSelector("#tinymce")); element.sendKeys(Keys.chord(Keys.ENTER)); driver.switchTo().defaultContent(); } catch (TimeoutException toe) { logger.error("Tinymce Editor is not found", toe); } }
From source file:org.apache.falcon.regression.ui.search.SearchPage.java
License:Apache License
public List<SearchResult> appendAndSearch(String appendedPart) { for (String queryParam : appendedPart.split("\\s+")) { focusOnSearchBox();/* ww w.ja v a2s . c o m*/ getSearchBox().sendKeys(queryParam); getSearchBox().sendKeys(Keys.ENTER); } waitForAngularToFinish(); if (resultBlock.isDisplayed()) { return getSearchResults(); } else { return Collections.emptyList(); } }
From source file:org.apache.portals.pluto.demo.integration.test.PortletHubDemoIT.java
License:Apache License
@Test public void testPortletHubDemo() throws UnsupportedEncodingException { navigateToPage("V3.0 Portlet Hub Demo"); // Verify that all the different images appear when clicking each radio button. By imageByXpath = By.xpath(IMAGE_XPATH_TEMPLATE.replace(TOKEN, "FullMoon")); waitingAsserter.assertTrue(visibilityOfElementLocated(imageByXpath)); for (String imageName : IMAGE_OPTIONS) { clickElement(driver, waitingAsserter, getXpath("div", "hub_demo_portlet", "ImageSelPortlet") + "/input[@value='" + imageName + "']"); waitingAsserter.assertTrue(elementNotPresentOrNotVisible(imageByXpath)); imageByXpath = By.xpath(IMAGE_XPATH_TEMPLATE.replace(TOKEN, imageName + "-trans")); waitingAsserter.assertTrue(visibilityOfElementLocated(imageByXpath)); }//from w w w.j a va 2 s . c om // Verify that all the different images appear when clicking each dropdown option. clickElement(driver, waitingAsserter, "input", "hub_demo_portlet", "ImageSelPortlet", "dropdown"); By imageSelectByXpath = By .xpath(getXpath("select", "hub_demo_portlet", "ImageSelPortlet") + "[@name='imgName']"); waitingAsserter.waitFor(elementToBeClickable(imageSelectByXpath)); Select select = new Select(driver.findElement(imageSelectByXpath)); select.selectByValue("default"); imageByXpath = By.xpath(IMAGE_XPATH_TEMPLATE.replace(TOKEN, "FullMoon")); waitingAsserter.assertTrue(visibilityOfElementLocated(imageByXpath)); for (String imageName : IMAGE_OPTIONS) { select = new Select(driver.findElement(imageSelectByXpath)); select.selectByValue(imageName); waitingAsserter.assertTrue(elementNotPresentOrNotVisible(imageByXpath)); imageByXpath = By.xpath(IMAGE_XPATH_TEMPLATE.replace(TOKEN, imageName + "-trans")); waitingAsserter.assertTrue(visibilityOfElementLocated(imageByXpath)); } // Verify that the border checkbox shows and hides the border on the image. waitingAsserter .assertTrue(and(visibilityOfElementLocated(imageByXpath), attributeEmpty(imageByXpath, "style"))); clickElement(driver, waitingAsserter, "input", "hub_demo_portlet", "PH", "ResourcePortlet", "PRP", "border"); waitingAsserter.assertTrue( and(visibilityOfElementLocated(imageByXpath), attributeContains(imageByXpath, "style", "border:"))); // Verify that the different cacheability radion buttons change the visible cacheability text. String cacheabilityRadioButtonXpathTemplate = getXpath("input", "hub_demo_portlet", "PH", "ResourcePortlet", "PRP") + "[@value='" + TOKEN + "']"; String resourcePortletDivXpath = getXpath("div", "hub_demo_portlet", "PH", "ResourcePortlet", "PRP"); By actionButtonByXpath = By.xpath(resourcePortletDivXpath + "//input[@value='Action']"); for (String cacheability : Util.unmodifiableList("Portlet", "Full", "Page")) { String cacheabilityResultXpath = resourcePortletDivXpath + "//p[contains(text(),'Cacheability')]"; waitingAsserter.assertTrue(elementNotPresentOrNotVisible( By.xpath(cacheabilityResultXpath + "[contains(text(),'" + cacheability + "')]"))); String cacheabilityRadioButtonXpath = cacheabilityRadioButtonXpathTemplate.replace(TOKEN, cacheability.toUpperCase(Locale.ENGLISH)); clickElement(driver, waitingAsserter, cacheabilityRadioButtonXpath); By cacheabilityResultByXpath = By.xpath(cacheabilityResultXpath); waitingAsserter.assertTrue(and(visibilityOfElementLocated(cacheabilityResultByXpath), textToBePresentInElementLocated(cacheabilityResultByXpath, cacheability))); if ("Page".equalsIgnoreCase(cacheability)) { waitingAsserter.assertTrue(visibilityOfElementLocated(actionButtonByXpath)); } else { waitingAsserter.assertTrue(visibilityOfElementLocated( By.xpath(resourcePortletDivXpath + "[contains(.,'Action URL could not be created.')]"))); } } // Click the Action button. clickElement(driver, waitingAsserter, actionButtonByXpath); waitingAsserter.assertTrue(visibilityOfElementLocated(actionButtonByXpath)); // Verify the background color changes. navigateToPage("V3.0 Portlet Hub Demo"); ((JavascriptExecutor) driver).executeScript("window.scrollTo(0,document.body.scrollHeight);"); By coloredTableByXpath = By .xpath(getXpath("div", "hub_demo_portlet", "PH", "ResourcePortlet", "PRP", "putResourceHere") + "//table[@style]"); waitingAsserter.assertTrue(and(visibilityOfElementLocated(coloredTableByXpath), backgroundColor(coloredTableByXpath, 0xFF, 0xFF, 0xFF))); String colorInputXpath = getXpath("input", "hub_demo_portlet", "PH", "ColorSelPortlet", "color"); sendKeysToElement(driver, waitingAsserter, colorInputXpath, "#FF0000", Keys.ENTER); waitingAsserter.assertTrue(and(visibilityOfElementLocated(coloredTableByXpath), backgroundColor(coloredTableByXpath, 0xFF, 0, 0))); // Verify that messages can be sent in different colors by different methods. for (String formSubmissionMethod : Util.unmodifiableList("URL", "form")) { for (ColorCombo colorCombo : ColorCombo.getAllPossibleCombos()) { String lowerCaseFormSubmissionMethod = formSubmissionMethod.toLowerCase(Locale.ENGLISH); clickElement(driver, waitingAsserter, "input", "hub_demo_portlet", "PH", "ColorSelPortlet", lowerCaseFormSubmissionMethod); testMessageSent(colorCombo); } clickElement(driver, waitingAsserter, "input", "hub_demo_portlet", "MessageBoxPortlet", "clear"); } // Click the Do Partial Action button and check that the reponse text appears. By responseDivByXpath = By .xpath(getXpath("div", "hub_demo_portlet", "PartialActionPortlet", "responseDiv")); waitingAsserter.assertTrue(textEmpty(responseDivByXpath)); for (int i = 1; i <= 10; i++) { clickElement(driver, waitingAsserter, "input", "hub_demo_portlet", "PartialActionPortlet", "doPA"); waitingAsserter .assertTrue(and(visibilityOfElementLocated(responseDivByXpath), textToBePresentInElementLocated( responseDivByXpath, "Partial Action has been executed " + i + " times."))); } }
From source file:org.apache.zeppelin.AbstractZeppelinIT.java
License:Apache License
protected void deleteTestNotebook(final WebDriver driver) { WebDriverWait block = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC); driver.findElement(By.xpath(".//*[@id='main']//button[@ng-click='moveNoteToTrash(note.id)']")) .sendKeys(Keys.ENTER); block.until(ExpectedConditions.visibilityOfElementLocated( By.xpath(".//*[@id='main']//button[@ng-click='moveNoteToTrash(note.id)']"))); driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'This note will be moved to trash')]" + "//div[@class='modal-footer']//button[contains(.,'OK')]")).click(); ZeppelinITUtils.sleep(100, false);//from w ww . ja v a 2 s.co m }
From source file:org.apache.zeppelin.AbstractZeppelinIT.java
License:Apache License
protected void deleteTrashNotebook(final WebDriver driver) { WebDriverWait block = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC); driver.findElement(By.xpath(".//*[@id='main']//button[@ng-click='removeNote(note.id)']")) .sendKeys(Keys.ENTER); block.until(ExpectedConditions/* w w w . ja v a 2 s . co m*/ .visibilityOfElementLocated(By.xpath(".//*[@id='main']//button[@ng-click='removeNote(note.id)']"))); driver.findElement( By.xpath("//div[@class='modal-dialog'][contains(.,'This cannot be undone. Are you sure?')]" + "//div[@class='modal-footer']//button[contains(.,'OK')]")) .click(); ZeppelinITUtils.sleep(100, false); }
From source file:org.apache.zeppelin.integration.AuthenticationIT.java
License:Apache License
@Test public void testGroupPermission() throws Exception { try {//from w w w. j av a 2 s . c om AuthenticationIT authenticationIT = new AuthenticationIT(); authenticationIT.authenticationUser("finance1", "finance1"); createNewNote(); String noteId = driver.getCurrentUrl().substring(driver.getCurrentUrl().lastIndexOf("/") + 1); pollingWait(By.xpath("//span[@uib-tooltip='Note permissions']"), MAX_BROWSER_TIMEOUT_SEC).click(); pollingWait(By.xpath(".//*[@id='selectOwners']/following::span//input"), MAX_BROWSER_TIMEOUT_SEC) .sendKeys("finance "); pollingWait(By.xpath(".//*[@id='selectReaders']/following::span//input"), MAX_BROWSER_TIMEOUT_SEC) .sendKeys("finance "); pollingWait(By.xpath(".//*[@id='selectRunners']/following::span//input"), MAX_BROWSER_TIMEOUT_SEC) .sendKeys("finance "); pollingWait(By.xpath(".//*[@id='selectWriters']/following::span//input"), MAX_BROWSER_TIMEOUT_SEC) .sendKeys("finance "); pollingWait(By.xpath("//button[@ng-click='savePermissions()']"), MAX_BROWSER_TIMEOUT_SEC) .sendKeys(Keys.ENTER); pollingWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Permissions Saved ')]" + "//div[@class='modal-footer']//button[contains(.,'OK')]"), MAX_BROWSER_TIMEOUT_SEC).click(); authenticationIT.logoutUser("finance1"); authenticationIT.authenticationUser("hr1", "hr1"); try { WebElement element = pollingWait( By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC); collector.checkThat("Check is user has permission to view this note link", false, CoreMatchers.equalTo(element.isDisplayed())); } catch (Exception e) { //This should have failed, nothing to worry. } driver.get(new URI(driver.getCurrentUrl()).resolve("/#/notebook/" + noteId).toString()); List<WebElement> privilegesModal = driver .findElements(By.xpath("//div[@class='modal-content']//div[@class='bootstrap-dialog-header']" + "//div[contains(.,'Insufficient privileges')]")); collector.checkThat("Check is user has permission to view this note", 1, CoreMatchers.equalTo(privilegesModal.size())); driver.findElement(By.xpath("//div[@class='modal-content'][contains(.,'Insufficient privileges')]" + "//div[@class='modal-footer']//button[2]")).click(); authenticationIT.logoutUser("hr1"); authenticationIT.authenticationUser("finance2", "finance2"); try { WebElement element = pollingWait( By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + noteId + "')]"), MAX_BROWSER_TIMEOUT_SEC); collector.checkThat("Check is user has permission to view this note link", true, CoreMatchers.equalTo(element.isDisplayed())); } catch (Exception e) { //This should have failed, nothing to worry. } driver.get(new URI(driver.getCurrentUrl()).resolve("/#/notebook/" + noteId).toString()); privilegesModal = driver .findElements(By.xpath("//div[@class='modal-content']//div[@class='bootstrap-dialog-header']" + "//div[contains(.,'Insufficient privileges')]")); collector.checkThat("Check is user has permission to view this note", 0, CoreMatchers.equalTo(privilegesModal.size())); deleteTestNotebook(driver); authenticationIT.logoutUser("finance2"); } catch (Exception e) { handleException("Exception in AuthenticationIT while testGroupPermission ", e); } }
From source file:org.apache.zeppelin.integration.ParagraphActionsIT.java
License:Apache License
@Test public void testDisableParagraphRunButton() throws Exception { try {/* w ww. j a va 2s .co m*/ createNewNote(); waitForParagraph(1, "READY"); setTextOfParagraph(1, "println (\"abcd\")"); driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); clickAndWait(By.xpath(getParagraphXPath(1) + "//ul/li/a[@ng-click='toggleEnableDisable(paragraph)']")); collector.checkThat("The play button class was ", driver.findElement( By.xpath(getParagraphXPath(1) + "//span[@class='icon-control-play shortcut-icon']")) .isDisplayed(), CoreMatchers.equalTo(false)); driver.findElement(By.xpath(".//*[@id='main']//button[contains(@ng-click, 'runAllParagraphs')]")) .sendKeys(Keys.ENTER); ZeppelinITUtils.sleep(1000, false); driver.findElement(By.xpath("//div[@class='modal-dialog'][contains(.,'Run all paragraphs?')]" + "//div[@class='modal-footer']//button[contains(.,'OK')]")).click(); ZeppelinITUtils.sleep(2000, false); collector.checkThat("Paragraph status is ", getParagraphStatus(1), CoreMatchers.equalTo("READY")); driver.navigate().refresh(); ZeppelinITUtils.sleep(3000, false); deleteTestNotebook(driver); } catch (Exception e) { handleException("Exception in ParagraphActionsIT while testDisableParagraphRunButton ", e); } }
From source file:org.apache.zeppelin.integration.ParagraphActionsIT.java
License:Apache License
public void testRunOnSelectionChange() throws Exception { try {// w ww . j av a 2s . c om String xpathToRunOnSelectionChangeCheckbox = getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-checked, 'true')]"; String xpathToDropdownMenu = getParagraphXPath(1) + "//select"; String xpathToResultText = getParagraphXPath(1) + "//div[contains(@id,\"_html\")]"; createNewNote(); waitForParagraph(1, "READY"); setTextOfParagraph(1, "%md My selection is ${my selection=1,1|2|3}"); runParagraph(1); waitForParagraph(1, "FINISHED"); // 1. 'RunOnSelectionChange' is true by default driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); collector.checkThat("'Run on selection change' checkbox will be shown under dropdown menu ", driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/form/input[contains(@ng-click, 'turnOnAutoRun(paragraph)')]")).isDisplayed(), CoreMatchers.equalTo(true)); Select dropDownMenu = new Select(driver.findElement(By.xpath((xpathToDropdownMenu)))); dropDownMenu.selectByVisibleText("2"); waitForParagraph(1, "FINISHED"); collector.checkThat( "If 'RunOnSelectionChange' is true, the paragraph result will be updated right after click any options in the dropdown menu ", driver.findElement(By.xpath(xpathToResultText)).getText(), CoreMatchers.equalTo("My selection is 2")); // 2. set 'RunOnSelectionChange' to false driver.findElement(By.xpath(getParagraphXPath(1) + "//span[@class='icon-settings']")).click(); driver.findElement(By.xpath(xpathToRunOnSelectionChangeCheckbox)).click(); collector.checkThat( "If 'Run on selection change' checkbox is unchecked, 'paragraph.config.runOnSelectionChange' will be false ", driver.findElement(By.xpath(getParagraphXPath(1) + "//ul/li/span[contains(@ng-if, 'paragraph.config.runOnSelectionChange == false')]")) .isDisplayed(), CoreMatchers.equalTo(true)); Select sameDropDownMenu = new Select(driver.findElement(By.xpath((xpathToDropdownMenu)))); sameDropDownMenu.selectByVisibleText("1"); waitForParagraph(1, "FINISHED"); collector.checkThat( "If 'RunOnSelectionChange' is false, the paragraph result won't be updated even if we select any options in the dropdown menu ", driver.findElement(By.xpath(xpathToResultText)).getText(), CoreMatchers.equalTo("My selection is 2")); // run paragraph manually by pressing ENTER driver.findElement(By.xpath(xpathToDropdownMenu)).sendKeys(Keys.ENTER); waitForParagraph(1, "FINISHED"); collector.checkThat( "Even if 'RunOnSelectionChange' is set as false, still can run the paragraph by pressing ENTER ", driver.findElement(By.xpath(xpathToResultText)).getText(), CoreMatchers.equalTo("My selection is 1")); } catch (Exception e) { handleException("Exception in ParagraphActionsIT while testRunOnSelectionChange ", e); } }
From source file:org.apache.zeppelin.integration.ParagraphActionsIT.java
License:Apache License
@Test public void testTitleButton() throws Exception { try {//from ww w.j a va 2s . c om createNewNote(); waitForParagraph(1, "READY"); String xpathToTitle = getParagraphXPath(1) + "//div[contains(@class, 'title')]/div"; String xpathToSettingIcon = getParagraphXPath(1) + "//span[@class='icon-settings']"; String xpathToShowTitle = getParagraphXPath(1) + "//ul/li/a[@ng-show='!paragraph.config.title']"; String xpathToHideTitle = getParagraphXPath(1) + "//ul/li/a[@ng-show='paragraph.config.title']"; ZeppelinITUtils.turnOffImplicitWaits(driver); Integer titleElems = driver.findElements(By.xpath(xpathToTitle)).size(); collector.checkThat("Before Show Title : The title doesn't exist", titleElems, CoreMatchers.equalTo(0)); ZeppelinITUtils.turnOnImplicitWaits(driver); clickAndWait(By.xpath(xpathToSettingIcon)); collector.checkThat("Before Show Title : The title option in option panel of paragraph is labeled as", driver.findElement(By.xpath(xpathToShowTitle)).getText(), CoreMatchers .allOf(CoreMatchers.endsWith("Show title"), CoreMatchers.containsString("Ctrl+"), CoreMatchers.anyOf(CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), CoreMatchers.containsString("+T"))); clickAndWait(By.xpath(xpathToShowTitle)); collector.checkThat("After Show Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("Untitled")); clickAndWait(By.xpath(xpathToSettingIcon)); collector.checkThat("After Show Title : The title option in option panel of paragraph is labeled as", driver.findElement(By.xpath(xpathToHideTitle)).getText(), CoreMatchers .allOf(CoreMatchers.endsWith("Hide title"), CoreMatchers.containsString("Ctrl+"), CoreMatchers.anyOf(CoreMatchers.containsString("Option"), CoreMatchers.containsString("Alt")), CoreMatchers.containsString("+T"))); clickAndWait(By.xpath(xpathToHideTitle)); ZeppelinITUtils.turnOffImplicitWaits(driver); titleElems = driver.findElements(By.xpath(xpathToTitle)).size(); collector.checkThat("After Hide Title : The title field is hidden", titleElems, CoreMatchers.equalTo(0)); ZeppelinITUtils.turnOnImplicitWaits(driver); driver.findElement(By.xpath(xpathToSettingIcon)).click(); driver.findElement(By.xpath(xpathToShowTitle)).click(); driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'title')]")).click(); driver.findElement(By.xpath(getParagraphXPath(1) + "//input")).sendKeys("NEW TITLE" + Keys.ENTER); ZeppelinITUtils.sleep(500, false); collector.checkThat("After Editing the Title : The title field contains ", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("NEW TITLE")); driver.navigate().refresh(); ZeppelinITUtils.sleep(1000, false); collector.checkThat("After Page Refresh : The title field contains ", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("NEW TITLE")); deleteTestNotebook(driver); } catch (Exception e) { handleException("Exception in ParagraphActionsIT while testTitleButton ", e); } }