'getAttribute("value") works in simulator but it returns null in a device

I'm using Appium over Android in a hybrid app made with stenciljs and ionic.

I'm using Appium server GUI and these are my capabilities:

            caps.setCapability("platformName", "Android");
            caps.setCapability("platformVersion", "11");
            caps.setCapability("deviceName", "emulator-5558");
            caps.setCapability("automationName", "UiAutomator2");
            caps.setCapability("udid", "emulator-5558");
            caps.setCapability("app",androidAppPath);
            driver = new AndroidDriver(appiumUrl, caps);

One of my test check if the text in a particular input field is equal to an expected text

To access to the input text I use:

WebElement input = webElement.findElement(inputBy);

input.getAttribute("value")

I double checked the input field is the right webelement.

My problem is that I am able to get the text from the input field if I run the test in an Android simulator, so the test will pass.

But If I run the test in an Android device, input.getAttribute("value") will always return null.

My understanding is that ChromeDriver is embedded in Appium, so if I run the test in the simulator or in the device, there should no be any difference in the capabilities.

Also my app has the setWebContentsDebuggingEnabled property on the android.webkit.WebView set to true

Am I missing something here?



Solution 1:[1]

It seems the problem is related with "w3c"

So I had to deactivate this capability with:

            caps.setCapability("appium:chromeOptions", ImmutableMap.of("w3c", false));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 xarly