Hi all,
While learning Appium, i am playing around Android “scroll” method, i got an UiObjectNotFoundException though there is a value with the text which i am looking.
Following is my code:
public class addPhotoToContact
{
static AndroidDriver driver;
public static void main(String args)
{
DesiredCapabilities caps=new DesiredCapabilities();
caps.setCapability(“deviceName”, “emulator-5554”);
caps.setCapability(“appPackage”, “com.android.contacts”);
caps.setCapability(“appActivity”, “.activities.PeopleActivity”);
try
{
driver=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),caps);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
} catch (MalformedURLException e)
{
e.printStackTrace();
}
//Click on create a new contact
driver.findElementByAndroidUIAutomator("resourceId(\"com.android.contacts:id/create_contact_button\")").click();
//Click on Change button
driver.findElementByAndroidUIAutomator("resourceId(\"com.android.contacts:id/change_button\")").click();
//Click on Choose Photo
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/text1\").text(\"Choose photo\")").click();
//Scroll to the element that we are looking and clicks
driver.scrollTo("xyz").click();
}
}
Following is the error message i am getting in Appium:
info: ← POST /wd/hub/session/bc90685c-0cc9-4f59-a757-75f5b6370ae9/element/3/click 200 3009.287 ms - 76 {“status”:0,“value”:true,“sessionId”:“bc90685c-0cc9-4f59-a757-75f5b6370ae9”}
info: → POST /wd/hub/session/bc90685c-0cc9-4f59-a757-75f5b6370ae9/element {“using”:“-android uiautomator”,“value”:“new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().descriptionContains("xyz").instance(0));new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains("xyz").instance(0));”}
info: [debug] Waiting up to 10000ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“-android uiautomator”,“selector”:“new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().descriptionContains("xyz").instance(0));new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains("xyz").instance(0));”,“context”:“”,“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“-android uiautomator”,“selector”:“new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().descriptionContains("xyz").instance(0));new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains("xyz").instance(0));”,“context”:“”,“multiple”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().descriptionContains(“xyz”).instance(0));new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“xyz”).instance(0)); using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing scrollable: new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().descriptionContains(“xyz”).instance(0))
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: boolean arg: true
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: int arg: 0
> info: [debug] [BOOTSTRAP] [debug] UiScrollable invoking method: public boolean com.android.uiautomator.core.UiScrollable.scrollIntoView(com.android.uiautomator.core.UiObject) throws com.android.uiautomator.core.UiObjectNotFoundException args: new UiSelector().descriptionContains(“xyz”).instance(0),
info: [debug] [BOOTSTRAP] [debug] UiScrollable coerce type: class com.android.uiautomator.core.UiObject arg: new UiSelector().descriptionContains(“xyz”).instance(0)
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “xyz”
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: int arg: 0
info: [debug] [BOOTSTRAP] [debug] Method name: scrollIntoView
info: [debug] [BOOTSTRAP] [debug] Setting uiObject for scrollIntoView
info: [debug] [BOOTSTRAP] [debug] Invoking method: public boolean com.android.uiautomator.core.UiScrollable.scrollIntoView(com.android.uiautomator.core.UiObject) throws com.android.uiautomator.core.UiObjectNotFoundException with: com.android.uiautomator.core.UiObject@11dadf36
info: [debug] [BOOTSTRAP] [error] com.android.uiautomator.core.UiObjectNotFoundException: UiSelector[INSTANCE=0, SCROLLABLE=true]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:9,“value”:“Could not parse UiSelector argument: problem using reflection to call this method”}
info: [debug] Condition unmet after 18455ms. Timing out.
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.”,“origValue”:“Could not parse UiSelector argument: problem using reflection to call this method”},“sessionId”:“bc90685c-0cc9-4f59-a757-75f5b6370ae9”}
info: ← POST /wd/hub/session/bc90685c-0cc9-4f59-a757-75f5b6370ae9/element 500 18492.343 ms - 317
info: [debug] Didn’t get a new command in 60 secs, shutting down…
Now can someone tell me how to overcome this error?