protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Debug/network possibilities

Open Basman01 opened this issue 12 years ago • 3 comments

Hi all

I have a question : Is it possible with protractor to check/validate a network event like for example a "get"?

What i am trying to do is checkking if the correct token is given when the user logs in

Basman01 avatar Jan 16 '14 09:01 Basman01

Protractor tries to simulate real user behaviour when interacting with your application and checking the responses of HTTP requests directly is not something that a normal user would normally do. This is not supported out of the box. But if this token is somehow exposed outside of the internals of your application - ex. it gets set in a cookie or in the local storage - you can get it using executeScript (which executes some javascript code in the browser) for example.

Testing tokens, returned from the server seems like a functional test for your server - for this you should use other tools - soapUI for example.

manevpe avatar Jan 16 '14 09:01 manevpe

For using executeScript to do this, check out this blog post: http://eitanp461.blogspot.com/2014/01/advanced-protractor-features.html

But yes, the 'end to endey' way of doing this would be to check if the user sees something valid when they log in. Should they get an error if they don't get a correct token? Then check to make sure the error is not present, etc.

juliemr avatar Jan 16 '14 17:01 juliemr

They would not get the right authorization if the dont have the right token (which also is said by an error message).

What i am also trying to do is save that token for later use in an API call .I make that call so that i can see that the data(the user can save different froms in the program) is received by the database(I now realize manevpe was right about me getting too technical).

My solution is that i now use executeScript to read the cookie and then make the call via url. I am now only thinking about potential security risks but that is not something to be discussed here i think ;)

Thanks for the help , i appreciate it

Basman01 avatar Jan 17 '14 07:01 Basman01