question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error trying to access shadowRoot elements on iOS

See original GitHub issue

The problem

Can’t access elements under a shadowRoot on iOS real device. We have an automation suite that runs on our Chrome app, and our Mac and Windows Electron apps using Selenium Webdriver. I’m hoping to use much of the same code on our Hybrid iOS app via Appium. We use Polymer and thus have to access elements under shadowRoots. On other platforms, we are doing this via shadowElement = $driver.execute_script(‘return document.querySelector(“blah_blah”).shadowRoot’) el = shadowElement.find_element(:css => “#id_of_my_element”)

This is not working in Appium. I’m getting a “Recursive object cannot be transferred” error.

Environment

Appium 1.7.1 (using Appium desktop app 1.2.7) Mac OS 10.13 Xcode 9.1 iOS 11.1.2 on real iPad Air

Details

I believe I have the capabilities set up correctly, as I can switch to the web context and access the elements above the shadowRoot elements.
When running the sample code below I get the error: “[MJSONWP] Encountered internal error running command: Error: Error while executing atom: Recursive object cannot be transferred (status: 13)”

Link to Appium logs

https://gist.github.com/dyhopper1/0df126924abfd093ae02c80fc71a5fc4

Code To Reproduce Issue [ Good To Have ]

(Sample ruby code)

`capabilities = { “bundleId”=> “com.vernier.spectralanalysis”, “udid” => “1905da18d1c56349efb55ab04xxxxxxxxxxxxxxx”, “platformName” => “iOS”, “deviceName” => “iPad Air”, “platformVersion” => “11.1”, “xcodeOrgId” => “xxxxxxxxxx”, “xcodeSigningId” => “iPhone Developer”, “startIWDP” => true }

$driver = Appium::Driver.new({:caps => capabilities}, false).start_driver sleep 4 webview = $driver.available_contexts.last $driver.set_context(webview) #works

el = $driver.execute_script(‘return document.querySelector(“vst-sa-app”)’) p el # just to prove the element was retrieved successfully. no problem.

#the following line results in error shadowEl = $driver.execute_script(‘return document.querySelector(“vst-sa-app”).shadowRoot’)

`

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:26 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
imurchiecommented, Jul 11, 2018
0reactions
caseycantwellcommented, Feb 12, 2021

Any update on this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Need help to click on the element under the shadow Root ...
If your usecase is to interact with the <path> element which is within the <svg> tag, is indeed within a #shadow-root (closed) ....
Read more >
Element.shadowRoot - Web APIs - MDN Web Docs
The Element.shadowRoot read-only property represents the shadow root hosted by the element. Use Element.attachShadow() to add a shadow root ...
Read more >
How To Automate Shadow DOM In Selenium WebDriver
When we try to find the Shadow DOM elements using Selenium ... Note, it has 1 shadow root element before we reach text...
Read more >
Working With Web Components (Shadow DOM) - HeadSpin
But what if we want to make use of an element located in the ... Finally, we're simply returning the shadow root and...
Read more >
Working with Shadow DOM Elements using Webdriver
Now using this root WebElement, we will try to find the next root element and proceed until we reach the final Shadow Root...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found