最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

angularjs - JavascriptError: javascript error: document unloaded while waiting for result - Stack Overflow

programmeradmin1浏览0评论

While testing angular apps using protractor e2e test runs.

I am currently facing a problem. And its an intermittent issue. I am receiving “JavascriptError: javascript error: document unloaded while waiting for result ” .

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 think it does mean here that before expect finishes it's assertion, the page being targeted is no more available or unloaded.

So, after every page navigation, I tried adding "browser.waitForAngular()". But it did't help the assertion to pass.

Curious thing is that same test pass in Ubuntu14.04 platform but fails in Mac OS X 10.10.4 x86_64

It doesn't fail for the same test every time. It's always a different test.

Any advise would be really helpful.

Thanks.

While testing angular apps using protractor e2e test runs.

I am currently facing a problem. And its an intermittent issue. I am receiving “JavascriptError: javascript error: document unloaded while waiting for result ” .

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 think it does mean here that before expect finishes it's assertion, the page being targeted is no more available or unloaded.

So, after every page navigation, I tried adding "browser.waitForAngular()". But it did't help the assertion to pass.

Curious thing is that same test pass in Ubuntu14.04 platform but fails in Mac OS X 10.10.4 x86_64

It doesn't fail for the same test every time. It's always a different test.

Any advise would be really helpful.

Thanks.

Share Improve this question asked Aug 13, 2015 at 22:46 Gaurav TandonGaurav Tandon 1312 silver badges8 bronze badges 2
  • Run webdriver-manager update and try again. – alecxe Commented Aug 13, 2015 at 23:18
  • 1 Updated webdriver-manager. But it still fails. – Gaurav Tandon Commented Aug 14, 2015 at 4:34
Add a ment  | 

2 Answers 2

Reset to default 4

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

I would suggesting having a look at ExpectedConditions in protractor. They help in these type of scenarios. If you look at the example this may help you find an alternative solution to your issue. I am currently rewriting a lot of tests using this pattern as was constantly having intermittent test failures on our CI build server.

发布评论

评论列表(0)

  1. 暂无评论