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







1
  • @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. Commented Jul 11, 2019 at 13:07

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.