I was previously using
driver.executeScript(String.format(“UIATarget.localTarget().doubleTap({x:%d, y:%d});”, p.getX(), p.getY()));
but this is not working with xcode 8.3 and appium 1.6.4
I was previously using
driver.executeScript(String.format(“UIATarget.localTarget().doubleTap({x:%d, y:%d});”, p.getX(), p.getY()));
but this is not working with xcode 8.3 and appium 1.6.4
public boolean doubleTapElement_XCTest(MobileElement el) {
try {
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> tapObject = new HashMap<String, String>();
tapObject.put("element", el.getId());
js.executeScript("mobile:doubleTap", tapObject);
return true;
} catch (Exception e) {
return false;
}
}
@Aleksei but for simple tap, should be only tap?
@sivanov for tap:
public boolean tapElement_XCTest(MobileElement el) {
try {
// tap into center of element
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> tapObject = new HashMap<String, String>();
tapObject.put("x", String.valueOf(el.getSize().getWidth() / 2));
tapObject.put("y", String.valueOf(el.getSize().getHeight() / 2));
tapObject.put("element", el.getId());
js.executeScript("mobile:tap", tapObject);
return true;
} catch (Exception e) {
return false;
}
}
org.openqa.selenium.UnsupportedCommandException: Unknown command, all the mobile commands except scroll and swipe have been removed. (WARNING: The server did not provide any stacktrace information)
C
you java client version hope latest beta?
For me it’s working like this:
public boolean tapElement(WebElementFacade el) {
try {
JavascriptExecutor js = (JavascriptExecutor) getDriver();
HashMap<String, String> tapObject = new HashMap<>();
tapObject.put("x", String.valueOf(el.getSize().getWidth() / 2));
tapObject.put("y", String.valueOf(el.getSize().getHeight() / 2));
tapObject.put("element", w(el).getId());
js.executeScript("mobile:tap", tapObject);
return true;
} catch (Exception e) {
return false;
}
}
public MobileElement w(WebElement el) {
return (MobileElement) ((WebElementFacade) el).getWrappedElement();
}
Serenity = <serenity.version>1.2.5-rc.1</serenity.version>
java-client = 4.1.2
My java client version is 4.1.1 and Ib cannot upgrade it for some reason.
I need to double tap
So try to use the method above, if not. Upgrade the java client.
I am using this:
public void doubleTapElementIOS(MobileElement element) {
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> tapObject = new HashMap<String, String>();
tapObject.put(“x”, String.valueOf(element.getSize().getWidth() / 2));
tapObject.put(“y”, String.valueOf(element.getSize().getHeight() / 2));
tapObject.put(“element”, element.getId());
js.executeScript(“mobile:doubleTap”, tapObject);
But this does not work.
Still the same exception:
org.openqa.selenium.UnsupportedCommandException: Unknown command, all the mobile commands except scroll and swipe have been removed. (WARNING: The server did not provide any stacktrace information)
C
check my Example! remove x,y from doubleTap and try again.
Finally, this has worked:
public void doubleTapElementIOS(MobileElement element) {
int x, y;
x = element.getCenter().getX();
y = element.getCenter().getY();
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap params = new HashMap<String, Object>();
params.put(“x”, x);
params.put(“y”, y);
params.put(“element”, element.getId());
js.executeScript(“mobile: doubleTap”, params);
Any idea how to do double tap using Python?
This works on iOS10.3 emulator but I can’t make it work on real device iPhone 6 with iOS 10.3:
self.driver.execute_script(“mobile: doubleTap”, {“x”: end_x, “y”: end_y})
for iOS9 I am using something like this:
action.tap(element=None, x=end_x, y=end_y, count=2).perform()
and it works on iPad with iOS9.3 but doesn’t work on iPhone emulator with iOS9.3.
Can anyone help me with this?