Ani Daniel
Ani Daniel

Reputation: 11

Uiautomator - cannot use UiObject2

I'm trying to create a new UiObject2 in UiAutomator but I receive the following message:

UiObject2(android.support.test.uiautomator.UiDevice, android.support.test.uiautomator.BySelector, android.view.accessibility.AccessibilityNodeInfo) is not public in 'android.support.test.uiautomator.UiObject2'. Cannot be accessed from outside package

Does anyone know how to fix this?

Upvotes: 1

Views: 1115

Answers (1)

MadHatter
MadHatter

Reputation: 395

UiObject2 resultsObj = mDevice.findObject(By.clazz("android.widget.ExpandableListView").res("android:id/list").pkg(PACKAGE_NAME).scrollable(true));

Did you add androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' in projectRoot-app module-build.gralde?
And write your test code under app module-androidTest?

Upvotes: 1

Related Questions