Today I am struggling with these lines of Protractor code:
element(by.linkText("People")).click(); browser.waitForAngular(); var url = browser.getCurrentUrl(); ...
It seems that getCurrentUrl always fails when placed after the waitForAngular() statement.
The error output is too foggy:
UnknownError: javascript error: document unloaded while waiting for result
So, what is the correct way to click on a hyperlink and check for a new URL?
Here are my tests:
If I getCurrentUrl() before clicking the link,
it('can visit people page', function () { var url = browser.getCurrentUrl(); element(by.linkText("People")).click(); expect(true).toBe(true); });
The test will pass.
If I getCurrentUrl() after clicking the link,
it('can visit people page', function () { var url = browser.getCurrentUrl(); element(by.linkText("People")).click(); expect(true).toBe(true); url = browser.getCurrentUrl(); });
An error is UnknownError in Protractor with an UnknownError output above. Something went wrong?
source share