Reputation: 131
Console error png We have been trying to print the console errors for the particular site by using the following code. But we are unable to catch console errors. Can anyone give quick response But we are getting
Line of Code :
driver.get_log('browser')
Error :
[{u'source': u'deprecation', u'message': u"https://xxxxx/static/vendor/vendor.bundle.js?v=16 902 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.", u'timestamp': 1515593047810, u'level': u'WARNING'}]
Line of Code :
driver.get_log('driver')
Error :
[{u'timestamp': 1515593061561, u'message': u'Unable to evaluate script: disconnected: not connected to DevTools\n', u'level': u'WARNING'}, {u'timestamp': 1515593071847, u'message': u'Unable to evaluate script: disconnected: not connected to DevTools\n', u'level': u'WARNING'}]
Code Block :
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
capabilities = DesiredCapabilities.CHROME
capabilities['loggingPrefs'] = { 'browser':'ALL' }
driver = webdriver.Chrome(desired_capabilities=capabilities)
driver.get('url')
elem = driver.find_element_by_id('username')
elem.send_keys('xxxx')
elem1 = driver.find_element_by_name('password')
elem1.send_keys('xxxx')
elem2 = driver.find_element_by_class_name('btn-info')
elem2.click()
driver.get('url')
for entry in driver.get_log('browser'):
print entry
Upvotes: 5
Views: 16088
Reputation: 1723
this Error:
looks like a JS error being printed:
[{u'source': u'deprecation', u'message':
u"https://xxxxx/static/vendor/vendor.bundle.js?v=16 902 Synchronous
XMLHttpRequest on the main thread is deprecated because of its detrimental
effects to the end user's experience. For more help, check
https://xhr.spec.whatwg.org/.", u'timestamp': 1515593047810, u'level':
u'WARNING'}]
I believe what that is outputing is what you are looking for.
Example from console on https://stackoverflow.com/
:
and this is my output from for log in driver.get_log('browser'): print(log)
:
{'level': 'SEVERE', 'message': 'https://secure.quantserve.com/quant.js -
Failed to load resource: net::ERR_CONNECTION_RESET', 'source': 'network',
'timestamp': 1515630280361}
{'level': 'SEVERE', 'message': 'https://js-sec.indexww.com/ht/p/185901-
159836282584097.js - Failed to load resource: net::ERR_TIMED_OUT', 'source':
'network', 'timestamp': 1515630288646}
{'level': 'SEVERE', 'message':
'https://www.googletagservices.com/tag/js/gpt.js - Failed to load resource:
net::ERR_TIMED_OUT', 'source': 'network', 'timestamp': 1515630288785}
Upvotes: 7