JavascriptError: javascript error: document unloaded while waiting for result
Hello I have a problem with “JavascriptError: javascript error: document unloaded while waiting for result ” . Any advise would be really helpful. Curious thing is that same test pass in Ubuntu14.04 platform but fails in Mac OS X 10.10.4 x86_64
And its an intermittent issue. It doesn't fail for the same test every time. It's always a different test.
Below are logs:
Failures:
[18:51:46][Step 4/4] 1) vacancies should create new job listing
[18:51:46][Step 4/4] Message:
[18:51:46][Step 4/4] [31m Failed: javascript error: document unloaded while waiting for result
[18:51:46][Step 4/4] (Session info: chrome=44.0.2403.155)
[18:51:46][Step 4/4] (Driver info: chromedriver=2.15.322455 (rg5th540dac8d0c453355d3d922c91ads1231),platform=Mac OS X 10.10.4 x86_64) [0m
[18:51:46][Step 4/4] Stack:
[18:51:46][Step 4/4] JavascriptError: javascript error: document unloaded while waiting for result
[18:51:46][Step 4/4] (Session info: chrome=44.0.2403.155)
[18:51:46][Step 4/4] (Driver info: chromedriver=2.15.322455 (rg5th540dac8d0c453355d3d922c91ads1231),platform=Mac OS X 10.10.4 x86_64)
[18:51:46][Step 4/4] at Array.forEach (native)
[18:51:46][Step 4/4] From: Task: Run it("should create new job listing") in control flow
[18:51:46][Step 4/4] at Array.forEach (native)
[18:51:46][Step 4/4] From asynchronous test:
[18:51:46][Step 4/4] Error
[18:51:46][Step 4/4] at Suite.<anonymous> (/client/test/e2e/vacancies/vacancies.create.specs.js:67:7)
[18:51:46][Step 4/4] at Object.<anonymous> (/client/test/e2e/vacancies/vacancies.create.specs.js:17:3)
The lines that the log is pointing to is the test's starting line.
Below is the code snippet:
67 it('should create new job listing', function () {
68 //Login As Admin To Access Vacancies Feature
69 loginAsManager();
.
. //load manager's dashboard list page
. dashboardPage = new DashboardPage();
. dashboardPage.vacanciesTab.click();
.
. //load vacancies list page
. var vacanciesUrl = browser.baseUrl + '#/vacancies';
. browser.waitForAngular();
. expect(browser.getCurrentUrl()).toEqual(vacanciesUrl);
. vacanciesPage = new VacanciesPage();
. vacanciesPage.addVacancyButton.click();
.
.
I was able to fix this issue by making browser sleep for few seconds after every change in URL.
Below is the code snippet:
67 it('should create new job listing', function () {
68 //Login As Admin To Access Vacancies Feature
69 loginAsManager();
.
. //load manager's dashboard list page
. dashboardPage = new DashboardPage();
. dashboardPage.vacanciesTab.click();
.
. //load vacancies list page
. var vacanciesUrl = browser.baseUrl + '#/vacancies';
. browser.sleep(2000);
. expect(browser.getCurrentUrl()).toEqual(vacanciesUrl);
. vacanciesPage = new VacanciesPage();
. vacanciesPage.addVacancyButton.click();
.
.
I don't think this is a neat solution to this problem.
I will be happy to hear, if someone has a better solution to this.
Cheers Gaurav
dashboardPage.vacanciesTab.click() is returning a promise, that is way you need to wait until respons. or do a .then() block and inside continue your test.