List of usage examples for org.openqa.selenium Keys ARROW_DOWN
Keys ARROW_DOWN
To view the source code for org.openqa.selenium Keys ARROW_DOWN.
Click Source Link
From source file:org.kuali.rice.krad.demo.uif.library.controls.LibraryControlCheckboxDefaultAft.java
License:Educational Community License
protected void actionSendKeysArrowDown(String id) { Actions actions = new Actions(driver); actions.moveToElement(driver.findElement(By.id(id))); actions.click();/* w ww . j a v a2 s.co m*/ actions.sendKeys(Keys.ARROW_DOWN); actions.build().perform(); }
From source file:org.openfaces.component.datatable.DataTableTest.java
License:LGPL
@Ignore @Test/*ww w . j a va 2s. c o m*/ public void testSingleSelectionAndKeyboardNavigation() { testAppFunctionalPage("/components/datatable/datatableSingleSelection.jsf"); //check keyboard navigation for single selection DataTableInspector singleSelectionDataTable = dataTable("formID:singleSelectionDataTable"); Actions click = new Actions(getDriver()) .moveToElement(getDriver().findElement(By.xpath(singleSelectionDataTable.bodyRow(0).getXPath()))) .click(); click.build().perform(); for (int i = 0; i < 8; i++) { Actions keyDown = new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN); keyDown.build().perform(); singleSelectionDataTable.checkSelectedIndex(i + 1); } //check selection with the mouse help Random rand = new Random(); for (int i = 0; i < 10; i++) { singleSelectionDataTable.makeAndCheckSingleSelection(0, rand.nextInt(8)); } //check rowData and rowIndex attributes DataTableInspector withRowDataTable = dataTable("formID:withRowDataID"); withRowDataTable.checkSelectedIndex(0); DataTableInspector withRowIndexTable = dataTable("formID:withRowIndexID"); withRowIndexTable.checkSelectedIndex(3); element("formID:withRowDataID:2:withRowData_firstBody").click(); element("formID:withRowIndexID:0:withRowIndex_firstBody").click(); element("formID:submitID").clickAndWait(); withRowDataTable.checkSelectedIndex(2); withRowIndexTable.checkSelectedIndex(0); }
From source file:org.openfaces.component.treetable.TreeTableTest.java
License:LGPL
/** * Check TreeTable single selection//from www. ja va 2s . c o m */ @Test @Ignore public void testSingleSelectionAndKeyboardNavigation() { closeBrowser(); testAppFunctionalPage("/components/treetable/treeTableSingleSelection.jsf"); /*check selection and keyboard navigation on the simple TreeTable*/ Actions click = new Actions(getDriver()) .moveToElement(getDriver().findElement(By.id("formID:singleSelectionTreeTableID:0:categoryID"))) .click(); click.build().perform(); ElementInspector emptyElement = element("empty"); ElementInspector treeTable = element("formID:singleSelectionTreeTableID"); treeTable.focus(); for (int i = 1; i < 26; i++) { if (i == 1 || i == 4 || i == 16 || i == 19 || i == 21 || i == 24) { //click right arrow to expand first TreeTable node new Actions(getDriver()).sendKeys(Keys.ARROW_RIGHT).build().perform(); OpenFacesAjaxLoadingMode.getInstance().waitForLoad(); } //get selected index value emptyElement.assertText(String.valueOf(i - 1)); //click down arrow new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).build().perform(); } //check mouse selection for the same TreeTable element("formID:singleSelectionTreeTableID:1:categoryID").click(); emptyElement.assertText("3"); element("formID:singleSelectionTreeTableID:4_1:nameID").click(); emptyElement.assertText("22"); /*Check TreeTable with defined 'nodePath' and 'nodeData' attributes*/ element("formID:singleNodePathSelectionTreeTableID:3:categoryID").click(); ElementInspector selectionNodePath = element("selectionNodePathID"); String indexBeforeSubmitNodePathTreeTable = selectionNodePath.text(); element("formID:singleNodeDataSelectionTreeTableID:1:categoryID").keyPress(KeyEvent.VK_RIGHT); OpenFacesAjaxLoadingMode.getInstance().waitForLoad(); treeTable.keyPress(KeyEvent.VK_DOWN); ElementInspector selectionNodeData = element("selectionNodeDataID"); String indexBeforeSubmitNodeDataTreeTable = selectionNodeData.text(); element("formID:submitID").clickAndWait(); selectionNodePath.assertText(indexBeforeSubmitNodePathTreeTable); selectionNodeData.assertText(indexBeforeSubmitNodeDataTreeTable); }
From source file:org.openfaces.component.treetable.TreeTableTest.java
License:LGPL
/** * Check TreeTable multiple selection/* ww w.j a v a 2s . c o m*/ */ //todo: add checking multiple selection functionality with the 'Ctrl' key @Test @Ignore public void testMultipleSelectionAndKeyboardNavigation() { testAppFunctionalPage("/components/treetable/treeTableMultipleSelection.jsf"); ElementInspector categoryOutput = element("formID:multipleSelectionTreeTableID:0:categoryID"); new Actions(getDriver()) .moveToElement(getDriver().findElement(By.id("formID:multipleSelectionTreeTableID:0:categoryID"))) .click().build().perform(); TreeTableInspector multipleSelectionTreeTable = treeTable("formID:multipleSelectionTreeTableID"); multipleSelectionTreeTable.focus(); /*check keyboard navigation and selection*/ //select root nodes for (int i = 0; i < 5; i++) { createEvent(multipleSelectionTreeTable, null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, true); } ElementInspector emptyElement = element("empty"); emptyElement.assertText(" 0 1 2 3 4 5"); for (int i = 0; i < 6; i++) { multipleSelectionTreeTable.getElementsByTagName("img").get(i) .clickAndWait(OpenFacesAjaxLoadingMode.getInstance()); } categoryOutput.click(); for (int i = 0; i < 25; i++) { createEvent(multipleSelectionTreeTable, null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, true); } emptyElement.assertText(" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"); for (int i = 0; i < 6; i++) { multipleSelectionTreeTable.getElementsByTagName("img").get(i) .clickAndWait(OpenFacesAjaxLoadingMode.getInstance()); } categoryOutput.click(); for (int i = 0; i < 5; i++) { createEvent(element("formID:multipleSelectionTreeTableID"), null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, true); } emptyElement.assertText(" 0 3 15 18 20 23"); /*check 'nodePaths' and 'nodeDatas' attributes*/ //verify is attributes took right initial values ElementInspector nodePathsOutput = element("formID:nodePathsID"); nodePathsOutput.assertText("Document BrowsingNetwork Access"); ElementInspector nodeDataOutput = element("formID:nodeDatasID"); nodeDataOutput.assertText("Document BrowsingDocument Deletion"); ElementInspector selectionNodePathsDiv = element("selectionNodePathsID"); selectionNodePathsDiv.assertText(" 1 5"); ElementInspector selectionNodeDataDiv = element("selectionNodeDatasID"); selectionNodeDataDiv.assertText(" 1 4"); //check root nodes element("formID:multipleNodePathsSelectionTreeTableID:0:categoryID").click(); TreeTableInspector multipleNodePathsTreeTable = treeTable("formID:multipleNodePathsSelectionTreeTableID"); new Actions(getDriver()) .moveToElement(getDriver().findElement(By.xpath(multipleNodePathsTreeTable.getXPath()))) .sendKeys(Keys.ARROW_DOWN).build().perform(); element("formID:multipleNodeDatasSelectionTreeTableID:0:categoryID").click(); TreeTableInspector multipleNodeDataTreeTable = treeTable("formID:multipleNodeDatasSelectionTreeTableID"); new Actions(getDriver()) .moveToElement(getDriver().findElement(By.xpath(multipleNodeDataTreeTable.getXPath()))) .sendKeys(Keys.ARROW_DOWN).build().perform(); //check root + expanded child nodes element("formID:multipleNodePathsSelectionTreeTableID:4:categoryID").click(); //click right arrow new Actions(getDriver()) .moveToElement(getDriver().findElement(By.xpath(multipleNodeDataTreeTable.getXPath()))) .sendKeys(Keys.ARROW_RIGHT).build().perform(); OpenFacesAjaxLoadingMode.getInstance().waitForLoad(); for (int i = 0; i < 3; i++) { createEvent(multipleNodePathsTreeTable, null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, true); } new Actions(getDriver()) .moveToElement( getDriver().findElement(By.id("formID:multipleNodeDatasSelectionTreeTableID:2:categoryID"))) .click().build().perform(); multipleNodeDataTreeTable.keyPress(Keys.ARROW_RIGHT); OpenFacesAjaxLoadingMode.getInstance().waitForLoad(); for (int i = 0; i < 3; i++) { createEvent(multipleNodeDataTreeTable, null, EventType.KEY, "keypress", KeyEvent.VK_DOWN, true); } element("formID:submitID").clickAndWait(); nodePathsOutput.assertText("Document DeletionSemen SemenychIvan IvanychNetwork Access"); nodeDataOutput.assertText("Document CreationAdministratorIvan IvanychDocument Modification"); selectionNodePathsDiv.assertText(" 4 5 6 7"); selectionNodeDataDiv.assertText(" 2 3 4 5"); //todo: checking with collapsed child node should be added after fix of 'JSFC-2603' }
From source file:org.richfaces.tests.metamer.ftest.richAutocomplete.TestAutocompleteJSApi.java
License:Open Source License
@Test public void testFocus() { focus.click();//from www . jav a 2 s. co m Graphene.guardAjax(keyboard).sendKeys("ala"); autocomplete.advanced().waitForSuggestionsToBeVisible().perform(); keyboard.sendKeys(Keys.ARROW_DOWN); Graphene.guardAjax(keyboard).sendKeys(Keys.ENTER); checkOutput("Alabama"); blur(WaitRequestType.XHR);// prevent ViewExpiredException }
From source file:org.richfaces.tests.metamer.ftest.richInplaceSelect.TestInplaceSelectJSApi.java
License:Open Source License
@Test public void open() { openButton.click();//from w w w . j a va 2s . co 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.richPickList.TestPickListJSApi.java
License:Open Source License
@Test public void testFocus() { assertEquals(pickList.advanced().getSelectedSourceListItemsElements().size(), 0); focus.click();/*from w w w .ja v a 2 s . c o m*/ keyboard.sendKeys(Keys.ARROW_DOWN); List<WebElement> selectedSourceListItemsElements = pickList.advanced().getSelectedSourceListItemsElements(); assertEquals(selectedSourceListItemsElements.size(), 1); assertEquals(selectedSourceListItemsElements.get(0).getText(), "Alabama"); }
From source file:org.richfaces.tests.metamer.ftest.richSelect.TestSelectJSApi.java
License:Open Source License
@Test public void testFocus() { focusButton.click();/*from w ww.ja v a2 s. c o m*/ 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.select.ITSelectKeyboardSelection.java
License:Open Source License
@Test public void test_selection_by_keyboard() { browser.get(contextPath.toExternalForm()); selectInput.sendKeys("t"); waitAjax().until().element(tampaBayOption).is().visible(); keyboard.pressKey(Keys.ARROW_DOWN); waitAjax().until().element(tampaBayOption).attribute("class").contains("rf-sel-sel"); if (FIREFOX.is(browser)) { keyboard.pressKey(Keys.RETURN);/*w w w .j av a2 s. c om*/ } else { keyboard.pressKey(Keys.ENTER); } waitGui().until().element(selectInput).attribute("value").equalTo("Tampa Bay"); }
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//w ww . ja v a 2 s .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; }