Capturing console logs of a Chrome extension in Selenium

I have a Chrome extension that calls console.log () in multiple places for debugging purposes. This output is displayed in the Chrome web console. When I run selenium using ChromeDriver and load the extension, I can still see the output in the web console, but cannot figure out how to view the extension logs from the selenium script.

Attempting driver.get_log('<target>')

any given target here returns logs from different parts of the selenium-driver browser stack, but shows nothing from the extension. I also set all log sources to 'ALL'

in loggingPrefs

as stated here .

I've also tried using this extension to collect console output into the DOM and then trying to read the DOM from the selenium script, but it looks like this extension doesn't (or can't?) Collect logs from other running extensions.

Any help would be greatly appreciated!

+3


source to share


1 answer


I ended up solving this by changing the extension I was testing to enter the DOM directly. This way I can read the output of the extension by reading the HTML from the page in selenium. It's not pretty, but it works.



0


source







All Articles