22

I am using python language bindings of selenium. The application under test is a WEBRTC application, which does write debug information to console logs of the browser. Need to get these log information when running the tests. I am able to get the logs when the browser is run on the same system, but when I run the same code with Grid on a remote browser the logs aren't returned even though they appear in the browser. I also tried using the -browserConsoleLog option when configuring the node to the hub, but even that did not work.

chrome_opts=webdriver.ChromeOptions()
desired_caps = chrome_opts.to_capabilities()
desired_caps.update({'loggingPrefs':{ 'browser':'ALL'}})

By enabling the logging prefs as shown above, I am able to get the console-api and network logs from the browser when it is run locally as:

driver=webdriver.Chrome(desired_caps)
driver.get(app_url)
logs = driver.get_log("browser") 
# returns all the console-api, network and browser logs as I read from one of the posts
for log in logs:
   if log.get('source')=='console-api':
       print log.get('message')

But when I use the same desired capabilties with a remote browser as shown below, get_logs doesn't return console logs though it appears in the browser console
driver=webdriver.Remote(command_executor=hub_url,desired_capabilities=desired_caps)

Any help?

  • See if this helps - http://stackoverflow.com/questions/25431380/capturing-browser-logs-with-selenium – LittlePanda Apr 27 '15 at 06:24
  • 3
    As given in the answers I am able to get the JS console logs from a local browser but not getting it from a remote browser via selenium hub. A solution to get the console logs from a browser via hub will be very helpful. – Jayprakash Dhananjay May 28 '15 at 17:06
  • I'm running into the same problem but from within protractor (which is essentially the same as selenium webdriver). Somehow, whenever I try to grab the logs by using `browser.manage().logs().get('browser')` (which afaik is the equivalent to your `driver.get_log('browser')` I don't get any result if I run it against our remote Chrome on a selenium grid. Locally it works fine. – Stephan Muller Sep 29 '16 at 08:40
  • @StephanMuller try `browser.manage().logs().get( "browser" ).then(function( log ) { console.log( log ); });` – user1207289 Sep 30 '16 at 01:24

0 Answers0