0

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

Stepan Suvorov
  • 25,118
  • 26
  • 108
  • 176
Brijesh Soni
  • 567
  • 1
  • 4
  • 14

2 Answers2

0

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.

Stepan Suvorov
  • 25,118
  • 26
  • 108
  • 176
  • Accepted.There is any way of integrate protractor with JUnit!.I have testcases in JUnit. And now frontend is converted in Angular. So I am thinking that use protractor library in JUnit and use advantage of protractor in JUnit. Is this possible or not? there is any way to do this? – Brijesh Soni Feb 27 '14 at 06:52
0

You can use browser.executeAsyncScript

Take a look at this example: Accessing Angular inside Protractor Test

Community
  • 1
  • 1
Andres D
  • 8,910
  • 2
  • 26
  • 31