new Frame(page, webviewElement, frameInfo)
Parameters:
Name | Type | Description |
---|---|---|
page |
Page | 所属page实例 |
webviewElement |
WebviewTag | webview节点 |
frameInfo |
FrameInfo | frame的信息 |
Methods
addScriptTag(options) → {Promise.<ElementHandle>}
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
options.url |
string |
<optional> |
要添加的script的src |
options.content |
string |
<optional> |
要注入页面的js代码 |
options.waitLoad |
boolean |
<optional> |
如果是url,等待onload回调 |
options.type |
string |
<optional> |
type属性,如果要注入 ES6 module,值为'module' |
注入一个指定url或(content)的script标签到页面
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
Returns:
返回注入脚本的dom句柄实例
- Type
- Promise.<ElementHandle>
addStyleTag(options) → {Promise.<ElementHandle>}
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
options.url |
string |
<optional> |
要添加的css link的src |
options.content |
string |
<optional> |
要注入页面的style代码 |
注入一个link(url)或style(content)标签到页面
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
Returns:
返回注入样式的dom句柄实例
- Type
- Promise.<ElementHandle>
childFrames()
获取当前frame
content() → {string}
todo 获取frame的内容
Returns:
- Type
- string
evaluate(pageFunction, args, timeoutopt) → {Promise.<*>}
在frame运行指定函数
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pageFunction |
function | ||
args |
Array.<string> | Array.<number> | 传给pageFunction的参数 |
|
timeout |
number |
<optional> |
等待超时时间 |
Returns:
返回运行结果,若pageFunction返回Promise,会等待Promise的resolve结果
- Type
- Promise.<*>
(async) goto(url, optionsopt) → {Promise.<undefined>}
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
options.waitUntil |
string |
<optional> |
认定跳转成功的事件类型 load|domcontentloaded,默认为domcontentloaded |
options.timeout |
number |
<optional> |
超时时间,单位为ms,默认为10000ms |
控制当前frame跳转到指定url 会在超时时间内追踪重定向,直到跳转到最终页面
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | ||
options |
Object |
<optional> |
Returns:
- Type
- Promise.<undefined>
isDetached()
todo
name() → {string}
frame的名称
Returns:
- Type
- string
page() → {Page}
frame所属的page实例
Returns:
- Type
- Page
parentFrame() → {Frame}
frame的parentFrame 如果当前frame为mainFrame,返回null
Returns:
- Type
- Frame
select()
todo
setContent(html) → {Promise.<undefined>}
todo 设置页面内容
Parameters:
Name | Type | Description |
---|---|---|
html |
string |
Returns:
- Type
- Promise.<undefined>
title() → {string}
frame的标题
Returns:
- Type
- string
type(selector, text, optionsopt)
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
options.delay |
number |
<optional> |
// 延迟输入, 操作更像用户 |
todo 未实现,请使用press方法 输入指定内容
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
selector |
string | 要输入的dom的选择,input或textarea |
|
text |
string | 输入的文本 |
|
options |
Object |
<optional> |
url() → {string}
获取url,如果是mainFrame为当前url,如果是iframe,则是src属性
Returns:
- Type
- string
waitFor(selectorOrFunctionOrTimeout, options, …args)
waitForSelector|waitForFunction|setTimeout的结合体
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
selectorOrFunctionOrTimeout |
string | number | function | ||
options |
Object | ||
args |
any |
<repeatable> |
waitForFunction(pageFunction, optionsopt, …args) → {Promise.<boolean>}
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
options.timeout |
number |
<optional> |
等待时间 |
在指定时间内轮询执行方法,直到方法返回true
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pageFunction |
function | ||
options |
Object |
<optional> |
|
args |
any |
<repeatable> |
Returns:
成功返回resove(true),超时返回reject
- Type
- Promise.<boolean>
waitForNavigation(optionsopt) → {Promise.<Object>}
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
options.waitUntil |
string |
<optional> |
认定跳转成功的事件类型 load|domcontentloaded,默认为domcontentloaded |
options.timeout |
number |
<optional> |
超时时间,单位为ms,默认为10000ms |
等待跳转完成
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
Returns:
返回跳转后frame的信息
- Type
- Promise.<Object>
waitForSelector(selector, optionsopt) → {Promise.<undefined>}
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
options.visible |
boolean |
<optional> |
节点是否可见,如果visible为true时必须查到到dom节点且可见才会返回true |
options.timeout |
number |
<optional> |
超时时间,单位为ms,默认为10000ms |
在指定时间内轮询查询dom节点,直到查找到节点
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
selector |
string | dom节点选择器 |
|
options |
Object |
<optional> |
Returns:
成功则resolve,失败返回reject
- Type
- Promise.<undefined>
waitForXPath()
todo
click(selector, options) → {Promise.<boolean>}
点击frame内的指定节点
Parameters:
Name | Type | Description |
---|---|---|
selector |
string | 选择器 |
options |
Object | 暂不支持 |
Returns:
- Type
- Promise.<boolean>
focus(selector, options) → {Promise.<boolean>}
聚焦frame内的指定节点
Parameters:
Name | Type | Description |
---|---|---|
selector |
string | 选择器 |
options |
Object | 暂不支持 |
Returns:
- Type
- Promise.<boolean>
blur(selector, options) → {Promise.<boolean>}
取消聚焦frame内的指定节点
Parameters:
Name | Type | Description |
---|---|---|
selector |
string | 选择器 |
options |
Object | 暂不支持 |
Returns:
- Type
- Promise.<boolean>
hover(selector, options) → {Promise.<boolean>}
鼠标移入frame内的指定节点,对应mouseover事件
Parameters:
Name | Type | Description |
---|---|---|
selector |
string | 选择器 |
options |
Object | 暂不支持 |
Returns:
- Type
- Promise.<boolean>
tap()
todo
localStorageKeys()
获取localStorage的所有key集合
localStorageGet(key) → {Promise.<string>}
localStorage.getItem
Parameters:
Name | Type | Description |
---|---|---|
key |
string |
Returns:
- Type
- Promise.<string>
localStorageSet(key, value) → {Promise.<undefined>}
localStorage.setItem
Parameters:
Name | Type | Description |
---|---|---|
key |
string | |
value |
string |
Returns:
- Type
- Promise.<undefined>
localStorageRemove(key) → {Promise.<undefined>}
localStorage.removeItem
Parameters:
Name | Type | Description |
---|---|---|
key |
string |
Returns:
- Type
- Promise.<undefined>