Page

Page

new Page()

Source:
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>}

Source:

初始化函数

Returns:
Type
Promise.<undefined>

build() → {Promise.<undefined>}

Source:

构建函数

Returns:
Type
Promise.<undefined>

isLoading() → {boolean}

Source:

是否在loading状态

Returns:
Type
boolean

isLoadingMainFrame() → {boolean}

Source:

主页面是否在loading状态

Returns:
Type
boolean

(async) bringToFront() → {Promise.<this>}

Source:

激活当前页面

Returns:
Type
Promise.<this>

browser() → {Browser}

Source:

获取当前page所属的browser

Returns:
Type
Browser

close() → {Browser}

Source:

关闭当前page

Returns:
Type
Browser

cookies(urls) → {Array.<Cookie>}

Source:

获取指定多个url下的cookie数据

Parameters:
Name Type Description
urls Array.<string>

url集合

Returns:

Cookie信息集合

Type
Array.<Cookie>

deleteCookies(…cookies)

Source:
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>}

Source:

获取当前page下的所有frame集合,包含mainFrame和iframe

Returns:
Type
Array.<Frame>

canGoBack() → {boolean}

Source:

当前page是否可后退

Returns:
Type
boolean

canGoForward() → {boolean}

Source:

当前page是否可前进

Returns:
Type
boolean

goBack() → {undefined}

Source:

page后退

Returns:
Type
undefined

goForward() → {undefined}

Source:

page前进

Returns:
Type
undefined

isClosed() → {boolean}

Source:

当前page是否关闭

Returns:
Type
boolean

mainFrame() → {Frame}

Source:

获取mainFrame

Returns:
Type
Frame

find(text) → {Promise.<boolean>}

Source:

搜索页面内是否存在指定文本

Parameters:
Name Type Description
text string

要搜索的文本

Returns:
Type
Promise.<boolean>

reload()

Source:

刷新页面 暂不支持options

screenshot(rect) → {Promise.<NativeImage>}

Source:

指定区域的截图 调用webview.capturePage

Parameters:
Name Type Description
rect Object

x, y, width, height属性

Returns:
Type
Promise.<NativeImage>

setCookie(…cookies) → {Promise}

Source:

设置cookie

Parameters:
Name Type Attributes Description
cookies Cookie <repeatable>
Returns:
Type
Promise

waitForRequest() → {Promise.<never>}

Source:

todo 等待页面发起指定请求

Returns:
Type
Promise.<never>

waitForResponse() → {Promise.<never>}

Source:

todo 等待页面的指定请求返回

Returns:
Type
Promise.<never>

evaluateHandle() → {Promise.<never>}

Source:

todo

Returns:
Type
Promise.<never>

queryObjects() → {Promise.<never>}

Source:

todo

Returns:
Type
Promise.<never>

target()

Source:

返回当前页面的target

$()

Source:

$$()

Source:

$eval()

Source:

$$eval()

Source:

$x()

Source:

addScriptTag()

Source:

addStyleTag()

Source:

click()

Source:

content()

Source:

evaluate()

Source:

focus()

Source:

hover()

Source:

goto()

Source:

select()

Source:

setContent()

Source:

tap()

Source:

title()

Source:

type()

Source:

url()

Source:

waitFor()

Source:

waitForFunction()

Source:

waitForNavigation()

Source:

waitForSelector()

Source:

waitForXPath()

Source:

waitForSrcScript()

Source:

page.mainFrame().waitForSrcScript的简写

localStorageKeys()

Source:

localStorageGet()

Source:

localStorageSet()

Source:

localStorageRemove()

Source:

Events

dom-ready

Source:
Properties:
Name Type Description
url string

页面url

页面的dom加载完毕

Type:
  • Object

frameattached

Source:
Properties:
Name Type Description
name string

iframe的name

url string

iframe的url

当iframe被首次加载时触发

Type:
  • Object

framenavigated

