List of usage examples for org.openqa.selenium.interactions Actions build
public Action build()
From source file:org.openecomp.sdc.ci.tests.execute.resourceui.VFCanvasTest.java
License:Open Source License
@Test public void VFCanvasTest1() throws Exception { // GeneralUIUtils.waitForContainsdataTestIdVisibility("left-sectioin-element-QA"); GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); Thread.sleep(2000);/*from w w w. j a v a 2s .co m*/ List<Integer> position = null; WebElement canvas = GeneralUIUtils.getWebElementWaitForVisible("canvas"); int xPos = 0; int yPos = 0; position = getposition(canvas, xPos, yPos); WebElement otherElement = GeneralUIUtils .getWebElementWaitForVisible("left-sectioin-element-QA left-section-NeutronPort"); for (int i = 0; i < 8; i++) { Actions builder = new Actions(GeneralUIUtils.getDriver()); Action dragAndDrop = builder.clickAndHold(otherElement) .moveToElement(canvas, position.get(0), position.get(1)).release().build(); dragAndDrop.perform(); Thread.sleep(2000); } Thread.sleep(2000); Actions builder = new Actions(GeneralUIUtils.getDriver()); builder.moveToElement(canvas, position.get(0), position.get(1)); builder.clickAndHold(); position = getposition(canvas, xPos, yPos); builder.moveToElement(canvas, position.get(0), position.get(1)); builder.release(); builder.build(); builder.perform(); builder.moveToElement(canvas, 200, 300); builder.release(); builder.perform(); }
From source file:org.openfaces.component.datatable.DataTableTest.java
License:LGPL
@Ignore @Test// w ww. j a v a2 s. c om 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 w w w .ja va 2s. com*/ */ @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.qe4j.web.OpenWebDriver.java
License:Open Source License
/** * Uses Selenium Actions to move the mouse over the center of the element * specified.//from w ww . j a v a 2 s. c o m * * @param by */ public void mouseOver(By by) { Actions actions = new Actions(webDriver); WebElement element = findElement(by); log.info("mouse over " + OpenWebElement.extractElementInfo(element)); Dimension dimension = element.getSize(); actions.moveToElement(element, dimension.width / 2, dimension.height / 2); actions.build().perform(); }
From source file:org.qe4j.web.OpenWebElement.java
License:Open Source License
/** * Performs a mouseover action relative to this element. * * @param by/*from w ww . j av a 2s . co m*/ */ public void mouseOver(By by) { Actions actions = new Actions(webDriver); WebElement element = webElement.findElement(by); Dimension dimension = element.getSize(); actions.moveToElement(element, dimension.width / 2, dimension.height / 2); actions.build().perform(); }
From source file:org.richfaces.bootstrap.demo.ftest.webdriver.pickList.fragment.PickListSelectionImpl.java
License:Open Source License
private void select() { if (selection.size() > 1) { //multiple selection is not working Actions builder = new Actions(driver); boolean firstrun = true; for (WebElement keyElement : selection) { builder.click(keyElement);//also deselect previous selected elements if (firstrun) { firstrun = false;/*from www . jav a 2s . c o m*/ builder.keyDown(Keys.CONTROL); } } builder.keyUp(Keys.CONTROL); builder.build().perform(); } else { selection.get(0).click(); } }
From source file:org.richfaces.bootstrap.demo.ftest.webdriver.pickList.fragment.PickListSelectionImpl.java
License:Open Source License
@Override public void transferByOne(With with) { int sourceListSizeFinalSize, targetListFinalSize; WebElement button;//w w w . j av a2 s. c o m if (to.getRoot().getAttribute("id").contains("SourceList")) { sourceListSizeFinalSize = picklist.getSourceList().size() + selection.size(); targetListFinalSize = picklist.getTargetList().size() - selection.size(); button = picklist.removeButton; } else { sourceListSizeFinalSize = picklist.getSourceList().size() - selection.size(); targetListFinalSize = picklist.getTargetList().size() + selection.size(); button = picklist.addButton; } switch (with) { case button: for (WebElement keyElement : selection) { keyElement.click(); button.click(); } break; case dnd: Actions builder = new Actions(driver); for (WebElement keyElement : selection) { dragAndDropActionWithPositiveOffset(builder, keyElement, to.getRoot()); } builder.build().perform(); break; default: throw new UnsupportedOperationException("Unknown switch " + with); } picklist.waitForListSizesChange(sourceListSizeFinalSize, targetListFinalSize); }
From source file:org.richfaces.bootstrap.demo.ftest.webdriver.pickList.fragment.PickListSelectionImpl.java
License:Open Source License
@Override public void transferMultiple(With with) { int sourceListSizeFinalSize, targetListFinalSize; WebElement button;/*from w w w. j av a 2s . co m*/ if (to.getRoot().getAttribute("id").contains("SourceList")) { sourceListSizeFinalSize = picklist.getSourceList().size() + selection.size(); targetListFinalSize = picklist.getTargetList().size() - selection.size(); button = picklist.removeButton; } else { sourceListSizeFinalSize = picklist.getSourceList().size() - selection.size(); targetListFinalSize = picklist.getTargetList().size() + selection.size(); button = picklist.addButton; } select(); switch (with) { case button: button.click(); break; case dnd: Actions builder = new Actions(driver); dragAndDropActionWithPositiveOffset(builder, selection.get(0), to.getRoot()); builder.build().perform(); break; default: throw new UnsupportedOperationException("Unknown switch " + with); } picklist.waitForListSizesChange(sourceListSizeFinalSize, targetListFinalSize); }
From source file:org.richfaces.tests.metamer.ftest.richDropTarget.TestDropTarget.java
License:Open Source License
private void guardedDrop() { Actions release = new Actions(driver).release(); MetamerPage.waitRequest(release, WaitRequestType.XHR); release.build().perform(); }
From source file:org.richfaces.tests.metamer.ftest.richPanelMenuGroup.TestPanelMenuGroupDOMEventHandlers.java
License:Open Source License
@Test @CoversAttributes("onmouseover") @Templates(value = "plain") public void testOnmouseover() { //This test should be done first, because use static x and y variables panelMenuGroupAttributes.set(mode, client); Actions mouseover = new Actions(driver).moveToElement(getPage().getRequestTimeElement()); mouseover.moveToElement(getPage().getTopGroup().advanced().getHeaderElement(), 3, 3); testFireEvent(panelMenuGroupAttributes, onmouseover, mouseover.build()); }