How to open console in firefox python selenium?

2024/10/15 13:15:21

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?

Answer

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_functionfrom datetime import datetimeimport loggingimport osfrom selenium import webdriverfrom selenium.webdriver.firefox.options import Options as FirefoxOptionsdef 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 = Truecontext.driver = webdriver.Firefox(firefox_options=options)context.driver.maximize_window()
https://en.xdnf.cn/q/69277.html

Related Q&A

Can python coverage module conditionally ignore lines in a unit test?

Using nosetests and the coverage module, I would like coverage reports for code to reflect the version being tested. Consider this code:import sys if sys.version_info < (3,3):print(older version of …

Delete Pandas DataFrame row where column value is 0

I already read the answers in this thread but it doesnt answer my exact problem. My DataFrame looks like thisLady in the Water The Night Listener Just My Luck Correlation Claudia Puig …

Pyarrow s3fs partition by timestamp

Is it possible to use a timestamp field in the pyarrow table to partition the s3fs file system by "YYYY/MM/DD/HH" while writing parquet file to s3?

flask run vs. python

Im having difficulty getting my flask app to run by using the "python" method. I have no problems usingexport FLASK_APP=microblog.py flask runbut attempting to usepython microblog.pywill resu…

Pandas-Add missing years in time series data with duplicate years

I have a dataset like this where data for some years are missing .County Year Pop 12 1999 1.1 12 2001 1.2 13 1999 1.0 13 2000 1.1I want something like County Year Pop 12 1999 1.1 12…

Saving zip list to csv in Python

How I can write below zip list to csv file in python?[{date: 2015/01/01 00:00, v: 96.5},{date: 2015/01/01 00:01, v: 97.0},{date: 2015/01/01 00:02, v: 93.75},{date: 2015/01/01 00:03, v: 96.0},{date: 20…

unable to download the pipeline provided by spark-nlp library

i am unable to use the predefined pipeline "recognize_entities_dl" provided by the spark-nlp library i tried installing different versions of pyspark and spark-nlp libraryimport sparknlp from…

Can __setattr__() can be defined in a class with __slots__?

Say I have a class which defines __slots__:class Foo(object):__slots__ = [x]def __init__(self, x=1):self.x = x# will the following work?def __setattr__(self, key, value):if key == x:object.__setattr__…

mysql-connector python IN operator stored as list

I am using mysql-connector with python and have a query like this:SELECT avg(downloadtime) FROM tb_npp where date(date) between %s and %s and host like %s",(s_date,e_date,"%" + dc + &quo…

Pandas: Use iterrows on Dataframe subset

What is the best way to do iterrows with a subset of a DataFrame?Lets take the following simple example:import pandas as pddf = pd.DataFrame({Product: list(AAAABBAA),Quantity: [5,2,5,10,1,5,2,3],Start…