4

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

Link to html: https://i.stack.imgur.com/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.

Dmytro Dadyka
  • 2,208
  • 5
  • 18
  • 31
user11674781
  • 41
  • 1
  • 2

0 Answers0