Example usage for org.openqa.selenium.interactions Actions Actions

List of usage examples for org.openqa.selenium.interactions Actions Actions

Introduction

In this page you can find the example usage for org.openqa.selenium.interactions Actions Actions.

Prototype

public Actions(WebDriver driver) 

Source Link

Usage

From source file:com.mgmtp.jfunk.web.util.WebDriverTool.java

License:Apache License

/**
 * Delegates to {@link #findElement(By)} and then performs a context-click using the
 * {@link Actions} class./*ww w.  j a  v a 2  s .  co m*/
 *
 * @param by
 *            the {@link By} used to locate the element
 */
public void contextClick(final By by) {
    checkTopmostElement(by);
    WebElement element = findElement(by);
    new Actions(webDriver).contextClick(element).perform();
}

From source file:com.mgmtp.jfunk.web.util.WebDriverTool.java

License:Apache License

/**
 * Delegates to {@link #findElement(By)} and then performs a double-click using the
 * {@link Actions} class.//from  w w  w  .  ja  va 2s .c  o m
 *
 * @param by
 *            the {@link By} used to locate the element
 */
public void doubleClick(final By by) {
    checkTopmostElement(by);
    WebElement element = findElement(by);
    new Actions(webDriver).doubleClick(element).perform();
}

From source file:com.mgmtp.jfunk.web.util.WebDriverTool.java

License:Apache License

/**
 * Delegates to {@link #findElement(By)} and then moves the mouse to the returned element
 * using the {@link Actions} class./* w w  w.  j  a v a 2s  .  com*/
 *
 * @param by
 *            the {@link By} used to locate the element
 */
public void hover(final By by) {
    checkTopmostElement(by);
    WebElement element = findElement(by);
    new Actions(webDriver).moveToElement(element).perform();
}

From source file:com.mgmtp.jfunk.web.util.WebDriverTool.java

License:Apache License

/**
 * Delegates to {@link #findElement(By)}, moves the mouse to the returned element using the
 * {@link Actions} class and then tries to find and element using {@code byToAppear}.
 * Default timeouts are applied./*w w  w .  j av a  2 s .c o m*/
 *
 * @param by
 *            the {@link By} used to locate the element
 * @param byToAppear
 *            the {@link By} used to locate the element that is supposed to appear after
 *            hovering
 */
public WebElement hover(final By by, final By byToAppear) {
    final WebElementFinder finder = wef.timeout(2L, 200L).by(byToAppear);

    return waitFor((ExpectedCondition<WebElement>) input -> {
        WebElement element = finder.by(by).find();
        checkTopmostElement(by);
        new Actions(webDriver).moveToElement(element).perform();
        return finder.by(byToAppear).find();
    });
}

From source file:com.mgmtp.jfunk.web.util.WebDriverTool.java

License:Apache License

private Rectangle getElementsVisibleRectangle(By by) {
    Rectangle viewport = getViewport();
    Rectangle intersection = viewport.intersection(getBoundingClientRect(by));
    if (intersection == null) {
        LOGGER.info("Scrolling the element identified by '{}' into the viewport.", by);
        new Actions(webDriver).moveToElement(findElement(by)).perform();
        intersection = viewport.intersection(getBoundingClientRect(by));
        if (intersection == null) {
            throw new WebElementException(
                    format("The element identified by '%s' is outside the viewport.", by));
        }/*from  www  .  j  a  v a 2s  . c  o m*/
    }
    return intersection;
}

From source file:com.mkl.websuites.internal.command.impl.click.ContextClickCommand.java

License:Apache License

@Override
protected void doOperationOnElement(WebElement elem) {
    Actions actions = new Actions(browser);
    actions.contextClick(elem).perform();
}

From source file:com.mkl.websuites.internal.command.impl.click.DoubleClickCommand.java

License:Apache License

@Override
protected void doOperationOnElement(WebElement elem) {
    Actions actions = new Actions(browser);
    actions.doubleClick(elem).perform();
}

From source file:com.mkl.websuites.internal.command.impl.key.PressCommand.java

License:Apache License

@Override
protected void runStandardCommand() {
    Actions action = new Actions(browser);
    String[] keyTokens = keyCombination.trim().toUpperCase(Locale.getDefault()).split("-");
    for (String key : keyTokens) {
        if (isModifier(key)) {
            action = action.keyUp(keyFromModifier(key));
        } else {//from   w  ww. j a v a 2 s  .c om
            action = action.sendKeys(keyFromString(key));
        }
    }
    action.build().perform();
}

From source file:com.mroza.seleniumTests.MrozaViewPage.java

License:Open Source License

protected void clickDialogButton(String buttonName) {
    WebElement dialog = getVisibleDialogBox();
    WebElement buttonPanel = dialog.findElement(By.className("ui-dialog-buttonpane"));
    List<WebElement> buttons = buttonPanel.findElements(By.tagName("button"));

    for (WebElement button : buttons) {
        List<WebElement> spanElements = button.findElements(By.tagName("span"));
        if (spanElements.get(1).getText().equals(buttonName)) {
            Actions actions = new Actions(driver);
            actions.moveToElement(button).click().perform();
            SeleniumWaiter.waitForJQueryAndPrimeFaces(driver);
            break;
        }//from   w  ww  . j av a  2  s . c o m
    }
}

From source file:com.mycompany.fullslidertest.FullsliderTest.java

public void createPresentation(String title) {
    driver = new ChromeDriver();
    js = (JavascriptExecutor) driver;/*www .  jav  a  2 s .co  m*/
    actions = new Actions(driver);

    driver.get("http://localhost:8888");
    driver.manage().window().maximize();

    js.executeScript("$('.newpresopanel')[0].click()");
    js.executeScript("$('#titleinput').val('" + title + "')");
    js.executeScript("$('.createpresentation')[0].click()");
}