Reputation: 2812
I know how to get logs from the browser in Selenium as shown below, but the problem with this is that some of the logs I can see in the browser's console, are never captured by Selenium. These missing logs are from extensions and service workers.
Is there any way to capture the logs from extensions and service workers? I am not able to modify the extensions or service workers to use an alternate logging mechanism, but any other workarounds would be most welcome!
# Initialise the driver, enabling browser logging
options = webdriver.ChromeOptions()
...
capabilities = options.to_capabilities()
capabilities['goog:loggingPrefs'] = { 'browser': 'ALL' }
driver = webdriver.Chrome(desired_capabilities=capabilities)
driver.get('http://127.0.0.1')
# Continually log everything
while True:
for entry in driver.get_log('browser'):
print(entry)
Upvotes: 5
Views: 657
Reputation: 47
This library allows you to get logs of the browser: https://github.com/MarketSquare/robotframework-seleniumtestability I have used it in the past to retrieve browser logs but I'm not sure about extenstions, you could give it a try.
Upvotes: 1