testing-samples
testing-samples copied to clipboard
UiSelector.resourceId("myButtonId") not working
I'm trying to get the facebook Login button in UIautomator but its failing to find the button given the id of the button
<com.facebook.login.widget.LoginButton
android:id="@+id/login_button_facebook"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"/>
And here is the code how I'm accessing the button in my test case
UiObject facebookButton = mDevice.findObject(new UiSelector().resourceId("login_button_facebook"));
Its failing to find the button saying :
android.support.test.uiautomator.UiObjectNotFoundException: UiSelector[RESOURCE_ID=login_button_facebook]
at android.support.test.uiautomator.UiObject.click(UiObject.java:416)
Please let me know if I'm doing it wrong. The documentation has not much detail about how to use it.
The id needs to include the package.
UiSelector().resourceId("com.example.something:id/login_button_facebook"));
This requirement is not well documented.