Source:
Properties:
Name Type Description
name string

iframe的name

url string

iframe的url

当iframe发生跳转时触发

Type:
  • Object

connect

Source:
Properties:
Name Type Description
url string

页面的url

当和页面建立起连接时触发 页面跳转之前会断开连接,刷新或跳转完成后会再次建立连接 在domcontentloaded事件之前

Type:
  • Object

framedetached

Source:
Properties:
Name Type Description
name string

iframe的name

url string

iframe的url

当iframe被删除时触发

Type:
  • Object

disconnect

Source:
Properties:
Name Type Description
url string

当前页面的url

当页面断开连接时触发

Type:
  • Object

load-start

Source:

proxy webview Event:"did-start-loading"

load-fail

Source:

proxy webview Event:"did-fail-load"

load-end

Source:

proxy webview Event:"did-stop-loading", Event:"did-finish-load", Event:"did-frame-finish-load"(isMainFrame=true)

title-updated

Source:
Properties:
Name Type Description
title string

页面标题更新

Type:
  • Object

favicon-updated

Source:
Properties:
Name Type Description
favicon string

icon更新

Type:
  • Object

console

Source:

proxy webview Event:"console-message"

new-window

Source:

proxy webview Event:"new-window"

load

Source:
Properties:
Name Type Description
name string

iframe的name

url string

iframe的url

iframe onload时触发

Type:
  • Object

domcontentloaded

Source:
Properties:
Name Type Description
name string

iframe的name

url string

iframe的url

iframe domcontentloaded时触发

Type:
  • Object

back

Source:

当前page取消激活时触发

front

Source:

当前page激活时触发

close

Source:

当前page关闭时触发

Page

new Page(browser, options)

Source:

Page构造函数

Parameters:
Name Type Description
browser Browser
options PageOptions

传入配置

Properties
Name Type Attributes Description
container Element

DOM容器

devtools boolean <optional>

是否打开控制台

partition string <optional>

session标识,相同的partition共享登录状态

loadingTimeout number <optional>

页面加载超时时间, 默认10s

startUrl string <optional>

初始页面

startUrlReferrer string <optional>

startUrl的referrer

preload string

preload的脚本路径, 理论上必须为当前包的preload/webivew.preload.js

webpreferences string <optional>

网页功能的设置

Methods

init() → {Promise.<undefined>}

Source:

初始化函数

Returns:
Type
Promise.<undefined>

build() → {Promise.<undefined>}

Source:

构建函数

Returns:
Type
Promise.<undefined>

isLoading() → {boolean}

Source:

是否在loading状态

Returns:
Type
boolean

isLoadingMainFrame() → {boolean}

Source:

主页面是否在loading状态

Returns:
Type
boolean

(async) bringToFront() → {Promise.<this>}

Source:

激活当前页面

Returns:
Type
Promise.<this>

browser() → {Browser}

Source:

获取当前page所属的browser

Returns:
Type
Browser

close() → {Browser}

Source:

关闭当前page

Returns:
Type
Browser

cookies(urls) → {Array.<Cookie>}

Source:

获取指定多个url下的cookie数据

Parameters:
Name Type Description
urls Array.<string>

url集合

Returns:

Cookie信息集合

Type
Array.<Cookie>

deleteCookies(…cookies)

Source:
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>}

Source:

获取当前page下的所有frame集合,包含mainFrame和iframe

Returns:
Type
Array.<Frame>

canGoBack() → {boolean}

Source:

当前page是否可后退

Returns:
Type
boolean

canGoForward() → {boolean}

Source:

当前page是否可前进

Returns:
Type
boolean

goBack() → {undefined}

Source:

page后退

Returns:
Type
undefined

goForward() → {undefined}

Source:

page前进

Returns:
Type
undefined

isClosed() → {boolean}

Source:

当前page是否关闭

Returns:
Type
boolean

mainFrame() → {Frame}

Source:

获取mainFrame

Returns:
Type
Frame

