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.thoughtworks.selenium.webdriven.commands.DoubleClick.java

License:Apache License

@Override
protected Void handleSeleneseCommand(WebDriver driver, String locator, String value) {
    alertOverride.replaceAlertMethod(driver);

    WebElement element = finder.findElement(driver, locator);

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

    return null;// w ww .  j  av a  2s . c  om
}

From source file:com.thoughtworks.selenium.webdriven.commands.DragAndDrop.java

License:Apache License

@Override
protected Void handleSeleneseCommand(WebDriver driver, String locator, String movementsString) {
    String[] parts = movementsString.split("\\s*,\\s*", 2);
    int xDelta = Integer.parseInt(parts[0].trim());
    int yDelta = Integer.parseInt(parts[1].trim());

    WebElement element = finder.findElement(driver, locator);
    new Actions(driver).dragAndDropBy(element, xDelta, yDelta).perform();

    return null;/* ww w.ja va  2 s . com*/
}

From source file:com.thoughtworks.selenium.webdriven.commands.DragAndDropToObject.java

License:Apache License

@Override
protected Void handleSeleneseCommand(WebDriver driver, String locatorFrom, String locatorTo) {
    WebElement elementFrom = finder.findElement(driver, locatorFrom);
    WebElement elementTo = finder.findElement(driver, locatorTo);
    new Actions(driver).dragAndDrop(elementFrom, elementTo).perform();

    return null;/*from  w  w w .ja  v  a 2s.com*/
}

From source file:com.thoughtworks.selenium.webdriven.commands.KeyDownNative.java

License:Apache License

@Override
protected Void handleSeleneseCommand(WebDriver driver, String keyCode, String ignored) {
    char[] chars = Character.toChars(Integer.parseInt(keyCode));
    new Actions(driver).keyDown(Keys.getKeyFromUnicode(chars[0])).perform();
    return null;/* w w  w .  jav  a  2  s .  com*/
}

From source file:com.thoughtworks.selenium.webdriven.commands.KeyPressNative.java

License:Apache License

@Override
protected Void handleSeleneseCommand(WebDriver driver, String keyCode, String ignored) {
    System.out.println(keyCode);//from   ww w .  j  a v a2  s . c o m
    char[] chars = Character.toChars(Integer.parseInt(keyCode));
    System.out.println(chars);
    new Actions(driver).sendKeys(new String(chars)).perform();
    return null;
}

From source file:com.thoughtworks.selenium.webdriven.commands.KeyUpNative.java

License:Apache License

@Override
protected Void handleSeleneseCommand(WebDriver driver, String keyCode, String ignored) {
    char[] chars = Character.toChars(Integer.parseInt(keyCode));
    new Actions(driver).keyUp(Keys.getKeyFromUnicode(chars[0])).perform();
    return null;//ww w . jav  a2 s  . co  m
}

From source file:com.tricentis.automobileinsurance.utility.AutomobileUtil.java

/**
 * /*from  www  .  j  a va  2 s . c  o  m*/
 * @param browserName
 */
public void setEnvironment(String browserName) {
    if (browserName.equalsIgnoreCase("firefox")) {
        /*Open firefox browser*/
        System.setProperty(AutomobileConstant.FIREFOXDRIVER_KEY, AutomobileConstant.FIREFOXDRIVER_VALUE);
        driver = new FirefoxDriver();
    } else if (browserName.equalsIgnoreCase("chrome")) {
        System.setProperty(AutomobileConstant.CHROMEDRIVER_KEY, AutomobileConstant.CHROMEDRIVER_VALUE);
        driver = new ChromeDriver();
    } else {
        System.setProperty(AutomobileConstant.IEDRIVER_KEY, AutomobileConstant.IEDRIVER_VALUE);
        driver = new InternetExplorerDriver();
    }
    /*implicit wait*/
    driver.manage().timeouts().implicitlyWait(AutomobileConstant.IMPLICIT_WAIT, TimeUnit.SECONDS);
    /*maximize browser window*/
    driver.manage().window().maximize();
    /* hit the application URL*/
    driver.get(AutomobileConstant.APPLICATION_URL);
    action = new Actions(driver);
}

From source file:com.uisteps.core.user.browser.Browser.java

License:Apache License

public void clickOnPoint(WrapsElement element, int x, int y) {

    try {//w w  w . j a va 2 s  .  co m
        Actions actions = new Actions(getDriver());
        actions.moveToElement(element.getWrappedElement(), x, y).click().build().perform();

    } catch (Exception ex) {
        throw new AssertionError("Cannot click " + element + "on point (" + x + "; " + y + ") !\n" + ex);
    }
}

From source file:com.uisteps.core.user.browser.Browser.java

License:Apache License

public void moveMouseOver(WrapsElement element) {

    try {//from  w  ww. j  a  v  a 2s .  c o m
        Actions actions = new Actions(getDriver());
        actions.moveToElement(element.getWrappedElement()).build().perform();
    } catch (Exception ex) {
        throw new AssertionError("Cannot move mouse over " + element + "!\n" + ex);
    }
}

From source file:com.uttesh.selenium.testng.highcharts.HighCharts.java

public HighCharts(WebDriver driver, WebElement chart) {
    PageFactory.initElements(new DefaultElementLocatorFactory(chart), this);
    this.driver = driver;
    this.chart = chart;

    int waitTimeoutInSeconds = 15;
    wait = new WebDriverWait(driver, waitTimeoutInSeconds, 100);
    performAction = new Actions(driver);
}