List of usage examples for org.openqa.selenium Keys ESCAPE
Keys ESCAPE
To view the source code for org.openqa.selenium Keys ESCAPE.
Click Source Link
From source file:org.richfaces.tests.page.fragments.impl.input.inplaceInput.EditingStateImpl.java
License:Open Source License
private void cancelByKeys() { input.sendKeys(Keys.chord(Keys.CONTROL, Keys.ESCAPE)); }
From source file:org.rstudio.studio.selenium.DataImportTests.java
License:Open Source License
@Test public void testImportCSVFile() throws Exception { WebElement menuEntry = MenuNavigator.getMenuItem(driver_, "Tools", "Import Dataset", "From Text File..."); menuEntry.click();/*from w w w . j av a 2s . co m*/ final WebElement importFileDialog = DialogTestUtils.waitForModalToAppear(driver_); DialogTestUtils.waitForFocusedInput(driver_, importFileDialog); Actions typeName = new Actions(driver_); File csvFile = new File("test/org/rstudio/studio/selenium/resources/banklist.csv"); typeName.sendKeys(csvFile.getAbsolutePath()); typeName.perform(); DialogTestUtils.respondToModalDialog(driver_, "Open"); // After a moment the modal prompting for the path will disappear, and // the modal prompting for input will appear. (new WebDriverWait(driver_, 5)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { List<WebElement> elements = driver_.findElements(By.className("gwt-DialogBox-ModalDialog")); if (elements.size() > 0) { if (elements.get(0).getText().contains("Import Dataset")) { return true; } } return false; } }); DialogTestUtils.respondToModalDialog(driver_, "Import"); ConsoleTestUtils.waitForConsoleContainsText(driver_, "read.csv"); // Once the CSV has been read, make sure all the rows made it to the // generated object ConsoleTestUtils.beginConsoleInteraction(driver_); (new Actions(driver_)).sendKeys(Keys.ESCAPE + "nrow(banklist)" + Keys.ENTER).perform(); ConsoleTestUtils.waitForConsoleContainsText(driver_, "515"); }
From source file:org.rstudio.studio.selenium.RConsoleInteraction.java
License:Open Source License
@Test public void testBasicRInteraction() { Actions do42 = new Actions(driver_); do42.sendKeys(Keys.chord(Keys.CONTROL, "l")); do42.sendKeys(Keys.ESCAPE); do42.sendKeys("41 + 1"); do42.sendKeys(Keys.ENTER); do42.perform(); ConsoleTestUtils.waitForConsoleContainsText(driver_, "42"); }
From source file:org.rstudio.studio.selenium.RConsoleInteraction.java
License:Open Source License
@Test public void testPopupCompletion() { // Test invoking autocomplete List<WebElement> elements = driver_ .findElements(By.id(ElementIds.getElementId(ElementIds.POPUP_COMPLETIONS))); assertEquals(elements.size(), 0);// w w w.j a v a 2 s . c o m Actions popup = new Actions(driver_); popup.sendKeys(Keys.ESCAPE); popup.sendKeys("print"); popup.sendKeys(Keys.TAB); popup.perform(); (new WebDriverWait(driver_, 5)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { List<WebElement> elements = driver_ .findElements(By.id(ElementIds.getElementId(ElementIds.POPUP_COMPLETIONS))); return elements.size() > 0; } }); // Test cancelling autocomplete once invoked Actions close = new Actions(driver_); close.sendKeys(Keys.ESCAPE).perform(); (new WebDriverWait(driver_, 5)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { List<WebElement> elements = driver_ .findElements(By.id(ElementIds.getElementId(ElementIds.POPUP_COMPLETIONS))); return elements.size() == 0; } }); }
From source file:org.rstudio.studio.selenium.RConsoleInteraction.java
License:Open Source License
@Test public void testPlotGeneration() { ConsoleTestUtils.resumeConsoleInteraction(driver_); Actions plotCars = new Actions(driver_); plotCars.sendKeys(Keys.ESCAPE + "plot(cars)" + Keys.ENTER); plotCars.perform();/*ww w. j av a 2 s . co m*/ // Wait for the Plot window to activate final WebElement plotWindow = (new WebDriverWait(driver_, 5)).until(ExpectedConditions .presenceOfElementLocated(By.id(ElementIds.getElementId(ElementIds.PLOT_IMAGE_FRAME)))); // Wait for a plot to appear in the window Assert.assertEquals(plotWindow.getTagName(), "iframe"); driver_.switchTo().frame(plotWindow); (new WebDriverWait(driver_, 5)).until(ExpectedConditions.presenceOfElementLocated(By.tagName("img"))); // Switch back to document context driver_.switchTo().defaultContent(); }
From source file:org.rstudio.studio.selenium.RConsoleInteraction.java
License:Open Source License
@Test public void testInvokeHelp() { ConsoleTestUtils.resumeConsoleInteraction(driver_); Actions help = new Actions(driver_); help.sendKeys(Keys.ESCAPE + "?lapply" + Keys.ENTER); help.perform();//from w w w . j a va 2s . com // Wait for the Help window to activate final WebElement helpWindow = (new WebDriverWait(driver_, 5)).until( ExpectedConditions.presenceOfElementLocated(By.id(ElementIds.getElementId(ElementIds.HELP_FRAME)))); // Wait for help to appear in the window Assert.assertEquals(helpWindow.getTagName(), "iframe"); driver_.switchTo().frame(helpWindow); (new WebDriverWait(driver_, 5)) .until(ExpectedConditions.textToBePresentInElement(By.tagName("body"), "lapply")); // Switch back to document context driver_.switchTo().defaultContent(); }
From source file:org.rstudio.studio.selenium.SourceInteraction.java
License:Open Source License
@Test public void findAndReplace() { createRFile();/*www . j a v a2s. c o m*/ // Type some code into the file String preReplaceCode = "foo <- 'bar'"; Actions a = new Actions(driver_); a.sendKeys(preReplaceCode + Keys.ENTER); a.perform(); // Find the ACE editor instance that the code appears in. (CONSIDER: // This is not the best way to find the code editor instance.) WebElement editor = null; List<WebElement> editors = driver_.findElements(By.className("ace_content")); for (WebElement e : editors) { if (e.getText().contains(preReplaceCode)) { editor = e; break; } } Assert.assertNotNull(editor); // Invoke find and replace WebElement findMenuEntry = MenuNavigator.getMenuItem(driver_, "Edit", "Find..."); findMenuEntry.click(); // Wait for the find and replace panel to come up (new WebDriverWait(driver_, 2)).until(ExpectedConditions .presenceOfElementLocated(By.id(ElementIds.getElementId(ElementIds.FIND_REPLACE_BAR)))); // Type the text and the text to be replaced (replace 'bar' with 'foo') Actions rep = new Actions(driver_); rep.sendKeys("bar" + Keys.TAB + "foo" + Keys.ENTER); rep.perform(); DialogTestUtils.respondToModalDialog(driver_, "OK"); Actions dismiss = new Actions(driver_); dismiss.sendKeys(Keys.ESCAPE); dismiss.perform(); // Ensure that the source has been updated Assert.assertTrue(editor.getText().contains("foo <- 'foo'")); closeUnsavedRFile(); }
From source file:org.rstudio.studio.selenium.WorkbenchTests.java
License:Open Source License
@Test public void testWorkbenchPersistance() throws Exception { clearWorkspace();//from ww w.j a va2s. co m // Add a variable to the workspace (new Actions(driver_)).sendKeys(Keys.ESCAPE + "selenium <- function() { 42 }" + Keys.ENTER).perform(); // Save the workspace WebElement saveItem = MenuNavigator.getMenuItem(driver_, "Session", "Save Workspace As..."); saveItem.click(); WebElement saveDialog = DialogTestUtils.waitForModalToAppear(driver_); DialogTestUtils.waitForFocusedInput(driver_, saveDialog); File tempFile = File.createTempFile("rstudio-selenium-workspace-", ".RData"); String workspaceFilePath = tempFile.getAbsolutePath(); tempFile.delete(); (new Actions(driver_)).sendKeys(workspaceFilePath + Keys.ENTER).perform(); DialogTestUtils.waitForModalToDisappear(driver_); // Clear the workspace and load it again clearWorkspace(); WebElement loadItem = MenuNavigator.getMenuItem(driver_, "Session", "Load Workspace..."); loadItem.click(); WebElement loadDialog = DialogTestUtils.waitForModalToAppear(driver_); DialogTestUtils.waitForFocusedInput(driver_, loadDialog); (new Actions(driver_)).sendKeys(workspaceFilePath + Keys.ENTER).perform(); DialogTestUtils.waitForModalToDisappear(driver_); // List the workspace and see if the variable is present ConsoleTestUtils.beginConsoleInteraction(driver_); (new Actions(driver_)).sendKeys(Keys.chord(Keys.CONTROL + "l")).sendKeys(Keys.ESCAPE + "ls()" + Keys.ENTER) .perform(); ConsoleTestUtils.waitForConsoleContainsText(driver_, "selenium"); }
From source file:org.rstudio.studio.selenium.WorkbenchTests.java
License:Open Source License
private void clearWorkspace() { // Clear out the workspace and make sure it's clear WebElement menuItem = MenuNavigator.getMenuItem(driver_, "Session", "Clear Workspace..."); menuItem.click();/*w w w. ja v a2 s .c om*/ DialogTestUtils.respondToModalDialog(driver_, "Yes"); ConsoleTestUtils.beginConsoleInteraction(driver_); (new Actions(driver_)).sendKeys(Keys.ESCAPE + "ls()" + Keys.ENTER).perform(); ConsoleTestUtils.waitForConsoleContainsText(driver_, "character(0)"); }
From source file:org.safs.selenium.webdriver.lib.WDLibrary.java
License:Open Source License
/** * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum * @param keycode int, a java keycode//from www.j a va 2s. c om * @return Keys enum for (primarily) non-printable (control) characters, or null. */ public static Keys convertToKeys(int keycode) { Keys key = null; switch (keycode) { case java.awt.event.KeyEvent.VK_ADD: key = Keys.ADD; break; case java.awt.event.KeyEvent.VK_ALT: key = Keys.ALT; break; case java.awt.event.KeyEvent.VK_KP_DOWN: key = Keys.ARROW_DOWN; break; case java.awt.event.KeyEvent.VK_KP_LEFT: key = Keys.ARROW_LEFT; break; case java.awt.event.KeyEvent.VK_KP_RIGHT: key = Keys.ARROW_RIGHT; break; case java.awt.event.KeyEvent.VK_KP_UP: key = Keys.ARROW_UP; break; case java.awt.event.KeyEvent.VK_BACK_SPACE: key = Keys.BACK_SPACE; break; case java.awt.event.KeyEvent.VK_CANCEL: key = Keys.CANCEL; break; case java.awt.event.KeyEvent.VK_CLEAR: key = Keys.CLEAR; break; case java.awt.event.KeyEvent.VK_WINDOWS: key = Keys.COMMAND; break; case java.awt.event.KeyEvent.VK_CONTROL: key = Keys.CONTROL; break; case java.awt.event.KeyEvent.VK_DECIMAL: key = Keys.DECIMAL; break; case java.awt.event.KeyEvent.VK_DELETE: key = Keys.DELETE; break; case java.awt.event.KeyEvent.VK_DIVIDE: key = Keys.DIVIDE; break; case java.awt.event.KeyEvent.VK_DOWN: key = Keys.DOWN; break; case java.awt.event.KeyEvent.VK_END: key = Keys.END; break; case java.awt.event.KeyEvent.VK_ENTER: key = Keys.ENTER; break; case java.awt.event.KeyEvent.VK_EQUALS: key = Keys.EQUALS; break; case java.awt.event.KeyEvent.VK_ESCAPE: key = Keys.ESCAPE; break; case java.awt.event.KeyEvent.VK_F1: key = Keys.F1; break; case java.awt.event.KeyEvent.VK_F2: key = Keys.F2; break; case java.awt.event.KeyEvent.VK_F3: key = Keys.F3; break; case java.awt.event.KeyEvent.VK_F4: key = Keys.F4; break; case java.awt.event.KeyEvent.VK_F5: key = Keys.F5; break; case java.awt.event.KeyEvent.VK_F6: key = Keys.F6; break; case java.awt.event.KeyEvent.VK_F7: key = Keys.F7; break; case java.awt.event.KeyEvent.VK_F8: key = Keys.F8; break; case java.awt.event.KeyEvent.VK_F9: key = Keys.F9; break; case java.awt.event.KeyEvent.VK_F10: key = Keys.F10; break; case java.awt.event.KeyEvent.VK_F11: key = Keys.F11; break; case java.awt.event.KeyEvent.VK_F12: key = Keys.F12; break; case java.awt.event.KeyEvent.VK_HELP: key = Keys.HELP; break; case java.awt.event.KeyEvent.VK_HOME: key = Keys.HOME; break; case java.awt.event.KeyEvent.VK_INSERT: key = Keys.INSERT; break; case java.awt.event.KeyEvent.VK_LEFT: key = Keys.LEFT; break; case java.awt.event.KeyEvent.VK_META: key = Keys.META; break; case java.awt.event.KeyEvent.VK_MULTIPLY: key = Keys.MULTIPLY; break; case java.awt.event.KeyEvent.VK_NUMPAD0: key = Keys.NUMPAD0; break; case java.awt.event.KeyEvent.VK_NUMPAD1: key = Keys.NUMPAD1; break; case java.awt.event.KeyEvent.VK_NUMPAD2: key = Keys.NUMPAD2; break; case java.awt.event.KeyEvent.VK_NUMPAD3: key = Keys.NUMPAD3; break; case java.awt.event.KeyEvent.VK_NUMPAD4: key = Keys.NUMPAD4; break; case java.awt.event.KeyEvent.VK_NUMPAD5: key = Keys.NUMPAD5; break; case java.awt.event.KeyEvent.VK_NUMPAD6: key = Keys.NUMPAD6; break; case java.awt.event.KeyEvent.VK_NUMPAD7: key = Keys.NUMPAD7; break; case java.awt.event.KeyEvent.VK_NUMPAD8: key = Keys.NUMPAD8; break; case java.awt.event.KeyEvent.VK_NUMPAD9: key = Keys.NUMPAD9; break; case java.awt.event.KeyEvent.VK_PAGE_DOWN: key = Keys.PAGE_DOWN; break; case java.awt.event.KeyEvent.VK_PAGE_UP: key = Keys.PAGE_UP; break; case java.awt.event.KeyEvent.VK_PAUSE: key = Keys.PAUSE; break; case java.awt.event.KeyEvent.VK_RIGHT: key = Keys.RIGHT; break; case java.awt.event.KeyEvent.VK_SEMICOLON: key = Keys.SEMICOLON; break; case java.awt.event.KeyEvent.VK_SEPARATOR: key = Keys.SEPARATOR; break; case java.awt.event.KeyEvent.VK_SHIFT: key = Keys.SHIFT; break; case java.awt.event.KeyEvent.VK_SPACE: key = Keys.SPACE; break; case java.awt.event.KeyEvent.VK_SUBTRACT: key = Keys.SUBTRACT; break; case java.awt.event.KeyEvent.VK_TAB: key = Keys.TAB; break; case java.awt.event.KeyEvent.VK_UP: key = Keys.UP; break; } return key; }