How to stop automatically closing browser when writing protractor test cases

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

    I'm sure there is a change triggered on your page by the button click. It might be something as subtle as a class change on an element or as obvious as a

    element with the text "Saved" displayed. What I would do is, after the test, explicitly wait for this change.

    [...]
    return protractor.browser.wait(function() {
        return element(by.cssContainingText('p', 'Saved')).isPresent();
    }, 10000);
    

    You could add such a wait mechanism to the afterEach() method of your spec file, so that your tests are separated even without the Protractor Angular implicit waits.

提交回复
热议问题