Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use a proxy to get status code for selenum drivers #586

Open
andrewsmedina opened this issue Feb 11, 2018 · 2 comments
Open

use a proxy to get status code for selenum drivers #586

andrewsmedina opened this issue Feb 11, 2018 · 2 comments

Comments

@andrewsmedina
Copy link
Member

I believe that we should use proxy to get status code in selenium driver. Something like browsermob: https://github.com/AutomatedTester/browsermob-proxy-py

@bmcculley
Copy link
Contributor

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?

@craigmi
Copy link

craigmi commented Mar 20, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants