문제

I have a angular application. I have written some test cases for the login-page, checking normal login scenarios.

describe('Login screen tests', function () {
  var ptor = protractor.getInstance();

  beforeEach(function(){
    ptor.get('http://url:3000/login/#/');
  });

  it('Blank Username & Password test', function() {
    ptor.findElement(protractor.By.id("submit")).click();
    var message = ptor.findElement(protractor.By.repeater('message in messages'));
    message.then(function(message){
        expect(message.getText()).toContain('Username or Password can\'t be blank');
    });
  });

  it ('Blank Password test', function(){
    ....
  });

  it ('Invalid username test', function(){
    ....
  });    

  ......  //Similarly more test cases folow for the login screen. 
});

The tests run properly as expected.

Problem: The tests are very slow, this takes about 1.5 mins to complete. If I run the same tests using a selenium via java. It takes only around 2-3 seconds which should be ideal. I want to use protractor coz the application is entirely on top of angular.

I would guess that there maybe a default time-out of lets say 300ms after each tests. which make the tests slow. So even if the check is done it waits for the time-out.

Is there some polling mechanism so that if the test completes before time-out it can move forward. I tried using done() like in jasmine, but done() gives an error, i inquired to know that done() is internally pached with protractor.

도움이 되었습니까?

해결책

There is a chance the slowness is related to protractor waiting to sync with each page each time. You can disable that feature with

ptor.ignoreSynchronization = true;

Keep in mind that the option was intended to be passed to non-angular pages, temporary. But if speed is more important to you, i guess you can go with that.

Note ptor is the old syntax, you should upgrade and start using browser instead, like this:

browser.ignoreSynchronization = true;

If you start experiencing flaky tests, i suggest you go back to the default false value on the specific pages that has random issues.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top