find(text) → {Promise.<boolean>}

Source:

搜索页面内是否存在指定文本

Parameters:
Name Type Description
text string

要搜索的文本

Returns:
Type
Promise.<boolean>

reload()

Source:

刷新页面 暂不支持options

screenshot(rect) → {Promise.<NativeImage>}

Source:

指定区域的截图 调用webview.capturePage

Parameters:
Name Type Description
rect Object

x, y, width, height属性

Returns:
Type
Promise.<NativeImage>

setCookie(…cookies) → {Promise}

Source:

设置cookie

Parameters:
Name Type Attributes Description
cookies Cookie <repeatable>
Returns:
Type
Promise

waitForRequest() → {Promise.<never>}

Source:

todo 等待页面发起指定请求

Returns:
Type
Promise.<never>

waitForResponse() → {Promise.<never>}

Source:

todo 等待页面的指定请求返回

Returns:
Type
Promise.<never>

evaluateHandle() → {Promise.<never>}

Source:

todo

Returns:
Type
Promise.<never>

queryObjects() → {Promise.<never>}

Source:

todo

Returns:
Type
Promise.<never>

target()

Source:

返回当前页面的target

$()

Source:

$$()

Source:

$eval()

Source:

$$eval()

Source:

$x()

Source:

addScriptTag()

Source:

addStyleTag()

Source:

click()

Source:

content()

Source:

evaluate()

Source:

focus()

Source:

hover()

Source:

goto()

Source:

select()

Source:

setContent()

Source:

tap()

Source:

title()

Source:

type()

Source:

url()

Source:

waitFor()

Source:

waitForFunction()

Source:

waitForNavigation()

Source:

waitForSelector()

Source:

waitForXPath()

Source:

waitForSrcScript()

Source:

page.mainFrame().waitForSrcScript的简写

localStorageKeys()

Source:

localStorageGet()

Source:

localStorageSet()

Source:

localStorageRemove()

Source:

Events

dom-ready

Source:
Properties:
Name Type Description
url string

页面url

页面的dom加载完毕

Type:
  • Object

frameattached

Source:
Properties:
Name Type Description
name string

iframe的name

url string

iframe的url

当iframe被首次加载时触发

Type:
  • Object

framenavigated

Source:
Properties:
Name Type Description
name string

iframe的name

url string

iframe的url

当iframe发生跳转时触发

Type:
  • Object

connect

Source:
Properties:
Name Type Description
url string

页面的url

当和页面建立起连接时触发 页面跳转之前会断开连接,刷新或跳转完成后会再次建立连接 在domcontentloaded事件之前

Type:
  • Object

framedetached

Source:
Properties:
Name Type Description
name string

iframe的name

url string

iframe的url

当iframe被删除时触发

Type:
  • Object

disconnect

Source:
Properties:
Name Type Description
url string

当前页面的url

当页面断开连接时触发

Type:
  • Object

load-start

Source:

proxy webview Event:"did-start-loading"

load-fail

Source:

proxy webview Event:"did-fail-load"

load-end

Source:

proxy webview Event:"did-stop-loading", Event:"did-finish-load", Event:"did-frame-finish-load"(isMainFrame=true)

title-updated

Source:
Properties:
Name Type Description
title string

页面标题更新

Type:
  • Object

favicon-updated

Source:
Properties:
Name Type Description
favicon string

icon更新

Type:
  • Object

console

Source:

proxy webview Event:"console-message"

new-window

Source:

proxy webview Event:"new-window"

load

Source:
Properties:
Name Type Description
name string

iframe的name

url string

iframe的url

iframe onload时触发

Type:
  • Object

domcontentloaded

Source:
Properties:
Name Type Description
name string

iframe的name

url string

iframe的url

iframe domcontentloaded时触发

Type:
  • Object

back

Source:

当前page取消激活时触发

front

Source:

当前page激活时触发

close

Source:

当前page关闭时触发