Skip to content

全局方法global - puppeteerApp

openApp(packageName)

打开应用

Kind: global function

ParamType
packageNamestring

openAppName(appName)

打开应用(通过名称)

Kind: global function

ParamType
appNamestring

closeApp(packageName)

关闭应用

Kind: global function

ParamType
packageNamestring

getApps() ⇒ Array.<Object>

获取所有应用

Kind: global function

getPackageName(appName) ⇒ string

获取应用包名

Kind: global function

ParamType
appNamestring

getApp(appName) ⇒ string

获取应用包名

Kind: global function

ParamType
appNamestring

version() ⇒ string

获取版本信息

Kind: global function

isEnabled() ⇒ string

获取版本信息

Kind: global function

requestPermission(options) ⇒ Promise.<boolean>

请求权限

Kind: global function

ParamTypeDefault
optionsObject
[options.timeout]number60000

back()

后退操作

Kind: global function

home()

主屏幕操作

Kind: global function

recent()

最近应用操作

Kind: global function

powerDialog()

最近应用操作

Kind: global function

notificationBar()

通知栏操作

Kind: global function

quickSettings()

快速设置操作

Kind: global function

lockScreen()

锁定屏幕操作

Kind: global function

splitScreen()

锁定屏幕操作

Kind: global function

setVolume(volumeLevel, streamType)

设置音量

Kind: global function

ParamTypeDefault
volumeLevelnumber
streamTypenumber1

getVolume(streamType) ⇒ number

获取音量

Kind: global function

ParamTypeDefault
streamTypenumber1

startActivity(streamType) ⇒ number

获取音量

Kind: global function

ParamType
streamTypenumber

openUrl(url)

打开网页的函数,支持 http 和 https 协议。 如果 URL 不是以 http 或 https 开头,则添加 https://。 不添加 URL scheme,比如 weixin://

Kind: global function

ParamType
urlstring

encodeURIComponent(str) ⇒ string

对字符串进行 encodeURIComponent 编码

Kind: global function

ParamType
strstring

encodeURI(uri, allowedChars) ⇒ string

对 URI 进行 encodeURI 编码

Kind: global function

ParamType
uristring
allowedCharsstring

decodeURIComponent(str) ⇒ string

对字符串进行 decodeURIComponent 解码

Kind: global function

ParamType
strstring

decodeURI(uri) ⇒ string

对 URI 进行 decodeURI 解码

Kind: global function

ParamType
uristring
toast(value)

显示 toast 消息 使用给定的值显示一个 toast 消息。

alert(message)Promise.<void>

显示 alert 对话框 显示一个包含给定消息的 alert 对话框,并返回一个承诺,当用户关闭对话框时解决该承诺。

confirm(title, [content], [callback])Promise.<boolean>

显示 confirm 对话框 显示一个具有给定标题和内容的 confirm 对话框。如果提供了回调函数,它将使用对话框的结果调用。 如果没有提供回调函数,则返回一个承诺,该承诺根据对话框的结果进行解析。

prompt(title, [defaultValue], [callback])Promise.<string>

显示 prompt 对话框 显示一个具有给定标题和默认值的 prompt 对话框。如果提供了回调函数,它将使用对话框的结果调用。 如果没有提供回调函数,则返回一个承诺,该承诺根据对话框的结果进行解析。

copyToClipboard(text)

将文本复制到剪贴板 将给定的文本复制到设备的剪贴板。

getClipboard()string

获取剪贴板内容 获取设备剪贴板当前的内容。

toast(value)

显示 toast 消息 使用给定的值显示一个 toast 消息。

Kind: global function

ParamTypeDescription
valuestring要在 toast 中显示的消息。

alert(message) ⇒ Promise.<void>

显示 alert 对话框 显示一个包含给定消息的 alert 对话框,并返回一个承诺,当用户关闭对话框时解决该承诺。

Kind: global function Returns: Promise.<void> - - 当用户关闭对话框时解决的承诺。

ParamTypeDescription
messagestring要在 alert 对话框中显示的消息。

confirm(title, [content], [callback]) ⇒ Promise.<boolean>

显示 confirm 对话框 显示一个具有给定标题和内容的 confirm 对话框。如果提供了回调函数,它将使用对话框的结果调用。 如果没有提供回调函数,则返回一个承诺,该承诺根据对话框的结果进行解析。

Kind: global function Returns: Promise.<boolean> - - 如果未提供回调函数,则根据对话框结果解析的承诺。

ParamTypeDefaultDescription
titlestringconfirm 对话框的标题。
[content]string"''"要在 confirm 对话框中显示的内容。
[callback]function可选的回调函数,将在对话框结果上被调用。

prompt(title, [defaultValue], [callback]) ⇒ Promise.<string>

显示 prompt 对话框 显示一个具有给定标题和默认值的 prompt 对话框。如果提供了回调函数,它将使用对话框的结果调用。 如果没有提供回调函数,则返回一个承诺,该承诺根据对话框的结果进行解析。

Kind: global function Returns: Promise.<string> - - 如果未提供回调函数,则根据对话框结果解析的承诺。

ParamTypeDefaultDescription
titlestringprompt 对话框的标题。
[defaultValue]string"''"在 prompt 对话框中显示的默认值。
[callback]function可选的回调函数,将在对话框结果上被调用。

copyToClipboard(text)

将文本复制到剪贴板 将给定的文本复制到设备的剪贴板。

Kind: global function

ParamTypeDescription
textstring要复制到剪贴板的文本。

getClipboard() ⇒ string

获取剪贴板内容 获取设备剪贴板当前的内容。

Kind: global function Returns: string - - 剪贴板当前的内容。