List of usage examples for org.openqa.selenium.interactions Mouse mouseDown
void mouseDown(Coordinates where);
From source file:com.elastica.webelements.HtmlElement.java
License:Apache License
/** * Forces a mouseDown event on the WebElement. */// ww w . j a v a 2 s. c om public void mouseDown() { TestLogging.log("MouseDown " + this.toString()); findElement(); Mouse mouse = ((HasInputDevices) driver).getMouse(); mouse.mouseDown(null); }
From source file:com.preferanser.webtest.steps.EndUserSteps.java
License:Open Source License
@Step public EndUserSteps dragsCardToOtherLocation(Card card, TableLocation fromLocation, TableLocation toLocation) { TablePage page = getTablePage();//w ww . jav a 2s .c o m Optional<WebElementFacade> maybeCard = page.getCardAtTableLocationElement(card, fromLocation); assertTrue(maybeCard.isPresent()); Optional<WebElementFacade> maybeTableLocation = page.getTableLocationElement(toLocation); assertTrue(maybeTableLocation.isPresent()); Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); mouse.mouseMove(maybeCard.get().getCoordinates(), 3, 3); // grab the top left corner mouse.mouseDown(null); // at the current location mouse.mouseMove(maybeTableLocation.get().getCoordinates()); mouse.mouseUp(maybeTableLocation.get().getCoordinates()); return this; }
From source file:org.oneandone.qxwebdriver.ui.core.WidgetImpl.java
License:LGPL
public void dragOver(Widget target) throws InterruptedException { Mouse mouse = ((HasInputDevices) driver.getWebDriver()).getMouse(); Locatable root = (Locatable) driver.findElement(By.tagName("body")); //cast WebElement to Locatable Locatable sourceL = (Locatable) contentElement; Locatable targetL = (Locatable) target.getContentElement(); Coordinates coord = root.getCoordinates(); mouse.mouseDown(sourceL.getCoordinates()); //get source position (center,center) int sourceX = sourceL.getCoordinates().onPage().x + ((int) contentElement.getSize().width / 2); int sourceY = sourceL.getCoordinates().onPage().y + ((int) contentElement.getSize().height / 2); // get target position (center, center) int targetX = targetL.getCoordinates().onPage().x + ((int) target.getContentElement().getSize().width / 2); int targetY = targetL.getCoordinates().onPage().y + ((int) target.getContentElement().getSize().height / 2); //compute deltas between source and target position //delta must be positive, however //also we have to define the direction int deltaX;/*from ww w.j a v a 2s .c o m*/ int directionX = 1; //move direction is right int deltaY; int directionY = 1; //move direction is bottom deltaX = targetX - sourceX; if (deltaX < 0) { deltaX *= -1; directionX = -1; // move direction is left } deltaY = targetY - sourceY; if (deltaY < 0) { deltaY *= -1; directionY = -1; // move direction is top } //define base delta, which must be the higher one int baseDelta = deltaX; if (deltaY > deltaX) { baseDelta = deltaY; } // iterate base delta, set mouse cursor in relation to delta x & delta y int x = 0; int y = 0; for (int i = 1; i <= baseDelta; i += 4) { if (i > baseDelta) { i = baseDelta; } x = (int) sourceX + (deltaX * i / baseDelta * directionX); y = (int) sourceY + (deltaY * i / baseDelta * directionY); mouse.mouseMove(coord, x, y); //System.out.println(x +", "+ y); Thread.sleep(1); } // source has the same coordinates as target if (sourceX == targetX && sourceY == targetY) { mouse.mouseMove(targetL.getCoordinates(), x++, y); Thread.sleep(20); } }
From source file:org.oneandone.qxwebdriver.ui.mobile.core.WidgetImpl.java
License:LGPL
public static void longtap(WebDriver driver, WebElement element) { if (driver instanceof HasTouchScreen) { TouchActions longtap = new TouchActions(driver); Point center = getCenter(element); longtap.down(center.getX(), center.getY()); longtap.perform();/* w w w . ja v a2 s. c om*/ try { Thread.sleep(750); } catch (InterruptedException e) { } longtap.up(center.getX(), center.getY()); longtap.perform(); } else { Locatable locatable = (Locatable) element; Coordinates coords = locatable.getCoordinates(); Mouse mouse = ((HasInputDevices) driver).getMouse(); mouse.mouseDown(coords); try { Thread.sleep(750); } catch (InterruptedException e) { } mouse.mouseUp(coords); } }
From source file:org.richfaces.tests.metamer.ftest.richContextMenu.TestContextMenu.java
License:Open Source License
@Test @CoversAttributes("onmousedown") @Templates(value = "plain") public void testOnmousedown() { updateShowAction();//from w w w . j a v a 2s.c o m testFireEvent(contextMenuAttributes, ContextMenuAttributes.onmousedown, new Action() { @Override public void perform() { page.getContextMenu().advanced().show(page.getTargetPanel1()); Mouse mouse = ((HasInputDevices) driver).getMouse(); mouse.mouseDown( ((Locatable) page.getContextMenu().advanced().getItemsElements().get(2)).getCoordinates()); } }); }
From source file:org.richfaces.tests.metamer.ftest.richContextMenu.TestContextMenu.java
License:Open Source License
@Test @CoversAttributes("onmouseup") @Templates(value = "plain") public void testOnmouseup() { updateShowAction();//w ww . j a v a 2s .c o m testFireEvent(contextMenuAttributes, ContextMenuAttributes.onmouseup, new Action() { @Override public void perform() { page.getContextMenu().advanced().show(page.getTargetPanel1()); Mouse mouse = ((HasInputDevices) driver).getMouse(); Coordinates coords = ((Locatable) page.getContextMenu().advanced().getItemsElements().get(2)) .getCoordinates(); mouse.mouseDown(coords); mouse.mouseUp(coords); } }); }
From source file:org.richfaces.tests.metamer.ftest.richDropDownMenu.AbstractDropDownMenuTest.java
License:Open Source License
@CoversAttributes("onmousedown") public void testOnmousedown() { updateDropDownMenuInvoker();/* w ww . ja va2 s. co m*/ testFireEvent(dropDownMenuAttributes, DropDownMenuAttributes.onmousedown, new Action() { @Override public void perform() { getCurrentMenu().advanced().show(page.getTarget1()); Mouse mouse = ((HasInputDevices) driver).getMouse(); mouse.mouseDown( ((Locatable) getCurrentMenu().advanced().getItemsElements().get(1)).getCoordinates()); } }); }
From source file:org.richfaces.tests.metamer.ftest.richDropDownMenu.AbstractDropDownMenuTest.java
License:Open Source License
@CoversAttributes("onmouseup") public void testOnmouseup() { updateDropDownMenuInvoker();/* ww w . j a v a 2 s . co m*/ testFireEvent(dropDownMenuAttributes, DropDownMenuAttributes.onmouseup, new Action() { @Override public void perform() { getCurrentMenu().advanced().show(page.getTarget1()); Mouse mouse = ((HasInputDevices) driver).getMouse(); Coordinates coords = ((Locatable) getCurrentMenu().advanced().getItemsElements().get(1)) .getCoordinates(); mouse.mouseDown(coords); mouse.mouseUp(coords); } }); }
From source file:org.specrunner.webdriver.actions.input.mouse.PluginMouseDownCoordinates.java
License:Open Source License
@Override protected void doEnd(IContext context, IResultSet result, WebDriver client, HasInputDevices input, Mouse mouse) throws PluginException { mouse.mouseDown(getCoordinates()); result.addResult(Success.INSTANCE, context.peek()); }