Getting error in Appium that mobile:longClick is not implemented..is there another way ?

1,149 views
Skip to first unread message

CS

unread,
Sep 2, 2014, 7:34:03 PM9/2/14
to appium-...@googlegroups.com

Hello, 

I'm automating a native Android app using Java and Appium version 1.2.0. I want to automate long press on a row in a list to bring up some options that are accessible through long press, right now  I test it manually. This is what I have tried: 

         WebDriverWait wait = new WebDriverWait(driver, 30);

         HashMap<String,String> longtapObj= new HashMap<String,String>();

    WebElement elem = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//android.widget.ListView[1]/android.widget.RelativeLayout[1]")));

    JavascriptExecutor js = (JavascriptExecutor) driver;    

    longtapObj.put("element", ( (RemoteWebElement) elem).getId()  );

         js.executeScript("mobile:longClick", longtapObj);


Appium server log error: 


2014-09-02T23:29:45.808Z - debug: Request received with params: {"args":[{"element":"5"}],"script":"mobile:longClick"}

2014-09-02T23:29:45.810Z - debug: Responding to client that a method is not implemented


2014-09-02T23:29:45.810Z - info: <-- POST /wd/hub/session/f66d9550-c47e-4380-a0f4-c819a12f59a9/execute 501 3.656 ms - 158 


2014-09-02T23:29:48.518Z - info: --> GET /wd/hub/status {}



Eclipse JUnit error: 


org.openqa.selenium.WebDriverException: Not yet implemented. Please help us: http://appium.io/get-involved.html (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 9 milliseconds


If a comment out the statement  js.executeScript("mobile:longClick"longtapObj);  no errors are thrown. Appreciate if anyone knows the right way to implement a log press using Appium in a native android app. 

Isaac Murchie

unread,
Sep 2, 2014, 11:20:21 PM9/2/14
to CS, appium-...@googlegroups.com
The java client has access to the TouchAction API, in which there is a longPress method. See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/touch-actions.md

--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/d/optout.

CS

unread,
Sep 3, 2014, 2:44:31 PM9/3/14
to appium-...@googlegroups.com, chi...@gmail.com
Issac, 

I tried implementing this using the the TouchAction API. Evidently, this has only one constructor TouchAction(MobileDriver driver).  So :

WebDriver driver=null;

driver =  new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); 

TouchAction action= new TouchAction(driver)

gives error " The constructor TouchAction(WebDriver) is undefined. "

If I try

MobileDriver driver=null;
driver =  new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); 

gives error " type mismatch: Cannot convert from RemoteWebDriver to MobileDriver"

So I tried casting: 

MobileDriver driver=null;

driver =  (MobileDriver) new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);


This removes the compiler error, but when the test runs, it fails: 


java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebDriver cannot be cast to io.appium.java_client.MobileDriver

Am I missing another way to do this ?

To unsubscribe from this group and stop receiving emails from it, send an email to appium-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages