mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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.
|
||||
|
||||
#### 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()
|
||||
- returns: <[string]> Returns user agent.
|
||||
|
@ -236,10 +236,10 @@ class Page extends EventEmitter {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {!Promise<string>}
|
||||
* @return {!string}
|
||||
*/
|
||||
async url() {
|
||||
return this.evaluate(() => window.location.href);
|
||||
url() {
|
||||
return this.mainFrame().url();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -778,9 +778,9 @@ describe('Puppeteer', function() {
|
||||
|
||||
describe('Page.url', 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);
|
||||
expect(await page.url()).toBe(EMPTY_PAGE);
|
||||
expect(page.url()).toBe(EMPTY_PAGE);
|
||||
}));
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user