Search in sources :

Example 26 with Actions

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

the class RealHtmlElement method rightClick.

/**
     * Simulate mouse right click action
     */
@Override
@PublicAtsApi
public void rightClick() {
    new RealHtmlElementState(this).waitToBecomeExisting();
    WebElement element = RealHtmlElementLocator.findElement(this);
    new Actions(webDriver).contextClick(element).perform();
}
Also used : RealHtmlElementState(com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState) Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 27 with Actions

use of org.openqa.selenium.interactions.Actions 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 28 with Actions

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

the class RealHtmlElementState method focus.

/**
     * Moves the focus to the specified element.
     * <b>Note:</b> This is somewhat breakable as
     * the browser window needs to be the active system window, otherwise the keyboard
     * events will go to another application.
     */
@PublicAtsApi
public void focus() {
    // retrieve browser focus
    webDriver.switchTo().window(webDriver.getWindowHandle());
    // now focus the target element
    WebElement webElement = RealHtmlElementLocator.findElement(element);
    if ("input".equals(webElement.getTagName())) {
        webElement.sendKeys("");
    } else {
        new Actions(webDriver).moveToElement(webElement).perform();
    }
}
Also used : Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 29 with Actions

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

the class MobileCheckBox method unCheck.

/**
     * Uncheck the check box
     */
@Override
@PublicAtsApi
public void unCheck() {
    new MobileElementState(this).waitToBecomeExisting();
    try {
        WebElement checkboxElement = MobileElementFinder.findElement(appiumDriver, this);
        if (checkboxElement.isSelected()) {
            if (appiumDriver instanceof AndroidDriver) {
                // checkboxElement.click(); // throwing exception (on Android) with message: Element is not clickable at point (x,y). Other element would receive the click
                new Actions(appiumDriver).moveToElement(checkboxElement).click().perform();
            } else {
                checkboxElement.click();
            }
        }
    } catch (Exception se) {
        throw new MobileOperationException(this, "unCheck", se);
    }
    UiEngineUtilities.sleep();
}
Also used : Actions(org.openqa.selenium.interactions.Actions) MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) AndroidDriver(io.appium.java_client.android.AndroidDriver) WebElement(org.openqa.selenium.WebElement) MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) MobileElementState(com.axway.ats.uiengine.utilities.mobile.MobileElementState) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 30 with Actions

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

the class HiddenHtmlElement method setTextContent.

/**
     * Set the content of the element
     * @param content the new content
     */
@PublicAtsApi
public void setTextContent(String content) {
    new HiddenHtmlElementState(this).waitToBecomeExisting();
    WebElement element = HiddenHtmlElementLocator.findElement(this);
    new Actions(htmlUnitDriver).sendKeys(element, content).perform();
}
Also used : HiddenHtmlElementState(com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState) Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

Actions (org.openqa.selenium.interactions.Actions)100 WebElement (org.openqa.selenium.WebElement)59 WebDriver (org.openqa.selenium.WebDriver)26 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)18 PublicAtsApi (com.axway.ats.common.PublicAtsApi)16 Test (org.junit.Test)16 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)9 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)6 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)4 List (java.util.List)3 Action (org.openqa.selenium.interactions.Action)3 MobileOperationException (com.axway.ats.uiengine.exceptions.MobileOperationException)2 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)2 MobileElementState (com.axway.ats.uiengine.utilities.mobile.MobileElementState)2 AndroidDriver (io.appium.java_client.android.AndroidDriver)2 File (java.io.File)2 DecimalFormat (java.text.DecimalFormat)2 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)2 SystemException (com.github.bordertech.wcomponents.util.SystemException)1 JavascriptActions (com.wikia.webdriver.common.core.elemnt.JavascriptActions)1