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);
}
}
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());
}
}
Aggregations