@Override protected Void handleSeleneseCommand(WebDriver driver, String locator, String value) { Mouse mouse = ((HasInputDevices) driver).getMouse(); ContextClickAction rightClick = new ContextClickAction(mouse, (Locatable) (driver.findElement(By.xpath(locator)))); rightClick.perform(); return null; }
/** * Emulates clicking on the mouse button that would bring up contextual menus (usually * right-clicking). */ public void perform() { moveToLocation(); mouse.contextClick(getActionLocation()); }
/** * Performs a context-click at the current mouse location. * @return A self reference. */ public Actions contextClick() { if (isBuildingActions()) { action.addAction(new ContextClickAction(jsonMouse, null)); } return clickInTicks(RIGHT); }
@Override public List<Interaction> asInteractions(PointerInput mouse, KeyInput keyboard) { List<Interaction> interactions = new ArrayList<>(); interactions.addAll(moveToLocation(mouse)); interactions.add(mouse.createPointerDown(Button.RIGHT.asArg())); interactions.add(mouse.createPointerUp(Button.RIGHT.asArg())); return Collections.unmodifiableList(interactions); } }
/** * Performs a context-click at middle of the given element. First performs a mouseMove * to the location of the element. * * @param target Element to move to. * @return A self reference. */ public Actions contextClick(WebElement target) { if (isBuildingActions()) { action.addAction(new ContextClickAction(jsonMouse, (Locatable) target)); } return moveInTicks(target, 0, 0).clickInTicks(RIGHT); }