1

I am using python and selenium automation to toggle a switch on chrome://extensions/ . On the top of the website, there is an toggle for developer mode, and I am trying to use

driver.find_element_by_id("knob").click()

however, this doesnt find the element named ID. Does anyone know how I might select the element to toggle Developer mode?

Marco Bonelli
  • 55,971
  • 20
  • 106
  • 115
Luke Vanzweden
  • 341
  • 2
  • 12

1 Answers1

2

That element is inside ShadowDOM so you need to explicitly access it,
see Accessing Shadow DOM tree with Selenium.

A simpler solution seems to be to call the internal API directly:

driver.execute_script('''
  document.querySelector("extensions-manager")
    .delegate.setProfileInDevMode(true)
''')
wOxxOm
  • 53,493
  • 8
  • 111
  • 119