use a proxy to get status code for selenum drivers
I believe that we should use proxy to get status code in selenium driver. Something like browsermob: https://github.com/AutomatedTester/browsermob-proxy-py
I like the idea, the only downside that I can think of from using browsermob is that it would require more dependencies on the system.
Is there a pure python proxy that could be used?
You could always enable performance logs and parse the log to get the status code
in the capabilities dict
capabilities['loggingPrefs'] = {'performance': 'ALL'}
chrome options
chrome_options.add_experimental_option('perfLoggingPrefs', {"enablePage": True})
def parse_chromedriver_status_code(performance_log)
status_code = None
for log in performance_log:
try:
method = loads(log['message'])['message']['method']
# it'll always be the 1st
if method == 'Network.responseReceived':
status_code = int(loads(log['message'])['message']['params']['response']['status'])
# response_url = loads(log['message'])['message']['params']['response']['url']
break
except KeyError:
pass
return status_code