[Appium 1.15] Can't locate elements in webview with id

Just updated to appium v1.15, and the locators that use ids in the webpage of our app throw 'Invalid argument: invalid locator" exceptions.

eg. findElement(By.id(id)) - throws invalid argument: invalid locator exception
findElement(By.xpath("//*[@id=id]")) - works just fine

Appium version : 1.15
Java libaries: using latest commit branch 53814cd5ac77cf26e73c89eee49649af39f9c5a5

server log:

2019-10-02 14:12:43:427 [HTTP] --> POST /wd/hub/session/2bed0e98-e5c9-40b6-8fed-037803ab9fcf/element
2019-10-02 14:12:43:427 [HTTP] {ā€œusingā€:ā€œidā€,ā€œvalueā€:ā€œContainer_Config_EdsUrlā€}
2019-10-02 14:12:43:428 [W3C (2bed0e98)] Driver proxy active, passing request on via HTTP proxy
2019-10-02 14:12:43:428 [WD Proxy] Matched ā€˜/wd/hub/session/2bed0e98-e5c9-40b6-8fed-037803ab9fcf/elementā€™ to command name ā€˜findElementā€™
2019-10-02 14:12:43:428 [WD Proxy] Proxying [POST /wd/hub/session/2bed0e98-e5c9-40b6-8fed-037803ab9fcf/element] to [POST http://127.0.0.1:9510/wd/hub/session/0e390a867d50b603985c4ce33a79b038/element] with body: {ā€œusingā€:ā€œidā€,ā€œvalueā€:ā€œContainer_Config_EdsUrlā€}
2019-10-02 14:12:43:444 [WD Proxy] Got an unexpected response with status 400: {ā€œvalueā€:{ā€œerrorā€:ā€œinvalid argumentā€,ā€œmessageā€:ā€œinvalid argument: invalid locator\n (Session info: chrome=76.0.3809.132)ā€,ā€œstacktraceā€:"0 chromedriver 0x0000000107a1cf69 chromedriver + 3649385\n1 chromedriver 0x00000001079acf73 chromedriver + 3190643\n2 chromedriver 0x000000010774db1f chromedriver + 703263\n3 chromedriver 0x00000001076c2d14 chromedriver + 134420\n4 chromedriver 0x00000001076eb287 chromedriver + 299655\n5 chromedriver 0x00000001076df7cd chromedriver + 251853\n6 chromedriver 0x00000001076e9837 chromedriver + 292919\n7 chromedriver 0x00000001076df9f3 chromedriver + 252403\n8 chromedriver 0x00000001076bb5e2 chromedriver + 103906\n9 chromedriver 0x00000001076bc6a5 chromedriver + 108197\n10 chromedriver 0x00000001079daa5f chrā€¦
2019-10-02 14:12:43:444 [W3C (2bed0e98)] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: 400 - {ā€œvalueā€:{ā€œerrorā€:ā€œinvalid argumentā€,ā€œmessageā€:ā€œinvalid argument: invalid locator\n (Session info: chrome=76.0.3809.132)ā€,ā€œstacktraceā€:ā€œ0 chromedriver 0x0000000107a1cf69 chromedriver + 3649385\n1 chromedriver 0x00000001079acf73 chromedriver + 3190643\n2 chromedriver 0x000000010774db1f chromedriver + 703263\n3 chromedriver 0x00000001076c2d14 chromedriver + 134420\n4 chromedriver 0x00000001076eb287 chromedriver + 299655\n5 chromedriver 0x00000001076df7cd chromedriver + 251853\n6 chromedriver 0x00000001076e9837 chromedriver + 292919\n7 chromedriver 0x00000001076df9f3 chromedriver + 252403\n8 chromedriver 0x00000001076bb5e2 chromedriver + 103906\n9 chromedriver 0x00000001076bc6a5 chromedriver + 108197\n10 chromedriver 0x00000001079daa5f chromedriver + 3377759\n11 chromedriver 0x00000001079e6780 chromedriver + 3426176\n12 chromedriver 0x00000001079e6518 chromedriver + 3425560\n13 chromedriver 0x00000001079baea9 chromedriver + 3247785\n14 chromedriver 0x00000001079e6ff8 chromedriver + 3428344\n15 chromedriver 0x00000001079ced47 chromedriver + 3329351\n16 chromedriver 0x0000000107a03e54 chromedriver + 3546708\n17 chromedriver 0x0000000107a22ca7 chromedriver + 3673255\n18 libsystem_pthread.dylib 0x00007fff71b092eb _pthread_body + 126\n19 libsystem_pthread.dylib 0x00007fff71b0c249 _pthread_start + 66\n20 libsystem_pthread.dylib 0x00007fff71b0840d thread_start + 13\nā€}}
2019-10-02 14:12:43:444 [W3C (2bed0e98)] at JWProxy.proxy (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:213:13)
2019-10-02 14:12:43:445 [W3C] Matched W3C error code ā€˜invalid argumentā€™ to InvalidArgumentError
2019-10-02 14:12:43:445 [HTTP] <-- POST /wd/hub/session/2bed0e98-e5c9-40b6-8fed-037803ab9fcf/element 400 18 ms - 1864
2019-10-02 14:12:43:445 [HTTP]

Hey @mykola-mokhnach ,

This is exactly what I was looking for.

Can you maybe help me Enforce chromedriver to JSONWP mode (set w3c chromedriver option to false )?

I was unable to find any code snippet on how to do this in java. Is it possible?

I only found ā€˜MobileCapabilityType.FORCE_MJSONWPā€™ which does not work.

I also tried:

ChromeOptions co = new ChromeOptions();
co.setCapability(ā€œw3cā€,false);
co.setCapability(ā€œandroidPackageā€,ā€œcom.android.chromeā€);
desiredCapabilities.setCapability(AndroidMobileCapabilityType.CHROME_OPTIONS, co);

But when using like this, the server will not even start, it will fail with:

/usr/local/lib/node_modules/appium/build/lib/main.js: error: argument ā€œ-dc/ā€“default-capabilitiesā€: Invalid parseDefaultCaps

Even without setting any capabs in ChromeOptions, the server fails to start as soon as I pass the ChromeOptions object to the desiredcapabilities

Any updates on this. I am using serenity framework and updated to appium 1.15.1 and now I cannot use find element by id only on android chrome webview. Everything else works fine. I do not seem to be able to turn off w3c mode and not sure if there is another work around.

Found a way to turn W3C off in C# for Android Chrome client by using AppiumOptions like below
DriverOptions driverOptions = new AppiumOptions();
driverOptions.AddAdditionalCapability(ChromeOptions.Capability, JObject.Parse("{ā€œw3cā€:false}"));

for java:
desiredCapabilities.setCapability(ā€œappium:chromeOptionsā€, ImmutableMap.of(ā€œw3cā€, false));

1 Like