End to End testing in protractor framework + AngularJs + calling an action from protractor
-
21-12-2019 - |
Question
I have an application in angularJs and in that I have 1 test case in protractor framework.I want to call a backend action of Java from protractor test case.How can I do that. ajax, http, jquery actions are not working I have tried the followings: 1)
$.ajax({
url : '/url',
type : 'GET/POST',
data : {
'param1' : val1,
"param2" : val2
},
success : function(json) {
console.log('success:'+json);
}
}
});
2)
$.getJSON('/url', {
"param1" : val1,
"param2" : val2
}, function(json) {
console.log('success:'+json);
});
3)
$http.get('/url', {
params : {
'param1' : val1,
'param2' : val2
}
}).success(function(data) {
console.log('success:'+json);
});
but that all are not working.
Please help me with an example thanks in advance
Solution
You can use browser.executeAsyncScript
Take a look at this example: Accessing Angular inside Protractor Test
OTHER TIPS
Protractor is e2e framework that means you can test only user interactions (in browser). For unit tests(making deeper testing for ajax calls) use Karma test runner.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow