Reputation: 41
I need to restart browser after each "it" (test), for this reason I write "restartBrowserBetweenTests: true" in protractor.config file. Now after first "it" (test) finished, browser closed and opened again (open website that I write in "beforeEach", but next "it" (test) is not run.
What I do wrong? I will be happy for any advice.
I use "protractor": "2.5.1".
Thanks!
Added:
beforeEach(function () {
browserUtil.navigateTo(browserUtil.url.main);
loginPage.loginAsSample();
});
afterEach(function(){
browserUtil.deleteCookies();
});
it("'Delete' button is inactive if there are no projects in the list", function() {
projectPage.clickOnProjectButton();
expect(projectPage.isProjectPageFormVisibility(true)).toBe(true);
expect(projectPage.isDeleteBtnDisable()).toBe(true);
});
it("Create new project with template 'A'", function() {
projectPage.clickOnNewProjectBtn();
projectPage.clickOnAProject();
projectPage.clickOnOkBtnProject();
expect(projectPage.isOpenedProjectVisibility(true)).toBe(true);
});
Upvotes: 1
Views: 3469
Reputation: 11
I've never utilized restartBrowserBetweenTests: true
, but this works for me:
in protractor.conf, remove restartBrowserBetweenTests: true
in test.spec.js, modify beforeEach
and afterEach
beforeEach(function () {
browser.get(browserUtil.url.main);
});
afterEach(function () {
browser.manage().deleteAllCookies();
});
Being that you're utilizing a page object structure for your tests, you could/would want to encapsulate browser.get(browser.browserUtil.url.main);
into you're page object.
Where ProjectPage is defined, I'd add :
this.refreshPage = function () {
browser.get(browserUtil.url.main);
};
If you go with this approach, you'd change the call on beforeEach
to :
beforeEach(function () {
projectPage.refresh();
});
Upvotes: 1