List of usage examples for org.openqa.selenium.interactions Actions contextClick
public Actions contextClick(WebElement target)
From source file:org.finra.jtaf.ewd.widget.element.InteractiveElement.java
License:Apache License
@Override public void rightClick() throws WidgetException { try {//from w ww. j a v a 2 s.co m Actions builder = new Actions(getGUIDriver().getWrappedDriver()); synchronized (InteractiveElement.class) { getGUIDriver().focus(); builder.contextClick(getWebElement()).build().perform(); } } catch (Exception e) { throw new WidgetException("Error while right clicking element", getLocator(), e); } }
From source file:org.richfaces.tests.showcase.contextMenu.AbstractContextMenuTest.java
License:Open Source License
protected void checkContextMenuRenderedAtCorrectPosition(WebElement target, WebElement contextMenuPopup, InvocationType type, ExpectedCondition<Boolean> conditionTargetIsFocused) { Actions builder = new Actions(GrapheneContext.getProxy()); if (conditionTargetIsFocused != null) { target.click();/*from w ww . j a v a 2 s.c o m*/ Graphene.waitGui(webDriver).withTimeout(2, TimeUnit.SECONDS).until(conditionTargetIsFocused); } waitGui(); // clicks in the middle of the target switch (type) { case LEFT_CLICK: builder.click(target); break; case RIGHT_CLICK: builder.contextClick(target); break; default: throw new IllegalArgumentException("Wrong type of context menu invocation!"); } builder.build().perform(); Graphene.waitGui().withTimeout(2, TimeUnit.SECONDS).until(element(contextMenuPopup).isVisible()); Point locationOfTarget = target.getLocation(); Point locationOfCtxMenu = contextMenuPopup.getLocation(); double witdth = getTargetWidth(target); double height = getTargetHeight(target); double halfOfDiagonal = Math.sqrt((height * height) + (witdth * witdth)) / 2.0; double distance = getDistance(locationOfTarget, locationOfCtxMenu); double result = halfOfDiagonal - distance; assertTrue(result >= 0 && result < TOLERANCE, "The context menu was not rendered on the correct position! The difference is: " + result); }
From source file:org.senchalabs.gwt.gwtdriver.gxt.models.TabPanel.java
License:Apache License
/** * Attempts a right click in the browser to show the context menu. Must be enabled in the client code, or no menu will be found * @see com.sencha.gxt.widget.core.client.TabPanel#setCloseContextMenu(boolean) *//* w w w.j a v a2 s . c om*/ public Menu rightClickTabWithText(String text) { List<WebElement> elements = getElement() .findElements(By.xpath(".//*[contains(text()," + escapeToString(text) + ")]")); for (WebElement elt : elements) { if (!elt.findElements(new FasterByChained(new ByNearestWidget(getDriver()), new ByWidget(getDriver(), com.sencha.gxt.widget.core.client.TabPanel.class))).isEmpty()) { Actions a = new Actions(getDriver()); a.contextClick(elt); a.perform(); return GwtWidget.find(Menu.class, getDriver()).atTop().done(); } } throw new NoSuchElementException("No tab found with text '" + text + "'"); }