I want to convert a set of desired capabilities to options in selenium Python.
In the below code i want to find the equivalent of dc["goog:loggingPrefs"] = {"browser":"INFO"}
for options in selenium python.
I've looked at: https://peter.sh/experiments/chromium-command-line-switches/ To see if there is an equivalent loggingPrefs switch for options but there doesn't seem to be one. The below code works for Selenium 4.7.2, but the problem is if we update to Selenium 4.10(latest) desired_capabilities is no longer supported when passing as a keyword argument to the webdriver. As far as i can see, most of the basic desired capabilities are supported by options such as brower version, name. How can we convert loggingPrefs desired capability to options for selenium webdriver.
def printConsoleLogs():
options = Options()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
#includes INFO level console messages, otherwise only SEVERE show
dc = DesiredCapabilities.CHROME.copy()
dc["goog:loggingPrefs"] = {"browser":"INFO"}
driver = webdriver.Chrome(service=service, options=options, desired_capabilities=dc)
driver.get("http://www.thepools.com")
time.sleep(5)
for entry in driver.get_log('browser'):
print(entry)
EDIT, FOUND THE SOLUTION, LEFT FOR PEOPLE LOOKING FOR THE SAME ANSWER IN THE FUTURE:
use options.set_capability("goog:loggingPrefs", {browser: "INFO"})
.set_capability(name, value)
, allows you to convert your desired_capabilities to selenium options