0

In my selenium+python automation, I have to install an extension before I actually start website automation. But, In my corporate network, I can upload the extensions to Chrome browser only when I unpacked the .crx file. This is my company policy. When I run the automation script, every time a fresh browser instance launches and 'Developer Mode' in extensions screen is disabled. I need to enable the developer mode from code. I have tried with below arguments in Chrome options but none of them worked.

options = webdriver.ChromeOptions() 
options.add_argument("--force-dev-mode-highlighting") 
options.add_argument("--system-developer-mode")

Any help to make it work will be highly appreciated.

  • [Running Selenium WebDriver using Python with extensions (.crx files)](https://stackoverflow.com/a/24182729) ? – wOxxOm Oct 13 '21 at 05:09
  • This does not work as I am in corporate network, and installing .crx is disabled. The only way I can add extension is uploading unpacked .crx file. But, as I mentioned in the question, 'Developer Mode' is disabled and 'Upload Unpacked' option is not available. So I need Developer Mode enabled before actually the browser launched. – Shiva Krishna Chippa Oct 13 '21 at 06:18
  • Change the prefs to `{"extensions.ui.developer_mode": true}`, [example](https://stackoverflow.com/a/64960630). – wOxxOm Oct 13 '21 at 07:52
  • @wOxxOm Thank you. It is not working. Is there any other way? – Shiva Krishna Chippa Oct 13 '21 at 17:00
  • Use `--load-extension=` + path-to-unpacked-directory in add_argument. – wOxxOm Oct 13 '21 at 17:02
  • I am already using it. Since there is no 'Developer Mode' toggle enabled, it is not working. – Shiva Krishna Chippa Oct 13 '21 at 17:04
  • If the toggle can't be enabled it can only happen if it's disabled by policy, you can see it by opening `chrome://policy`, in which case there's no way to enable dev mode. – wOxxOm Oct 13 '21 at 17:06

1 Answers1

0

From last comment from @wOxxOm, that worked for me: Change the prefs to {"extensions.ui.developer_mode": true}, example.

chrome_options.add_experimental_option('prefs',{"extensions.ui.developer_mode": True,})

Thank you @wOxxOm

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77