Open shagupta92042 opened 2 years ago
(code ) - WebElement shadowRootForTraderAcc = (WebElement) ((JavascriptExecutor) driver).executeScript("return arguments[0].shadowRoot", shadowDomHostForTraderAcc);
(Error) - java.lang.ClassCastException: org.openqa.selenium.remote.ShadowRoot cannot be cast to org.openqa.selenium.WebElement
The error is expected. The returned object cannot be cast to WebElement, so the above statement should not work.
@mykola-mokhnach Yes therefore we are using below new code to access the shadow dom
WebElement shadowDomHostForTradeSettings = (wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//it-trade-tab//it-account-selector//ion-autocomplete")))); SearchContext shadowRootForTradeSettings = shadowDomHostForTradeSettings.getShadowRoot();
using above code we are getting below error
The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
It is hard to say anything without having the full server log
https://gist.github.com/shagupta92042/fa4ebd4409afd10cdcfe08ca613edab8
Please check the Appium server logs for the same.
https://github.com/appium/appium/pull/16538 should resolve the "no route" issue after it is published, although it will only be available in Appium2
Thanks @mykola-mokhnach , Could you please suggest by when latest release will be available for use with this fix ?
Any following Appium2 version since beta.25
@mykola-mokhnach I tested this with Appium v2.0.0-beta.27 but still getting no route error for shadow dom elements . No route found for /wd/hub/session/ec9f6a47-d6aa-4f46-836b-8ecfe0768c78/shadow/0.9815731080829553-3/element
Please check the logs at below location https://gist.github.com/shagupta92042/06e6d55698dbddb180cb1ced4b6fb185
[35m[HTTP][39m [37m-->[39m [37mGET[39m [37m/wd/hub/session/ec9f6a47-d6aa-4f46-836b-8ecfe0768c78/element/0.9815731080829553-2/shadow[39m [35m[HTTP][39m [90m{}[39m [35m[AndroidUiautomator2Driver@c2a4 (ec9f6a47)][39m Driver proxy active, passing request on via HTTP proxy [debug] [35m[WD Proxy][39m Matched '/wd/hub/session/ec9f6a47-d6aa-4f46-836b-8ecfe0768c78/element/0.9815731080829553-2/shadow' to command name 'elementShadowRoot' [debug] [35m[WD Proxy][39m Proxying [GET /wd/hub/session/ec9f6a47-d6aa-4f46-836b-8ecfe0768c78/element/0.9815731080829553-2/shadow] to [GET http://127.0.0.1:8000/session/015b0d67d8100da7cf09fbf161dcbfa2/element/0.9815731080829553-2/shadow] with no body [debug] [35m[WD Proxy][39m Got response with status 200: {"sessionId":"015b0d67d8100da7cf09fbf161dcbfa2","status":0,"value":{"shadow-6066-11e4-a52e-4f735466cecf":"0.9815731080829553-3"}} [35m[WD Proxy][39m Replacing sessionId 015b0d67d8100da7cf09fbf161dcbfa2 with ec9f6a47-d6aa-4f46-836b-8ecfe0768c78 [35m[HTTP][39m [37m<-- GET /wd/hub/session/ec9f6a47-d6aa-4f46-836b-8ecfe0768c78/element/0.9815731080829553-2/shadow [39m[32m200[39m [90m31 ms - 122[39m [35m[HTTP][39m [90m[39m
Not sure where an error is visible. This particular request has passed as expected
@mykola-mokhnach Please check at 1013 line
[35m[HTTP][39m [37m-->[39m [37mPOST[39m [37m/wd/hub/session/ec9f6a47-d6aa-4f46-836b-8ecfe0768c78/shadow/0.9815731080829553-3/element[39m [35m[HTTP][39m [90m{"shadowId":"0.9815731080829553-3","using":"css selector","value":".selectize-input.items.full.has-options.has-items"}[39m [debug] [35m[HTTP][39m No route found for /wd/hub/session/ec9f6a47-d6aa-4f46-836b-8ecfe0768c78/shadow/0.9815731080829553-3/element [35m[HTTP][39m [37m<-- POST /wd/hub/session/ec9f6a47-d6aa-4f46-836b-8ecfe0768c78/shadow/0.9815731080829553-3/element [39m[33m404[39m [90m18 ms - 262[39m [35m[HTTP][39m [90m[39m
These are different routes. They should be added separately
@mykola-mokhnach So how can this be resolved ? Does it requires a fix from your end ?
@mykola-mokhnach So how can this be resolved ? Does it requires a fix from your end ?
I've added a PR. New routes will be available in the next server release
@mykola-mokhnach Do we have any update this? I am also facing the same error using Appium with dotnet client.
The problem
We are trying to test a hybrid app and we are using webview to test the same . We recently upgraded the appium client from 7.1.0 to 8.0.0 and selenium to 4.1.2 version. While acccessing the shadow dom element the code is failing on Mobile where as the same code is working fine on Desktop Web automation . In selenium 4 , to access the shadow dom a new method was introduced which is getShadowRoot() . When we try to access the shadow element using getShadowRoot() method then we get below error
org.openqa.selenium.UnsupportedCommandException: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource Build info: version: '4.1.2', revision: '9a5a329c5a' System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_322' Driver info: io.appium.java_client.android.AndroidDriver Command: [1c227afb-151c-4642-a3aa-256dbf33c2c6, getElementShadowRoot {id=0.9766494918888731-11}] Capabilities {appium:app: D:\release.apk, appium:appActivity: com.iongroup.ionweb.activit..., appium:appPackage: com.iongroup.ionweb.agt, appium:autoGrantPermissions: true, appium:automationName: uiautomator2, appium:chromeOptions: {w3c: false}, appium:chromedriverExecutable: C:\Users\shashank.gupta\nod..., appium:databaseEnabled: false, appium:desired: {app: D:\release.apk, appActivity: com.iongroup.ionweb.activit..., appPackage: com.iongroup.ionweb.agt, autoGrantPermissions: true, automationName: uiautomator2, chromeOptions: {w3c: false}, chromedriverExecutable: C:\Users\shashank.gupta\nod..., deviceName: CVH7N16B14000292, newCommandTimeout: 60, platformName: android, platformVersion: 8.1.0}, appium:deviceApiLevel: 27, appium:deviceManufacturer: Huawei, appium:deviceModel: Nexus 6P, appium:deviceName: CVH7N16B14000292, appium:deviceScreenDensity: 560, appium:deviceScreenSize: 1440x2560, appium:deviceUDID: CVH7N16B14000292, appium:javascriptEnabled: true, appium:locationContextEnabled: false, appium:networkConnectionEnabled: true, appium:newCommandTimeout: 60, appium:pixelRatio: 3.5, appium:platformVersion: 8.1.0, appium:statBarHeight: 84, appium:takesScreenshot: true, appium:viewportRect: {height: 2308, left: 0, top: 84, width: 1440}, appium:warnings: {}, appium:webStorageEnabled: false, platformName: android}
When we use the belowold code which used to work with Android System webview version 95 then we get the below error
(code ) - WebElement shadowRootForTraderAcc = (WebElement) ((JavascriptExecutor) driver).executeScript("return arguments[0].shadowRoot", shadowDomHostForTraderAcc);
(Error) - java.lang.ClassCastException: org.openqa.selenium.remote.ShadowRoot cannot be cast to org.openqa.selenium.WebElement
Environment
Code To Reproduce Issue [ Good To Have ]
WebElement shadowDomHostForTradeSettings = (wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//it-trade-tab//it-account-selector//ion-autocomplete")))); SearchContext shadowRootForTradeSettings = shadowDomHostForTradeSettings.getShadowRoot();