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
setting request headers #740
Comments
Protractor (and webdriver, which it is built on top of) are intended to test your application like a user interacting with your page, so the meaning of |
Thanks for your quick reply. I suspected this reason, but it would have been useful for me to bypass our login system (a non angular page provided by a reverse proxy) by setting headers. I will find another way... |
Well this may answer my question in another thread. I would like to suggest that in some cases it might be very useful to be able to either set request headers or somehow persist cookies across tests. We have a lot of annoying things like Take a Tour, surveys, etc. that pop up for a completely anonymous user. We can direct our tests to close these things. But when you factor in load time of the feature, this adds several seconds to every test, which adds up when you have 1000s of tests eventually. |
Custom headers would be more than nice. 👍 |
+1 using headers to enable things in non-prod env is very common. Please add this feature. |
+1 In my case the browsers in prod env have to go through proxy and authentication servers, which set a number of HTTP headers. Currently our solution is to proxy all requests from protractor through connect. |
+1; We use SSO / Kerberos and I would like to imitate another user than me. Hence I need to set the Authorization header. |
+1 on adding headers |
+1 for modifying headers |
+1 on adding headers. In my case, I want to be able to control different responses from the same user action coming back from a mocked API. |
+1 We don't want to log allways... we have a test case testing it. We need to bypass them. We want setting headers! |
+1 |
We'd need webdriver to implement this feature, which they've already rejected doing. You could try contacting them on their github but I don't think it will get you anywhere. |
The selenium issue you linked does not seem to be the same thing we are asking for. People in that thread are asking to be able to test response headers going to protractor. We are asking to be able to set request headers coming from protractor to the server at the start of the test. This functionality is to do things like simulate a logged in or "cookied" user w/o having to take the extra step of explicitly logging in every time. Also in our case it could be used to bypass an annoying resource-consuming overlay which sets a cookie when the user closes it - telling it to not to show up the next time the page is loaded. As a workaround we have created dummy pages to set these cookies. But it slows the tests down when protractor first has to hit these dummy pages before every test. We also use a WURFL-based tool called Scientia which sets a header to indicate the make, model, browser and OS of the various devices we support. It would be nice to be able to spoof this to test different device-specific behaviors. |
Sorry, sounds like I linked to the wrong issue. This has been raised with WebDriver though and they have rejected it. @juliemr is probably more able to find the exact issue, but you could just make a new issue on their github |
+1 for having the possibility to set request headers @jackspaniel for setting a cookie you can use the |
+1 for setting/modifying request headers. BTW, why this issue has been closed ? |
It was closed because we'd need webdriver to implement this feature, which they've already rejected doing. You could try contacting them on their github but I don't think it will get you anywhere. |
To add, though it does not seem possible to arbitrarily set request headers, if you just want to set cookies, that is at least possible with |
It's been a while but if I recall correctly that doesn't actually send a cookie to the server with the request - it just registers in the browser that it received a cookie. |
If you support having the ability to set request headers on tests, please go to this ticket and add +1 to the request. I just created it as it inherently has and is affecting the way i have to create tests. |
+1 for modheaders - we use modheaders to access our app during a release... so this would make that easy. |
+1 |
1 similar comment
+1 |
workaround, just put the "headers" in the url
|
our app uses two-factor authentication and sends you an sms. It would be hard (impossible?) to login as user would normally login. |
Just use Twilio number (they have even free one). Using Twilio API get an sms with the code. That's not difficult. https://www.twilio.com/docs/usage/api |
Hey,
I'm having difficulties setting headers in my requests (browser.get('/path');)
Is there a way to do so ?
Thanks !
The text was updated successfully, but these errors were encountered: