hi,
actually, I have faced this kind of error when i was using like e.g. tap(button).perform()
then I used (X,Y) co-ord but Y co-ord is not correctly located on screen while X co-ord is correct so i add some offset (in my case i add 100 i.e. Y+100) then its worked for me.
But i dont think this is the reliable way to do this job.
public static void tap(WebElement we) {
Point p = we.getLocation();
Dimension size = we.getSize();
try {
nativeContext();
Point appLoc = driver.findElement(By.xpath("//UIAWebView[1]")).getLocation();
driver.tap(1, appLoc.x + p.x + (size.width / 2), appLoc.y + p.y + (size.height / 2), 1);
} finally {
webContext();
}
}Smth that worked on one phone. failed on another...
Is there any ideas how to get correct coordinates for tap?
@jonahss
Looks, this can be fixed in 1.3.2. When are you going to release 1.3.2?
It seems it has been fixed here:
and now is going with the new release.
Also, with the new server release this java client feature60 is going to be published.
Hey, @jonahss, @SergeyTichomirov
Looks, this is no longer valid in 1.3.2:
executeScript("mobile: swipe", swipeObject)
Is there a way to tap, swipe and scrollTo element in webview?
Regarding the last one I'm not sure if it still needed if above will works.
But I got the following:
[36minfo[39m: [37m-->[39m [37mPOST[39m [37m/wd/hub/session/cde2565af9101509c4316c499667ac90/execute[39m [90m{"script":"mobile: swipe","args":[{"startX":0.5,"duration":2,"startY":0.6,"endX":0.5,"endY":0.2}]}[39m
[36minfo[39m: [debug] Tried to execute non-existent mobile command 'swipe'. Most mobile commands have been ported to official client library methods. Please check your Appium library for more information and documentation
[36minfo[39m: [debug] Responding to client that a method is not implemented
Let me get out the error message for trying touch actions for web, like element.tap()
public LobbyPage(AppiumSwipeableDriver driver, String game) {
this.driver = driver;
this.game = game;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
@FindBy(xpath = "//img[contains(@src, 'image')]")
public MobileElement casinoTab;
And the next one is failed with:
casinoTab.tap(1,1);
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at io.appium.java_client.pagefactory.ElementInterceptor.intercept(ElementInterceptor.java:27)
at io.appium.java_client.MobileElement$$EnhancerByCGLIB$$50f36ea9.tap()
at com.pages.LobbyPage.openCasinoTab(LobbyPage.java:67)
at com.pages.LobbyPage.openGameWithLogin(LobbyPage.java:87)
at com.run.ScreenshotMaker.gameActions(ScreenshotMaker.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:38)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:382)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Ok. Now it is clear for me.
AppiumDriver is abstract class since 2.0.0 (java-client version). It is extended by AndroidDriver and IOSDriver. AndoidDriver generates AndroidElements and IOSDriver generates IOSElements. Both AndroidElement and IOSElement extend MobileElement.
AndroidDriver and IOSDriver have specific JsonToWebElementConverters. AppiumDriver has't any specific converter. In your case it works like RemoteWebDriver and you receive RemoteWebElement. It is the root cause of your problem.
Why you are using AppiumSwipeableDriver (customized AppiumDriver)?

