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

How is the proxy setup? #98

Closed
sontek opened this issue Feb 14, 2017 · 3 comments
Closed

How is the proxy setup? #98

sontek opened this issue Feb 14, 2017 · 3 comments

Comments

@sontek
Copy link

sontek commented Feb 14, 2017

When I generate an HTML report I have a HAR Log which shows all the network traffic in the browser, that looks like:

{
            "startedDateTime": "2017-02-14T19:14:49.802Z",
            "time": 1234,
            "request": {
                "method": "POST",
                "url": "http://127.0.0.1:55271/v1/users/",
                "httpVersion": "HTTP/1.1",
                "cookies": [],
                "headers": [{
                    "name": "accept",
                    "value": "application/json"
                }, {
                    "name": "Referer",
                    "value": "http://127.0.0.1:55270/signup"
                }, {
                    "name": "Origin",
                    "value": "http://127.0.0.1:55270"
                }, {
                    "name": "User-Agent",
                    "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1"
                }, {
                    "name": "content-type",
                    "value": "application/json"
                }, {
                    "name": "Content-Length",
                    "value": "132"
                }],
                "queryString": [],
                "headersSize": -1,
                "bodySize": -1
            },
            "response": {
                "status": null,
                "statusText": "Error downloading http://127.0.0.1:55271/v1/users/ - server replied: Unknown Error",
                "httpVersion": "HTTP/1.1",
                "cookies": [],
                "headers": [{
                    "name": "Access-Control-Allow-Credentials",
                    "value": "true"
                }, {
                    "name": "Access-Control-Allow-Methods",
                    "value": "POST"
                }, {
                    "name": "Access-Control-Allow-Origin",
                    "value": "http://127.0.0.1:55270"
                }, {
                    "name": "Access-Control-Expose-Headers",
                    "value": "Request-ID"
                }, {
                    "name": "Access-Control-Max-Age",
                    "value": "86400.0"
                }, {
                    "name": "Content-Length",
                    "value": "6256"
                }, {
                    "name": "Content-Type",
                    "value": "application/json; charset=utf-8"
                }, {
                    "name": "Date",
                    "value": "Tue, 14 Feb 2017 19:14:49 GMT"
                }, {
                    "name": "Request-Id",
                    "value": "4d8013"
                }, {
                    "name": "Server",
                    "value": "waitress"
                }, {
                    "name": "Vary",
                    "value": "Origin"
                }],
                "redirectURL": "",
                "headersSize": -1,
                "bodySize": 6256,
                "content": {
                    "size": 6256,
                    "mimeType": "application/json; charset=utf-8"
                }
            },
            "cache": {},
            "timings": {
                "blocked": 0,
                "dns": -1,
                "connect": -1,
                "send": 0,
                "wait": 1234,
                "receive": 0,
                "ssl": -1
            },
            "pageref": "http://127.0.0.1:55270/signup"
        }]
    }
}

I can't find any information on how this proxy is setup, my hand rolled setup uses browsermob-proxy. What I'm trying to do is figure out a way to log out failed network requests to the console during test runs. So that example above would log out:

"Error downloading http://127.0.0.1:55271/v1/users/ - server replied: Unknown Error"
@davehunt
Copy link
Contributor

You can configure a proxy by passing capabilities to the driver instance. For Firefox using GeckoDriver you'll need to check the documentation on how to construct the proxy configuration. There are several ways to set capabilities using pytest-selenium, and these are documented here. I hope this helps, though configuring proxies is not a direct responsibility for pytest-selenium, so I may redirect further questions to the Selenium and GeckoDriver projects.

@sontek
Copy link
Author

sontek commented Feb 15, 2017

I thought a proxy was already setup. How is it generating the HAR log without one?

@davehunt
Copy link
Contributor

I thought a proxy was already setup. How is it generating the HAR log without one?

I do not know anything about your environment or infrastructure, but I can tell you that pytest-selenium will not use a proxy or generate a HAR file on its own.

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

No branches or pull requests

2 participants