Search in sources :

Example 1 with IOSElement

use of io.appium.java_client.ios.IOSElement in project testsigma by testsigmahq.

the class HideKeyboardAction method hideKeyboardByTappingOutsideKeyboard.

private void hideKeyboardByTappingOutsideKeyboard() {
    String keyboardElementClassName = "XCUIElementTypeKeyboard";
    log.info("Using KEYBOARD ELEMENT(Tap/touch above keyboard) to hide keyboard, Element classname:" + keyboardElementClassName);
    try {
        IOSElement element = (IOSElement) getDriver().findElementByClassName(keyboardElementClassName);
        Point keyboardPoint = element.getLocation();
        TouchAction touchAction = new TouchAction(getDriver());
        touchAction.tap(PointOption.point(keyboardPoint.getX() + 2, keyboardPoint.getY() - 2)).perform();
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            log.error("Thread Interrupted exception, Ignore this", e);
        }
        log.info("Using KEYBOARD ELEMENT(Tap/touch above keyboard) to hide keyboard didn't throw any exception.");
    } catch (Exception e) {
        log.error("**Tried to hide keyboard using KEYBOARD ELEMENT(Tap/touch above keyboard)***", e);
    }
}
Also used : IOSElement(io.appium.java_client.ios.IOSElement) Point(org.openqa.selenium.Point) TouchAction(io.appium.java_client.TouchAction)

Example 2 with IOSElement

use of io.appium.java_client.ios.IOSElement in project testsigma by testsigmahq.

the class MobileElementAction method tapByElementCoOrdinates.

public void tapByElementCoOrdinates(WebElement webElement, AppiumDriver driver) throws Exception {
    Point loc = webElement.getLocation();
    if (webElement instanceof IOSElement) {
        loc = ((IOSElement) webElement).getCenter();
    } else if (webElement instanceof AndroidElement) {
        loc = ((AndroidElement) webElement).getCenter();
    }
    int x = loc.getX();
    int y = loc.getY();
    TapPointAction tapPointAction = new TapPointAction();
    tapPointAction.setTapPoint(new com.testsigma.automator.actions.mobile.TapPoint(x, y));
    tapPointAction.setDriver(driver);
    ActionResult result = tapPointAction.run();
    if (ActionResult.FAILED.equals(result)) {
        log.error(tapPointAction.getErrorMessage());
        throw new Exception("Failed to tap at (" + x + ", " + y + ") : " + tapPointAction.getErrorMessage());
    }
}
Also used : IOSElement(io.appium.java_client.ios.IOSElement) ActionResult(com.testsigma.automator.constants.ActionResult) AndroidElement(io.appium.java_client.android.AndroidElement) AutomatorException(com.testsigma.automator.exceptions.AutomatorException)

Aggregations

IOSElement (io.appium.java_client.ios.IOSElement)2 ActionResult (com.testsigma.automator.constants.ActionResult)1 AutomatorException (com.testsigma.automator.exceptions.AutomatorException)1 TouchAction (io.appium.java_client.TouchAction)1 AndroidElement (io.appium.java_client.android.AndroidElement)1 Point (org.openqa.selenium.Point)1