0

I'm new to protractor and I found that there is not much documentation on post method for sending JSON data to backend.

What is the proper way to send the json data to backend.

I tried using the way:

http://www.google.com/url?q=http%3A%2F%2Fstackoverflow.com%2Fa%2F21804302%2F265261&sa=D&sntz=1&usg=AFQjCNH4Nnq1Htz8P79EZsIC0KSYmvlfUA 

But could not succeed as I could not execute the block inside browser.executeAsyncScript

Please post some examples or documentation where I can do this

Thanks in advance

Pardeep Dhingra
  • 3,916
  • 7
  • 30
  • 56
spidy
  • 269
  • 2
  • 13
  • you should write code instead of asking for documentation. – Parth Trivedi Jan 29 '16 at 09:15
  • check this question: http://stackoverflow.com/questions/6968448/where-is-body-in-a-nodejs-http-get-response – Sergey Teplyakov Jan 29 '16 at 11:41
  • @SergeyTeplyakov...thanks for the reply..but there is nothing mentioned about testing .....Im new to protractor...where should I insert variable options or post in protractor as described in above link........ – spidy Jan 29 '16 at 11:56

1 Answers1

0

Here's an example:

browser.controlFlow().execute(function() {
    return new Promise(function(fulfill, reject) {
        var requestBuilder = require('superagent');
        var requestUrl = 'http://www.google.com/url?q=http%3A%2F%2Fstackoverflow.com%2Fa%2F21804302%2F265261&sa=D&sntz=1&usg=AFQjCNH4Nnq1Htz8P79EZsIC0KSYmvlfUA';

        requestBuilder
            .get(requestUrl)
            .end(function(err, result) {
                if (err) {
                    reject(err);
                } else {
                    fulfill(result);
                }
            });
    });
});
martin770
  • 1,271
  • 11
  • 15