Unable to find element by using ClassName selector

Dear folks,

I’m using Appium for doing Hybrid test on Android Device.
As somebody told me that UIAutomator 4.4. will interpret webview (and the H5 elements in webview) to view.

And, I did saw the button element in UIAutomator.bat tool, but whenever I ran my automation code, if I’m lucky I can find the element by using AppiumDriver.FindElementByClassName(“android.widget.Button”).
Unlucky, most of the days, it find nothing.

Does anybody know why I’m unable to find the element in the WebView?

        DesiredCapabilities cap = new DesiredCapabilities();
        cap.SetCapability(CapabilityType.BrowserName, "");
        cap.SetCapability("appium-version", "1.2");
        cap.SetCapability("platformName", "Android");
        cap.SetCapability("platformVersion", "4.4");
        cap.SetCapability("appPackage", "XXX");
        cap.SetCapability("appActivity", "XXX");
        cap.SetCapability("deviceName", "Lenovo S930");

info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“class n
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”
:“find”,“params”:{“strategy”:“class name”,“selector”:“android.widget.Button”,“co
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.Button using CLASS_NAME
with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.Button,
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“No element found”,

Best Regards,
Lucas Luo

Well, try upgrading to Appium 1.3.0 if you can.

If that doesn’t help, you could post an issue to the github repository.

It’s a rather curious issue, is the button visible on the screen when this happens?

Hi jonahss,

It looks we are unable to install appium 1.3 from npm install, right?
It is not released?

Best Regards,
Lucas Luo

Finally, I used Nexus, then the element could be found by UIAutomator.
But, that’s why? Why the behavior is different from device to device?

Behavior is different from device to device because the devices are different!

I’ve talked to a group that has over 100 different android phones in their test system, and the stories they tell of things randomly not working in this or that manufacturer are horrifying indeed.

Thank you jonahss!

Best Regards,
Lucas Luo