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.coderoad.automation.common.util.PageUtil.java

License:Open Source License

/**
 * Drag and drop./*  w ww . j  a v  a  2 s  .c  om*/
 * 
 * @param driver the driver
 * @param fromElement the from element
 * @param toElement the to element
 * @param xOffset the x offset
 * @param yOffset the y offset
 */
public static void dragAndDrop(final WebDriver driver, final WebElement fromElement, final WebElement toElement,
        final int xOffset, final int yOffset) {

    final Actions builder = new Actions(driver);
    builder.dragAndDrop(fromElement, toElement).build().perform();

}

From source file:com.coderoad.automation.common.util.PageUtil.java

License:Open Source License

/**
 * Move to element.//from   w ww .  j  a  v  a2s  .c o m
 * 
 * @param driver the driver
 * @param element the element
 */
public static void moveToElement(final WebDriver driver, final WebElement element) {

    final Actions builder = new Actions(driver);

    builder.moveToElement(element);
}

From source file:com.coderoad.automation.common.util.PageUtil.java

License:Open Source License

/**
 * Double click./*from   ww w. j  a  v a 2  s . c  o m*/
 * 
 * @param driver the driver
 * @param element the element
 */
public static void doubleClick(final WebDriver driver, final WebElement element) {

    new Actions(driver).doubleClick(element).perform();
}

From source file:com.coderoad.automation.rocketTruedx.page.LoginPage.java

License:Open Source License

/*************************************************************
 * @description Login to TRUedx Na //w w w. j  a va2 s.  c o m
 * @return the dealer search page
 * @throws InterruptedException the interrupted exception
 *************************************************************/
public MainPage loginToRocketTruedxNa(String user, String password) throws InterruptedException {

    driver.manage().deleteAllCookies();
    this.openPage(TestUtils.getRocketTruedxUrl());
    Thread.sleep(500);
    boolean loginpage = getDriver().getPageSource().contains("Logon");
    if (loginpage) {
        Actions builder = new Actions(getDriver());
        builder.moveToElement(formLogonForm).build().perform();
        LogUtil.log("Enter Username :" + user, LogLevel.MEDIUM);
        txtUserName.sendKeys(user);
        LogUtil.log("Enter Username :" + password, LogLevel.MEDIUM);
        txtPassword.sendKeys(password);
        btnSubmit.click();
        WaitUtil.waitUntil(Timeout.FIVE_SEC);
    }
    return PageFactory.initElements(getDriver(), MainPage.class);
}

From source file:com.cognifide.qa.bb.actions.ActionsProvider.java

License:Apache License

@Override
public Actions get() {
    return new Actions(webDriver);
}

From source file:com.cognifide.qa.bb.aem.core.siteadmin.internal.SiteToolbarImpl.java

License:Apache License

@Override
public void createPage(String template, String title, String name) {
    Actions actions = new Actions(webDriver);
    actions.pause(2000).perform();//from  w ww  .  j av  a2  s . c  o m
    createButton.click();
    currentScope.findElement(By.className("cq-siteadmin-admin-create" + StringUtils.lowerCase("page"))).click();
    createPageWizard.selectTemplate(template).provideTitle(title).provideName(name).submit();
}

From source file:com.comcast.dawg.house.EditDeviceUIIT.java

License:Apache License

private EditDeviceOverlay launchEditOverlay(RemoteWebDriver driver, String deviceId) {
    WebElement filteredTable = driver.findElementByClassName(IndexPage.FILTERED_TABLE);
    WebElement deviceRow = filteredTable.findElement(By.xpath("div[@data-deviceid='" + deviceId + "']"));
    (new Actions(driver)).contextClick(deviceRow).perform();
    ContextMenu cxtMenu = new ContextMenu(driver, driver.findElementByClassName(CXT_MENU));
    return cxtMenu.launchEditDeviceOverlay();
}

From source file:com.consol.citrus.selenium.actions.DropDownSelectAction.java

License:Apache License

@Override
protected void execute(WebElement webElement, SeleniumBrowser browser, TestContext context) {
    super.execute(webElement, browser, context);

    Select dropdown = new Select(webElement);

    if (StringUtils.hasText(option)) {
        dropdown.selectByValue(context.replaceDynamicContentInString(option));
    }/*from  w  w  w. j  a v a2  s .  c o m*/

    if (!CollectionUtils.isEmpty(options)) {
        if (BrowserType.IE.equals(browser.getEndpointConfiguration().getBrowserType())) {
            for (String option : options) {
                dropdown.selectByValue(context.replaceDynamicContentInString(option));
            }
        } else {
            List<WebElement> optionElements = dropdown.getOptions();
            Actions builder = new Actions(browser.getWebDriver());
            builder.keyDown(Keys.CONTROL);
            for (String optionValue : options) {
                for (WebElement option : optionElements) {
                    if (!option.isSelected()
                            && isSameValue(option, context.replaceDynamicContentInString(optionValue))) {
                        builder.moveToElement(option).click(option);
                    }
                }
            }
            builder.keyUp(Keys.CONTROL);
            Action multiple = builder.build();
            multiple.perform();
        }
    }
}

From source file:com.consol.citrus.selenium.actions.HoverAction.java

License:Apache License

@Override
protected void execute(WebElement webElement, SeleniumBrowser browser, TestContext context) {
    super.execute(webElement, browser, context);

    Actions builder = new Actions(browser.getWebDriver());
    builder.moveToElement(webElement).perform();
}

From source file:com.consol.citrus.selenium.client.WebClient.java

License:Apache License

/**
 * Select multiple items from a pull-down list.
 *
 * @param by//from   w  ww  .j av a  2  s  .co m
 * @param from Start at index.
 * @param to End at index.
 */
public void selectMultipleItems(By by, int from, int to) {
    Select dropdown = new Select(findElement(by));

    if (BrowserTypeEnum.INTERNET_EXPLORER.equals(browserType)) {
        for (int i = from; i < to; i++) {
            dropdown.selectByIndex(i);
        }
    } else {
        //Rest:
        List<WebElement> options = dropdown.getOptions();
        Actions builder = new Actions(webDriver);
        builder.keyDown(Keys.CONTROL);
        for (int i = from; i < to; i++) {
            WebElement item = options.get(i);
            if (!item.isSelected()) {
                builder.moveToElement(item).click(item);
            }
        }
        builder.keyUp(Keys.CONTROL);
        Action multiple = builder.build();
        multiple.perform();
    }
}