java-client icon indicating copy to clipboard operation
java-client copied to clipboard

Unable to resolve findElementByAndroidUIAutomator with java client :5.0.0-BETA9 version

Open skmvali opened this issue 9 years ago • 11 comments

The problem

Unable to resolve the method findElementByAndroidUIAutomator with andriod driver object. Instead working fine with "MobileBy.AndroidUIAutomator("")". is "findElementByAndroidUIAutomator " deprecated with latest version?

Environment

Appium Java Client version : 5.0.0-BETA9 Code To Reproduce Issue

Working Code

DesiredCapabilities cap=new DesiredCapabilities(); cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, ""); AppiumDriver driver=new AndroidDriver(new URL(""), cap);

driver.findElement(MobileBy.AndroidUIAutomator("")).click();

Unresolved code

driver.findElementByAndroidUIAutomator(").click()

skmvali avatar Jul 11 '17 08:07 skmvali

@skmvali

Sorry for the delaying. I am busy. What do you expect? Yes. AppiumDriver has NO findElementByAndroidUIAutomator. It is not implemented by the AppiumDriver class but it is implemented by the AndroidDriver. So the there are two correct ways:

driver.findElement(MobileBy.AndroidUIAutomator("")).click();

as you has described

AndroidDriver driver=new AndroidDriver(new URL(""), cap);

TikhomirovSergey avatar Jul 20 '17 10:07 TikhomirovSergey

Thanks for the reply @TikhomirovSergey

skmvali avatar Jul 20 '17 11:07 skmvali

I think it is reopened by mistake. Feel free to reopen if you still hit any issues.

SrinivasanTarget avatar Jul 23 '17 05:07 SrinivasanTarget

Hi Guys According to my understanding of polymophisim and inheritence principles

AppiumDriver driver = new AndroidDriver(capabilities,"")

driver.findElementByAndroidUIAutomator("") should call the AndroidDriver method andnot the AppiumDriver one but this is not the case

WalterSihlali avatar Nov 21 '18 09:11 WalterSihlali

I am facing the same issue. Below is my code

File f = new File("src/test/java"); File fs = new File(f,"ApiDemos-debug.apk");

DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus 6 API 28"); cap.setCapability(MobileCapabilityType.APP, fs.getAbsolutePath()); URL url = new URL("http://127.0.0.1:4723/wd/hub"); AndroidDriver driver = new AndroidDriver(url,cap); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // driver.findElementByAndroidUIAutomator ==>findElementByAndroidUIAutomator cannot be resolved or is not a field

selenium-java - 3.141.59 java-client - 7.3.0 Screenshot 2020-04-21 at 6 56 58 PM

I am also facing the same issue, any resolution for this?

madhusmitanishu avatar May 07 '20 01:05 madhusmitanishu

@madhusmitanishu No resolution. You have to type the entire method name. Then it does not throw the error

Because findElementByAndroidUIAutomator is a default method which is supported by Java 8 onward. You are using Java 1.5 in project. Change it to 1.8 +.

amodmahajan2016 avatar Jun 14 '20 03:06 amodmahajan2016

@amodmahajan2016 thankyou , i changed JAVA SE 1.7 TO JAVA SE 1.8 .Now driver.findElementsByAndroidUIAutomator showing Screenshot (187)

mani19297 avatar Nov 29 '20 23:11 mani19297

image

am also facing issues here. Kindly help me on this

joyjagan11 avatar May 17 '22 07:05 joyjagan11

@joyjagan11

MobileBy is deprecated but you can use this:

driver.findElement(new AppiumBy.ByAndroidUIAutomator("text(\"Views\")")).click();

sweeneyapps avatar Jun 14 '22 17:06 sweeneyapps