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:
parent
826fe42c48
commit
52d3bc05de
@ -518,7 +518,7 @@ class Page extends EventEmitter {
|
||||
async function navigate(client, url, referrer) {
|
||||
try {
|
||||
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) {
|
||||
return error;
|
||||
}
|
||||
|
10
test/test.js
10
test/test.js
@ -1420,6 +1420,16 @@ describe('Page', function() {
|
||||
expect(response.status()).toBe(200);
|
||||
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user