Search code examples
angularjstestingjasmineprotractorend-to-end

Check POST request payload data with Protractor


Let's say i have angular page with a couple of input elements and save button. After Save button is clicked POST request will be sent. I'm writing Protractor e2e test for this page.

The question:

How can i check with protractor POST request payload data after app is sent it or before sending? I want to be sure that my app will sent right data in POST request.


Solution

  • Following @Andres D's comment: yes, there is a misconception here.

    protractor is a tool that helps you mimic real-user interactions with a page by automating a real browser. It stays on the high-level, sees what a normal user can see - click buttons, fills out inputs etc.

    In other words, it is a black box testing, it doesn't matter where is data coming from, which protocol used to transfer it or how many external js files your page requires to be loaded - these are all technical details that should checked and tested separately.


    FYI, there is a relevant tool called protractor-http-mock that can help you in testing corner cases allowing to replace the server responses with custom defined.