Make page.url() return URL synchronously.
page.url() is just a shortcut to page.mainFrame().url(). References #39.
This commit is contained in:
parent
34a96a8462
commit
560b817d7f
@ -353,7 +353,9 @@ In case of multiple pages in one browser, each page can have its own viewport si
|
|||||||
- returns: <[Promise]> Promise which resolves when the value is set.
|
- returns: <[Promise]> Promise which resolves when the value is set.
|
||||||
|
|
||||||
#### page.url()
|
#### page.url()
|
||||||
- returns: <[Promise]<[string]>> Promise which resolves with the current page url.
|
- returns: <[string]> Current page url.
|
||||||
|
|
||||||
|
This is a shortcut for [page.mainFrame().url()](#frameurl)
|
||||||
|
|
||||||
#### page.userAgent()
|
#### page.userAgent()
|
||||||
- returns: <[string]> Returns user agent.
|
- returns: <[string]> Returns user agent.
|
||||||
|
@ -236,10 +236,10 @@ class Page extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {!Promise<string>}
|
* @return {!string}
|
||||||
*/
|
*/
|
||||||
async url() {
|
url() {
|
||||||
return this.evaluate(() => window.location.href);
|
return this.mainFrame().url();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -778,9 +778,9 @@ describe('Puppeteer', function() {
|
|||||||
|
|
||||||
describe('Page.url', function() {
|
describe('Page.url', function() {
|
||||||
it('should work', SX(async function() {
|
it('should work', SX(async function() {
|
||||||
expect(await page.url()).toBe('about:blank');
|
expect(page.url()).toBe('about:blank');
|
||||||
await page.navigate(EMPTY_PAGE);
|
await page.navigate(EMPTY_PAGE);
|
||||||
expect(await page.url()).toBe(EMPTY_PAGE);
|
expect(page.url()).toBe(EMPTY_PAGE);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user