new Page()
Properties:
Name | Type | Description |
---|---|---|
id |
string | 当前实例的唯一id |
closed |
boolean | 当前page是否关闭 |
isFront |
boolean | 当前page是否激活状态 |
isReady |
boolean | 首次dom-ready后isReady为true |
container |
Element | 容器dom |
webview |
WebviewTag | 页面对应的webview |
session |
Session | webview对应的Session实例 |
webRequest |
WebRequest | webview对应的WebRequest实例 |
ipc |
Ipc | ipc通信实例,可用于和webview的主页面和所有iframe通信 |
shortcuts |
Array | 快捷键配置,由Browser注入 |
options |
Object | 传入的配置信息 |
Extends
Methods
init() → {Promise.<undefined>}
初始化函数
Returns:
- Type
- Promise.<undefined>
build() → {Promise.<undefined>}
构建函数
Returns:
- Type
- Promise.<undefined>
isLoading() → {boolean}
是否在loading状态
Returns:
- Type
- boolean
isLoadingMainFrame() → {boolean}
主页面是否在loading状态
Returns:
- Type
- boolean
(async) bringToFront() → {Promise.<this>}
激活当前页面
Returns:
- Type
- Promise.<this>
browser() → {Browser}
获取当前page所属的browser
Returns:
- Type
- Browser
close() → {Browser}
关闭当前page
Returns:
- Type
- Browser
cookies(urls) → {Array.<Cookie>}
获取指定多个url下的cookie数据
Parameters:
Name | Type | Description |
---|---|---|
urls |
Array.<string> | url集合 |
Returns:
Cookie信息集合
- Type
- Array.<Cookie>
deleteCookies(…cookies)
Properties:
Name | Type | Description |
---|---|---|
Cookie.url |
string | 与cookie关联的 URL |
Cookie.name |
string | cookie名称 |
删除cookie 和puppeteer区别的是只支持url和name属性
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cookies |
Cookie |
<repeatable> |
要删除的cookie属性 |
frames() → {Array.<Frame>}
获取当前page下的所有frame集合,包含mainFrame和iframe
Returns:
- Type
- Array.<Frame>
canGoBack() → {boolean}
当前page是否可后退
Returns:
- Type
- boolean
canGoForward() → {boolean}
当前page是否可前进
Returns:
- Type
- boolean
goBack() → {undefined}
page后退
Returns:
- Type
- undefined
goForward() → {undefined}
page前进
Returns:
- Type
- undefined
isClosed() → {boolean}
当前page是否关闭
Returns:
- Type
- boolean
mainFrame() → {Frame}
获取mainFrame
Returns:
- Type
- Frame
find(text) → {Promise.<boolean>}
搜索页面内是否存在指定文本
Parameters:
Name | Type | Description |
---|---|---|
text |
string | 要搜索的文本 |
Returns:
- Type
- Promise.<boolean>
reload()
刷新页面 暂不支持options
screenshot(rect) → {Promise.<NativeImage>}
指定区域的截图 调用webview.capturePage
Parameters:
Name | Type | Description |
---|---|---|
rect |
Object | x, y, width, height属性 |
Returns:
- Type
- Promise.<NativeImage>
setCookie(…cookies) → {Promise}
设置cookie
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cookies |
Cookie |
<repeatable> |
Returns:
- Type
- Promise
waitForRequest() → {Promise.<never>}
todo 等待页面发起指定请求
Returns:
- Type
- Promise.<never>
waitForResponse() → {Promise.<never>}
todo 等待页面的指定请求返回
Returns:
- Type
- Promise.<never>
evaluateHandle() → {Promise.<never>}
todo
Returns:
- Type
- Promise.<never>
queryObjects() → {Promise.<never>}
todo
Returns:
- Type
- Promise.<never>
target()
返回当前页面的target
$()
$$()
$eval()
$$eval()
$x()
addScriptTag()
addStyleTag()
click()
content()
evaluate()
focus()
hover()
goto()
select()
setContent()
tap()
title()
type()
url()
waitFor()
waitForFunction()
waitForNavigation()
waitForSelector()
waitForXPath()
waitForSrcScript()
page.mainFrame().waitForSrcScript的简写
localStorageKeys()
localStorageGet()
localStorageSet()
localStorageRemove()
Events
dom-ready
Properties:
Name | Type | Description |
---|---|---|
url |
string | 页面url |
页面的dom加载完毕
Type:
- Object
frameattached
Properties:
Name | Type | Description |
---|---|---|
name |
string | iframe的name |
url |
string | iframe的url |
当iframe被首次加载时触发
Type:
- Object
framenavigated
Properties:
Name | Type | Description |
---|---|---|
name |
string | iframe的name |
url |
string | iframe的url |
当iframe发生跳转时触发
Type:
- Object
connect
Properties:
Name | Type | Description |
---|---|---|
url |
string | 页面的url |
当和页面建立起连接时触发 页面跳转之前会断开连接,刷新或跳转完成后会再次建立连接 在domcontentloaded事件之前
Type:
- Object
framedetached
Properties:
Name | Type | Description |
---|---|---|
name |
string | iframe的name |
url |
string | iframe的url |
当iframe被删除时触发
Type:
- Object
disconnect
Properties:
Name | Type | Description |
---|---|---|
url |
string | 当前页面的url |
当页面断开连接时触发
Type:
- Object
load-start
proxy webview Event:"did-start-loading"
load-fail
proxy webview Event:"did-fail-load"
load-end
proxy webview Event:"did-stop-loading", Event:"did-finish-load", Event:"did-frame-finish-load"(isMainFrame=true)
title-updated
Properties:
Name | Type | Description |
---|---|---|
title |
string |
页面标题更新
Type:
- Object
favicon-updated
Properties:
Name | Type | Description |
---|---|---|
favicon |
string |
icon更新
Type:
- Object
console
proxy webview Event:"console-message"
new-window
proxy webview Event:"new-window"
load
Properties:
Name | Type | Description |
---|---|---|
name |
string | iframe的name |
url |
string | iframe的url |
iframe onload时触发
Type:
- Object
domcontentloaded
Properties:
Name | Type | Description |
---|---|---|
name |
string | iframe的name |
url |
string | iframe的url |
iframe domcontentloaded时触发
Type:
- Object
back
当前page取消激活时触发
front
当前page激活时触发
close
当前page关闭时触发