I am trying to post to a url to get a username and password so I can log into my website to do functional testing. I start up selenium server and run this basic test with a request to a posting service.
define([
'intern!object',
'runtime/testConfig',
'intern/dojo/node!nconf',
'intern/dojo/node!http'
], function(registerSuite, conf, nconf, http) {
var tests = {
name: 'Login test',
'Test': function() {
return http.request({
host: 'posttestserver.com',
path: '/post.php',
json: true,
method: 'POST',
body: {
"userName": "sgfi98j",
"password": "sgfi98j",
"userEmail": "[email protected]",
"sourceCode": "TEST",
"region": "US"
},
headers: {
'Content-Type': 'application/json'
}
}, function(response) {
// Continuously update stream with data
var body = '';
console.log("getting data");
response.on('data', function(d) {
body += d;
console.log(".");
});
response.on('end', function() {
console.log("done");
console.log(body);
});
response.on('error', function(e) {
console.log("ERROR :( ");
console.log(e.message);
});
});
}
};
registerSuite(tests);
});
I have tried many verions of this and either get no error or
Warning: FATAL ERROR
Error: [POST http://localhost:4444/wd/hub/session] connect ECONNREFUSED
Error: connect ECONNREFUSED
at exports._errnoException <util.js:746:11>
at TCPConnectWrap.afterConnect [as oncomplete] <net.js:1000:19> Use --force to continue.
Am I missing something in my selenium/intern config?
I never really sorted out the error using the http module because I did have selenium running and it was still giving me the error. But I tried using dojo/request because it returns promises and it worked right away.