Im trying to open firefox console through Selenium with Python. How can I open firefox console with python selenium? Is it possible to send keys to the driver or something like that?
I know this is relatively old but I ran into this issue recently. I got firefox to automatically open devtools by passing in a browser process argument "-devtools".
Selenium: 3.14 geckodriver: 0.21.0 firefox: 61.0.1
from __future__ import print_function
from datetime import datetime
import logging
import os
from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions
def before_scenario(context, scenario):
logging.info("RUNNING: " + scenario.name)
print("Browser Test starting.\n")
options = FirefoxOptions()
options.log.level = "trace"
options.add_argument("-devtools")
if 'headless' in os.environ and os.environ['headless'] == '1':
options.headless = True
context.driver = webdriver.Firefox(firefox_options=options)
context.driver.maximize_window()
Try to simulate the same procedure as a "regular" firefox window using the send_keys
function:
from selenium.webdriver.common.keys import Keys
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.SHIFT + 'k')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With