Search in sources :

Example 1 with Action

use of org.openqa.selenium.interactions.Action in project java.webdriver by sayems.

the class ActionBuildPerform method main.

public static void main(String... args) {
    WebDriver driver = new FirefoxDriver();
    driver.get("file://C:/selectable.html");
    WebElement one = driver.findElement(By.name("one"));
    WebElement three = driver.findElement(By.name("three"));
    WebElement five = driver.findElement(By.name("five"));
    // Add all the actions into the Actions builder.
    Actions builder = new Actions(driver);
    builder.keyDown(Keys.CONTROL).click(one).click(three).click(five).keyUp(Keys.CONTROL);
    // Generate the composite action.
    Action compositeAction = builder.build();
    // Perform the composite action.
    compositeAction.perform();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Action(org.openqa.selenium.interactions.Action) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement)

Example 2 with Action

use of org.openqa.selenium.interactions.Action in project ats-framework by Axway.

the class RealHtmlElement method dragAndDropTo.

/**
     * Drag and drop an element on top of other element
     * @param targetElement the target element
     */
@Override
@PublicAtsApi
public void dragAndDropTo(HtmlElement targetElement) {
    new RealHtmlElementState(this).waitToBecomeExisting();
    WebElement source = RealHtmlElementLocator.findElement(this);
    WebElement target = RealHtmlElementLocator.findElement(targetElement);
    Actions actionBuilder = new Actions(webDriver);
    Action dragAndDropAction = actionBuilder.clickAndHold(source).moveToElement(target, 1, 1).release(target).build();
    dragAndDropAction.perform();
// drops the source element in the middle of the target, which in some cases is not doing drop on the right place
// new Actions( webDriver ).dragAndDrop( source, target ).perform();
}
Also used : RealHtmlElementState(com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState) Action(org.openqa.selenium.interactions.Action) Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 3 with Action

use of org.openqa.selenium.interactions.Action in project ats-framework by Axway.

the class HiddenHtmlElement method dragAndDropTo.

/**
     * Drag and drop an element on top of other element
     * @param targetElement the target element
     */
@Override
@PublicAtsApi
public void dragAndDropTo(HtmlElement targetElement) {
    new HiddenHtmlElementState(this).waitToBecomeExisting();
    WebElement source = HiddenHtmlElementLocator.findElement(this);
    WebElement target = HiddenHtmlElementLocator.findElement(targetElement);
    Actions actionBuilder = new Actions(htmlUnitDriver);
    Action dragAndDropAction = actionBuilder.clickAndHold(source).moveToElement(target, 1, 1).release(target).build();
    dragAndDropAction.perform();
// drops the source element in the middle of the target, which in some cases is not doing drop on the right place
// new Actions( htmlUnitDriver ).dragAndDrop( source, target ).perform();
}
Also used : HiddenHtmlElementState(com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState) Action(org.openqa.selenium.interactions.Action) Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

WebElement (org.openqa.selenium.WebElement)3 Action (org.openqa.selenium.interactions.Action)3 Actions (org.openqa.selenium.interactions.Actions)3 PublicAtsApi (com.axway.ats.common.PublicAtsApi)2 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)1 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)1 WebDriver (org.openqa.selenium.WebDriver)1 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)1