4

I am doing automation to web application and need to click on button -Login inside shadow root.

Link to html: https://i.sstatic.net/6TcFu.jpg

Tried many different solutions - no success.

How to solve this? Thanks in advance

Did this code:

###def expand_shadow_element (element):###

  global driver

  shadowRoot= driver.execute_script('return arguments[0].shadowRoot', element)

return shadowRoot

### The script: ###

global driver

root = driver.find_element_by_tag_name("decoy-server-login")

shadowRoot = expand_shadow_element(root)
               shadowRoot.find_element_by_xpath("//[@id='loginForm']/p/button").click()

Get error:

Message: invalid selector: Unable to locate an element with the xpath expression //*[@id='loginForm']/p/button because of the following error: NotSupportedError: Failed to execute 'evaluate' on 'Document': The node provided is '#document-fragment', which is not a valid context node type.

1

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.