1

I have tried several methods to open the console in firefox via selenium (using python), but none of these is working, although I'm not getting any troubleshoots, except for the last one.

Selenium 3.141.0, Firefox 68.0, geckodriver-v0.24.0-win64

    import selenium
    from selenium import webdriver
    from selenium.webdriver import ActionChains
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

    caps = DesiredCapabilities.FIREFOX
    driver = webdriver.Firefox(capabilities = caps, executable_path="C:\\Users\\user_name\\API_Fire\\geckodriver.exe")

    action = ActionChains(driver) 

# First version I tried:

    action.send_keys(Keys.CONTROL + Keys.SHIFT + 'k').perform()

# Second version I tried:

    action.key_down(Keys.F12).key_up(Keys.F12).perform()

# Third version I tried:

    action.key_down(Keys.CONTROL + Keys.SHIFT).send_keys('k').key_up(Keys.CONTROL + Keys.SHIFT).perform()

# Troubleshoot for third version: 
   InvalidArgumentException: Message: data did not match any variant of untagged enum KeyActionItem at line 1 column 1159







supputuri
  • 13,644
  • 2
  • 21
  • 39
björn_313
  • 13
  • 3
  • @DebanjnB `options.add_argument("--auto-open-devtools-for-tabs")` does not work in OP case, as he is trying to open dev tools in Firefox. So OP has to use `devtools` options as shown in my answer below. – supputuri Jul 11 '19 at 13:07

1 Answers1

2

Add the devtools option as shown below.

Need below Import:

from selenium.webdriver.firefox.options import Options

Script

FF_options = Options()
FF_options.add_argument("-devtools")
driver = webdriver.Firefox(firefox_options=FF_options)

You can get the complete list of options in firefox command line options page.

supputuri
  • 13,644
  • 2
  • 21
  • 39