List of usage examples for org.openqa.selenium.interactions Actions dragAndDropBy
public Actions dragAndDropBy(WebElement source, int xOffset, int yOffset)
From source file:com.ggasoftware.uitest.control.Element.java
License:Open Source License
/** * A convenience method that performs click-and-hold at the location of the source element, moves by a given offset, then releases the mouse. * * @param xOffset - horizontal move offset. * @param yOffset - vertical move offset. * @return Parent instance/*from w w w. j av a 2 s .c om*/ */ public ParentPanel dragAndDropBy(int xOffset, int yOffset) { logAction(this, getParentClassName(), format("Drag and drop element: horizontal move offset - %dpx; vertical move offset - %dpx", xOffset, yOffset)); Actions builder = new Actions(getDriver()); Action dragAndDropBy = builder.dragAndDropBy(getWebElement(), xOffset, yOffset).build(); dragAndDropBy.perform(); return parent; }
From source file:com.vaadin.tests.components.calendar.CalendarResizeOverlappingEventsTest.java
License:Apache License
private void dragAndDrop(WebElement element, int yOffset) { /*//from w w w . j av a2s . com * Selenium doesn't properly drag and drop items in IE8. It tries to * start dragging an element from a position above the element itself. */ if (BrowserUtil.isIE8(getDesiredCapabilities())) { Actions action = new Actions(getDriver()); action.moveToElement(element); action.moveByOffset(0, 1); action.clickAndHold(); action.moveByOffset(0, yOffset); action.release(); action.build().perform(); } else { Actions action = new Actions(getDriver()); action.dragAndDropBy(element, 0, yOffset); action.build().perform(); } }
From source file:org.alfresco.po.PageElement.java
License:Open Source License
/** * Drag and drop element by x,y// ww w . j a va 2 s .c o m * @param source html element * @param x coordinate * @param y coordinate */ public void dragAndDrop(WebElement source, int x, int y) { PageUtils.checkMandatoryParam("source element", source); Actions builder = new Actions(driver); Action dragAndDrop = builder.dragAndDropBy(source, x, y).build(); dragAndDrop.perform(); }
From source file:org.finra.jtaf.ewd.widget.element.InteractiveElement.java
License:Apache License
public void dragAndDropByOffset(int xOffset, int yOffset) throws WidgetException { try {/*from w w w . j av a 2s. com*/ Actions builder = new Actions(getGUIDriver().getWrappedDriver()); synchronized (InteractiveElement.class) { getGUIDriver().focus(); builder.dragAndDropBy(getWebElement(), xOffset, yOffset).build().perform(); } } catch (Exception e) { throw new WidgetException("Error while performing drag and drop from " + getLocator() + " offset by X: " + xOffset + " Y: " + yOffset, getLocator(), e); } }
From source file:org.oneandone.qxwebdriver.ui.mobile.core.WidgetImpl.java
License:LGPL
public static void track(WebDriver driver, WebElement element, int x, int y, int step) { if (driver instanceof HasTouchScreen) { if (step == 0) { step = 1;// ww w. java 2s .c o m // TODO: no move if step == 0 } Point center = getCenter(element); int posX = center.getX(); int posY = center.getY(); int endX = posX + x; int endY = posY + y; TouchActions touchAction = new TouchActions(driver); touchAction.down(posX, posY); while ((x < 0 && posX > endX || x > 0 && posX < endX) || (y < 0 && posY > endY || y > 0 && posY < endY)) { if (x > 0 && posX < endX) { if (posX + step > endX) { posX += endX - (posX + step); } else { posX += step; } } else if (x < 0 && posX > endX) { if (posX - step < endX) { posX -= endX + (posX - step); } else { posX -= step; } } if (y > 0 && posY < endY) { if (posY + step > endY) { posY += endY - (posY + step); } else { posY += step; } } else if (y < 0 && posY > endY) { if (posY - step < endY) { posY -= endY + (posY - step); } else { posY -= step; } } touchAction.move(posX, posY); } touchAction.up(posX, posY).perform(); } else { Actions mouseAction = new Actions(driver); mouseAction.dragAndDropBy(element, x, y); } }
From source file:org.richfaces.bootstrap.demo.ftest.webdriver.pickList.fragment.PickListSelectionImpl.java
License:Open Source License
/** * Workaround for Drag and Drop//from www. ja v a 2s . c o m */ private void dragAndDropAction(WithOffset offset, Actions builder, WebElement source, WebElement target) { Point sourceLocation = source.getLocation(); Point targetLocation = target.getLocation(); int x = targetLocation.getX() - sourceLocation.getX() + offset.getOffset(); int y = targetLocation.getY() - sourceLocation.getY() + offset.getOffset(); builder.dragAndDropBy(source, x, y); // builder.clickAndHold(source); // builder.moveToElement(target); // builder.moveByOffset(offset.getOffset(),offset.getOffset());//second move will throw exception // builder.release(); }
From source file:org.richfaces.ui.extendedDataTable.ITColumnWidth.java
License:Open Source License
@Test public void column_resize_smaller() { browser.get(contextPath.toExternalForm()); WebElement column1ResizeHandle = header .findElement(By.cssSelector(".rf-edt-hdr .rf-edt-td-column1 .rf-edt-rsz")); Actions builder = new Actions(browser); final Action dragAndDrop = builder.dragAndDropBy(column1ResizeHandle, -20, 0).build(); dragAndDrop.perform();//from ww w . j a va 2 s .c om Assert.assertEquals("181px", firstRow.findElement(By.cssSelector("td")).getCssValue("width")); Assert.assertEquals("180px", firstRow.findElement(By.cssSelector("td .rf-edt-c-column1")).getCssValue("width")); }
From source file:org.richfaces.ui.extendedDataTable.ITColumnWidth.java
License:Open Source License
@Test public void column_resize_bigger() { browser.get(contextPath.toExternalForm()); WebElement column1ResizeHandle = header .findElement(By.cssSelector(".rf-edt-hdr .rf-edt-td-column1 .rf-edt-rsz")); Actions builder = new Actions(browser); final Action dragAndDrop = builder.dragAndDropBy(column1ResizeHandle, 20, 0).build(); dragAndDrop.perform();/*from w w w . j av a2 s .c o m*/ Assert.assertEquals("221px", firstRow.findElement(By.cssSelector("td")).getCssValue("width")); Assert.assertEquals("220px", firstRow.findElement(By.cssSelector("td .rf-edt-c-column1")).getCssValue("width")); }
From source file:org.richfaces.ui.extendedDataTable.ITTableState.java
License:Open Source License
@Test public void table_width_resize() throws InterruptedException { // given/* w ww. j a v a 2 s . c o m*/ browser.get(contextPath.toExternalForm() + "width.jsf"); WebElement column1ResizeHandle = header .findElement(By.cssSelector(".rf-edt-hdr .rf-edt-td-column1 .rf-edt-rsz")); Actions builder = new Actions(browser); final Action dragAndDrop = builder.dragAndDropBy(column1ResizeHandle, 60, 0).build(); // when / then Warp.initiate(new Activity() { @Override public void perform() { dragAndDrop.perform(); } }).inspect(new Inspection() { private static final long serialVersionUID = 1L; @Inject IterationTableStateBean bean; @AfterPhase(Phase.INVOKE_APPLICATION) public void verify_table_state_updated() throws JSONException { ExtendedDataTableState beanState = new ExtendedDataTableState(bean.getWidthState()); Assert.assertEquals("Backing bean table state should be updated", "270px", beanState.toJSON().getJSONObject("columnsWidthState").getString("column1")); FacesContext facesContext = FacesContext.getCurrentInstance(); AbstractExtendedDataTable edtComponent = (AbstractExtendedDataTable) facesContext.getViewRoot() .findComponent("myForm").findComponent("edt"); ExtendedDataTableState tableState = new ExtendedDataTableState(edtComponent); Assert.assertEquals("EDT tableState should be updated", "270px", tableState.toJSON().getJSONObject("columnsWidthState").getString("column1")); } }); Assert.assertEquals("270px", firstRow.findElement(By.cssSelector("td .rf-edt-c-column1")).getCssValue("width")); }
From source file:org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceInterface.java
License:Open Source License
/** * This method performs the slider change action of the web interface. * @param slider : The element of the slider to be changed. * @param val : Value to be set./*from w w w.jav a 2 s.c o m*/ */ private void moveSlider(WebElement slider, int val) { Actions move = new Actions(driver); Action action = move.dragAndDropBy(slider, 0, val).build(); action.perform(); }