How to stop automatically closing browser when writing protractor test cases

后端 未结 9 1768
面向向阳花
面向向阳花 2021-02-07 12:43

I am new to writing test cases using protractor for non angular application. I wrote a sample test case.Here the browser closes automatically after running test case.How can I p

9条回答
  •  深忆病人
    2021-02-07 13:06

    The best way to make browser NOT to close for some time, Use browser.wait(). Inside the wait function write logic for checking either visibilityOf() or invisibilityOf() of an element, which is not visible or it will take time to become invisible on UI. In this case wait() keep on checking the logic until either condition met or timeout reached. You can increase the timeout if you want browser visible more time.

    var EC=protractor.ExpectedConditions;
    var submitBtnElm = $('input[data-behavior=saveContribution]');
    
    it('Should Search', function() {
       browser.driver.get('http://localhost/enrollments/osda1.html');   
       browser.driver.findElement(by.id('contributePercentValue')).sendKeys(50);
       submitBtnElm.click().then(function() {
       browser.wait(function(){
                EC.invisibilityOf(submitBtnElm).call().then(function(isPresent){
                    if(isPresent){
                        return true;
                    }
                });
            },20000,'error message');
        });
      });
    

提交回复
热议问题