We are using selenium web driver and python for our test automation and trying to automate html5 app with shadow dom design. Unable to identify any elements that come under shadow-root. For eg. If I want to access any element under the shadow root given below then how can I do that? Any help is appreciated.
相关问题
- Views base64 encoded blob in HTML with PHP
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
You can inject this piece of javascript that does this and then run the find_element methods on that element:
since you use often that you may create a function, , then the above becomes:
on the resulting element you can put any of the methods:
later edit:
many times the root elements are nested and the second nested element is no longer available in document, but is available in the current accessed shadow root. I think is better to use the selenium selectors and inject the script just to take the shadow root:
To put this into perspective I just added a testable example with Chrome's download page, clicking the search button needs open 3 nested shadow root elements: