feat(Page): introduce url at error message at page.goto (#2174)

Now the error message will come with the url where the error was
generated.

Fixes #2165.
This commit is contained in:
Juan Sebastian velez Posada 2018-03-12 18:38:05 -04:00 committed by Andrey Lushnikov
parent 826fe42c48
commit 52d3bc05de
2 changed files with 11 additions and 1 deletions

View File

@ -518,7 +518,7 @@ class Page extends EventEmitter {
async function navigate(client, url, referrer) { async function navigate(client, url, referrer) {
try { try {
const response = await client.send('Page.navigate', {url, referrer}); const response = await client.send('Page.navigate', {url, referrer});
return response.errorText ? new Error(response.errorText) : null; return response.errorText ? new Error(`${response.errorText} at ${url}`) : null;
} catch (error) { } catch (error) {
return error; return error;
} }

View File

@ -1420,6 +1420,16 @@ describe('Page', function() {
expect(response.status()).toBe(200); expect(response.status()).toBe(200);
expect(response.url()).toContain('self-request.html'); expect(response.url()).toContain('self-request.html');
}); });
it('should fail when navigating and show the url at the error message', async function({page, server, httpsServer}) {
const url = httpsServer.PREFIX + '/redirect/1.html';
let error = null;
try {
await page.goto(url);
} catch (e) {
error = e;
}
expect(error.message).toContain(url);
});
}); });
describe('Page.waitForNavigation', function() { describe('Page.waitForNavigation', function() {