How to stop automatically closing browser when writing protractor test cases

后端 未结 9 1745
面向向阳花
面向向阳花 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:12

    Add browser.pause() at the end of your it function. Within the function itself.

    0 讨论(0)
  • 2021-02-07 13:17
    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.pause(); // it should leave browser alive after test
      });
    

    browser.pause() should leave browser alive until you let it go.

    @Edit Another approach is to set browser.ignoreSynchronization = true before browser.get(...). Protractor wouldn't wait for Angular loaded and you could use usual element(...) syntax.

    0 讨论(0)
  • 2021-02-07 13:20

    I suggest you to use browser.driver.sleep(500); before your click operation.

    See this.

    browser.driver.sleep(500);
    
    element(by.css('your button')).click();
    browser.driver.sleep(500);
    
    0 讨论(0)
提交回复
热议问题