List of usage examples for org.openqa.selenium Keys TAB
Keys TAB
To view the source code for org.openqa.selenium Keys TAB.
Click Source Link
From source file:org.richfaces.tests.metamer.ftest.richInplaceSelect.TestInplaceSelectJSApi.java
License:Open Source License
@Test public void open() { openButton.click();//from www .j av a 2 s . c o m inplaceSelect.advanced().waitForPopupToShow().perform(); assertTrue(inplaceSelect.advanced().isInState(InplaceComponentState.ACTIVE)); keyboard.sendKeys(Keys.ARROW_DOWN); keyboard.sendKeys(Keys.ENTER); Graphene.guardAjax(keyboard).sendKeys(Keys.TAB); assertEquals(outputTextElement.getText(), "Alabama"); assertTrue(inplaceSelect.advanced().isInState(InplaceComponentState.CHANGED)); }
From source file:org.richfaces.tests.metamer.ftest.richSelect.TestSelectJSApi.java
License:Open Source License
@Test public void testFocus() { focusButton.click();/*from w w w . j a va 2 s. com*/ keyboard.sendKeys("ala"); select.advanced().waitUntilSuggestionsAreVisible().perform(); keyboard.sendKeys(Keys.ARROW_DOWN); keyboard.sendKeys(Keys.ENTER); Graphene.guardAjax(keyboard).sendKeys(Keys.TAB); assertEquals(output.getText(), "Alabama"); }
From source file:org.richfaces.ui.ajax.ITTestAjax.java
License:Open Source License
@Test public void listener_with_parameter() throws InterruptedException { // given//from w w w . ja v a2s .com browser.get(contextPath.toExternalForm()); WebElement cell = browser.findElement(By.id("myForm:input")); cell.sendKeys("123"); Graphene.guardAjax(cell).sendKeys(Keys.TAB); cell = browser.findElement(By.id("myForm:input")); Assert.assertEquals("4", cell.getAttribute("value")); }
From source file:org.richfaces.ui.extendedDataTable.ITTableState.java
License:Open Source License
@Test public void table_observe() throws InterruptedException { // given/*ww w. j a va 2 s. c o m*/ browser.get(contextPath.toExternalForm() + "filter.jsf"); List<WebElement> cells = browser.findElements(By.cssSelector(".rf-edt-c-column2 .rf-edt-c-cnt")); WebElement cell = cells.get(cells.size() - 1); Assert.assertEquals("6", cell.getText()); WebElement filterInput = browser.findElement(By.id("myForm:edt:filterInput")); filterInput.clear(); filterInput.sendKeys("3"); filterInput.sendKeys(Keys.TAB); Thread.sleep(500); cells = browser.findElements(By.cssSelector(".rf-edt-c-column2 .rf-edt-c-cnt")); cell = cells.get(cells.size() - 1); Assert.assertEquals("3", cell.getText()); // when / then Warp.initiate(new Activity() { @Override public void perform() { guardAjax(button).click(); } }).inspect(new Inspection() { private static final long serialVersionUID = 1L; @Inject IterationTableStateBean bean; @AfterPhase(Phase.INVOKE_APPLICATION) public void verify_bean_executed() { FacesContext facesContext = FacesContext.getCurrentInstance(); AbstractExtendedDataTable edtComponent = (AbstractExtendedDataTable) facesContext.getViewRoot() .findComponent("myForm").findComponent("edt"); ExtendedDataTableState tableState = new ExtendedDataTableState(edtComponent.getTableState()); UIColumn column = new UIColumn(); column.setId("column2"); Assert.assertEquals("3", tableState.getColumnFilter(column)); } }); }
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);/*from w w w . j av a 2s . 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.SourceInteraction.java
License:Open Source License
@Test public void createAndSourceRFile() { createRFile();//from ww w . j a v a2 s . c o m // Type some code into the file. Note that the matching brace is auto // completed. Actions a = new Actions(driver_); a.sendKeys("f <- function() {" + Keys.ENTER); a.sendKeys(Keys.TAB + "42"); a.perform(); // Source the entire file WebElement sourceMenuEntry = MenuNavigator.getMenuItem(driver_, "Code", "Source"); sourceMenuEntry.click(); // Wait for the console to contain the string "source" ConsoleTestUtils.waitForConsoleContainsText(driver_, "source("); closeUnsavedRFile(); }
From source file:org.rstudio.studio.selenium.SourceInteraction.java
License:Open Source License
@Test public void findAndReplace() { createRFile();//from w ww . j a va 2 s . c om // 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.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 w ww.ja v a 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; }
From source file:org.specrunner.webdriver.actions.input.keyboard.PluginTab.java
License:Open Source License
@Override protected Keys obtainKey() throws PluginException { return Keys.TAB; }
From source file:org.tanaguru.rules.generator.json.TanaguruJsTestCaseExtractor.java
License:Open Source License
/** * @param args the command line arguments * @throws java.net.MalformedURLException *//* ww w . j ava 2 s . c o m*/ public static void main(String[] args) throws MalformedURLException, IOException, InterruptedException { // DesiredCapabilities caps = new DesiredCapabilities(); // caps.setJavascriptEnabled(true); // WebDriver driver = new PhantomJSDriver(caps); // FirefoxDriver driver = // new FirefoxDriver( // new FirefoxBinary(new File(PATH_TO_FF)), // new FirefoxProfile()); DesiredCapabilities ff = DesiredCapabilities.firefox(); // DesiredCapabilities chrome = DesiredCapabilities.chrome(); RemoteWebDriver driver = null; try { driver = new RemoteWebDriver(new URL(HUB_URL), ff); // driver = new RemoteWebDriver(new URL("http://172.17.0.23:4444/wd/hub"), chrome); String script = IOUtils.toString( TanaguruJsTestCaseExtractor.class.getClassLoader().getResourceAsStream(JS_SCRIPT_NAME)); for (Element el : Jsoup.parse(new URL(URL_LIST), 5000).select("a")) { String url = el.attr("abs:href"); String resourceName = StringUtils.remove(el.attr("href"), ".html"); if (StringUtils.contains(url, "html")) { driver.get(url); driver.findElementByTagName("body").sendKeys(Keys.TAB); try { FileUtils.write(new File(PATH_TO_WRITE + resourceName + ".json"), new JSONArray(driver.executeScript(script).toString()).toString(4)); } catch (JSONException ex) { } } } } finally { if (driver != null) { driver.quit(); } } }