Lokesh Lokesh - 1 month ago 26
Android Question

org.openqa.selenium.UnsupportedCommandException error on appium scroll

Model PageI am trying to scroll to a particular element in the screen, getting the below error:

Eclipse Error log:

org.openqa.selenium.UnsupportedCommandException: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource. (Original error: That device doesn't know how to respond to 'mobile: 'scroll--it's probably not using Appium's API) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 13 milliseconds


Below is the Appium error logs:

> info: <-- POST /wd/hub/session/0b79ffed-89dc-66ca-27b0- cf6ef260181a/element 200 18.561 ms - 122
> info: --> POST /wd/hub/session/0b79ffed-89dc-66ca-27b0- cf6ef260181a/execute {"script":"mobile: scroll","args": [{"direction":"down","element":"c845c15a-918c-019f-67a0-ae6a1dbe34c5"}]}
> info: [debug] Responding to client with error: {"status":9,"value": {"message":"The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource. (Original error: That device doesn't know how to respond to 'mobile: 'scroll--it's probably not using Appium's API)","origValue":"That device doesn't know how to respond to 'mobile: 'scroll--it's probably not using Appium's API"},"sessionId":"0b79ffed-89dc-66ca-27b0-cf6ef260181a"}
> info: <-- POST /wd/hub/session/0b79ffed-89dc-66ca-27b0-cf6ef260181a/execute 500 3.576 ms - 449
> info: --> DELETE /wd/hub/session/0b79ffed-89dc-66ca-27b0-cf6ef260181a {}
> info: Shutting down appium session
> info: [debug] Stopping selendroid server
> info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/0b79ffed-89dc-66ca-27b0-cf6ef260181a","method":"DELETE"}
> info: [debug] executing cmd: C:\Users\GangaiahL\AppData\Local\Android\sdk\platform-tools\adb.exe -s 00bd9781 shell "am force-stop au.com.carsguide"
> info: [debug] [SELENDROID] getSystemUiVisibility() after setting = 0
> info: [debug] [SELENDROID] getSystemUiVisibility() after setting = 0
> info: [debug] Stopping logcat capture
> info: [debug] Logcat terminated with code null, signal SIGTERM
> info: [debug] Cleaning up appium session
> info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"0b79ffed-89dc-66ca-27b0-cf6ef260181a"}
> info: <-- DELETE /wd/hub/session/0b79ffed-89dc-66ca-27b0-cf6ef260181a 200 1526.913 ms - 76 {"status":0,"value":null,"sessionId":"0b79ffed-89dc-66ca- 27b0-cf6ef260181a"}


Below is My code:
And the error thrown line-js.executeScript("mobile: scroll", scrollObject);

@Test
public void test() throws InterruptedException
{

System.out.println("TEST STARTED");

driver.findElement(By.linkText("All Makes")).click();
Thread.sleep(10000);
//driver.findElement(By.linkText("AUDI")).click();
WebElement element = driver.findElement(By.linkText("AUDI"));
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
scrollObject.put("element", ((RemoteWebElement) element).getId());
js.executeScript("mobile: scroll", scrollObject);

Answer

1.Do you have any scrollable view in your screen ? 2.If you have scrollable view in screen, do scroll on view not on text.

OR

Try this and ask:

String name ="AUDI";

driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\""+name+"\").instance(0))");

OR

MobileElement element = (MobileElement) driver.findElementByClassName("android.widget.ListView"); 
JavascriptExecutor js = (JavascriptExecutor)driver; 
HashMap<String, String> scrollObject = new HashMap<String, String>(); 
scrollObject.put("direction", "down"); 
scrollObject.put("element", ((RemoteWebElement) element).getId());
scrollObject.put("text", "AUDI"); 
js.executeScript("mobile: scrollTo", scrollObject);

try this one.

I have solved the your problem and I have made the video which will helpful for everyone.

Please the solution for your problem in this link : https://www.youtube.com/watch?v=EdgStq4d0bQ.

Updated Answer :

I have updated my appium to 1.5.3 and fixed your issue & it will help for future also. Please refer this video : https://www.youtube.com/watch?v=bT3tqaLNn-Y

Comments