WebElement elems=driver.findElement(By.linkText("Custom Development"));//Menu Item WebElement elems1=driver.findElement(By.xpath("//li[@id='item-465']/a"));//Menu Actions builder = new Actions(driver); Actions hoverOverRegistrar = builder.moveToElement(elems1); hoverOverRegistrar.perform(); elems.click();//at last Menu Item Click
Actions builder = new Actions(driver); // Or maybe seleniumDriver? Not sure which one to use Actions hoverOverRegistrar = builder.moveToElement(menuRegistrar); hoverOverRegistrar.perform();
Actions actions = new Actions(driver); WebElement menuHoverLink = driver.findElement(By.linkText("Menu heading")); actions.moveToElement(menuHoverLink); WebElement subLink = driver.findElement(By.cssSelector("#headerMenu .subLink")); actions.moveToElement(subLink); actions.click(); actions.perform();
@Override public SelenideElement execute(SelenideElement proxy, WebElementSource locator, Object[] args) { locator.driver().actions().doubleClick(locator.findAndAssertElementIsInteractable()).perform(); return proxy; } }
@Override public SelenideElement execute(SelenideElement proxy, WebElementSource locator, Object[] args) { locator.driver().actions().contextClick(locator.findAndAssertElementIsInteractable()).perform(); return proxy; } }
@Override public SelenideElement execute(SelenideElement proxy, WebElementSource locator, Object[] args) { WebElement element = locator.getWebElement(); new Actions(locator.driver().getWebDriver()).moveToElement(element).perform(); return proxy; } }
@Override public SelenideElement execute(SelenideElement proxy, WebElementSource locator, Object[] args) { SelenideElement target; if (args[0] instanceof String) { target = ElementFinder.wrap(locator.driver(), By.cssSelector((String) args[0])); } else if (args[0] instanceof WebElement) { target = WebElementWrapper.wrap(locator.driver(), (WebElement) args[0]); } else { throw new IllegalArgumentException("Unknown target type: " + args[0] + " (only String or WebElement are supported)"); } target.shouldBe(visible); new Actions(locator.driver().getWebDriver()).dragAndDrop(locator.getWebElement(), target).perform(); return proxy; } }
private void moveToElement(WebElement element) { new Actions(browser.driver).moveToElement(element).perform(); }
@Override public void run() { // Scroll to status message because it must be visible in order to get its text new Actions(browser.driver).moveToElement(statusMessage).perform(); waitForElementVisibility(statusMessage); assertEquals(expectedTexts, getTextsForAllStatusMessagesToUser()); } }, WebDriverException.class, AssertionError.class);
public static void mouseClickByLocator( String locator ) { WebElement el = driver.findElement( By.cssSelector( locator ) ); Actions builder = new Actions(driver); builder.moveToElement( el ).click( el ); builder.perform(); }
/** * Send keys without a specific target. This allows testing situations where the focus is expressly * manipulated by javascript, and where using {@link #sendKeysToPageBody(String)} will fail due to that. */ public KeyboardShortcuts sendKeysToWindow(String keys) { new Actions(driver).sendKeys(keys).perform(); return this; }
/** * Move horizontally. * @param horizontalOffset * @param verticalOffset */ public static void moveByOffset(int horizontalOffset, int verticalOffset) { getActions().moveByOffset(horizontalOffset, verticalOffset).perform(); }
/** * Moves cursor to {@link WebElement} with provided {@code elementLocator} which attached to DOM * and performs mouse's right button click. * * <p>Note! It does not mean that element is visible. * * @param elementLocator locator of {@link WebElement} for which context menu will be opened. */ public void moveCursorToAndContextClick(By elementLocator) { moveCursorTo(elementLocator); actionsFactory.createAction(seleniumWebDriver).contextClick().perform(); }
public <T extends WebElementFacade> T moveTo(String xpathOrCssSelector, Object... arguments) { if (!driverIsDisabled()) { withAction().moveToElement(findBy(xpathOrCssSelector, arguments)).perform(); } return findBy(xpathOrCssSelector, arguments); }
public J pressTab() { invoker.doJAction("Press Tab on Element", () -> { Actions builder = new Actions(getDriver()); builder.sendKeys(getWebElement(), Keys.TAB).perform(); }); return this; }
public void doubleClicks() { invoker.doJAction("Double click on Element", () -> { Actions builder = new Actions(getDriver()); builder.doubleClick(getWebElement()).perform(); }); }
public void rightClick() { invoker.doJAction("Right click on Element", () -> { Actions builder = new Actions(getDriver()); builder.contextClick(getWebElement()).perform(); }); }
/** * Simulate Space key */ @Override @PublicAtsApi public void pressSpaceKey() { new HiddenHtmlElementState(this).waitToBecomeExisting(); WebElement element = HiddenHtmlElementLocator.findElement(this); new Actions(htmlUnitDriver).sendKeys(element, Keys.SPACE).perform(); }
/** * Simulate Tab key */ @Override @PublicAtsApi public void pressTabKey() { new HiddenHtmlElementState(this).waitToBecomeExisting(); WebElement element = HiddenHtmlElementLocator.findElement(this); new Actions(htmlUnitDriver).sendKeys(element, Keys.TAB).perform(); }
private void dragAndDropWithOffset(final WebElement source, final WebElement target, final int offset) { Point currentLocation = source.getLocation(); Point destination = target.getLocation(); // We need to ensure we have the source in view. An egrgarious hack to make sure we can do this. // Assumes that scrolling to the top of the page will have our source AND target in the viewable area driver.findElement(By.tagName("body")).getSize(); int xOffset = destination.x - currentLocation.x + 1; int yOffset = destination.y - currentLocation.y + offset; Actions action = new Actions(driver).dragAndDropBy(source, xOffset, yOffset); action.perform(); }