Protractor browser.wait doesn't wait

后端 未结 2 1334
走了就别回头了
走了就别回头了 2021-02-01 15:48

I am assuming that browser.wait should be a blocking call, but it is not working as I expected. Here is my sample:

descr         


        
2条回答
  •  难免孤独
    2021-02-01 16:37

    Wait function will hold execution for that particular function, But JavaScript work in async way. So sometime there might be chance your function gets executed before wait function. To understand it better you need to read Promises in angular/protractor.

    To get your code working you need to .then(function(){}); (asking function 2 to wait until 1st complete.

    browser.wait(function() {
        console.log('1 - BeforeEach WAIT');
        return true;
    }).then(function () {
        console.log('2 - BeforeEach after wait');
    });
    

提交回复
热议问题