Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
df005cf6
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
df005cf6
编写于
5月 15, 2023
作者:
Z
zhouke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify.Signed-off-by: <zhouke35@huawei.com>.
Signed-off-by:
N
zhouke
<
zhouke35@huawei.com
>
上级
55b9befd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
160 addition
and
134 deletion
+160
-134
zh-cn/application-dev/reference/apis/js-apis-uitest.md
zh-cn/application-dev/reference/apis/js-apis-uitest.md
+160
-134
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-uitest.md
浏览文件 @
df005cf6
...
...
@@ -20,7 +20,7 @@ UiTest提供模拟UI操作的能力,供开发者在测试场景使用,主要
## 导入模块
```
js
import
{
UiComponent
,
UiDriver
,
Component
,
Driver
,
UiWindow
,
ON
,
BY
,
MatchPattern
,
DisplayRotation
,
ResizeDirection
,
WindowMode
,
PointerMatrix
,
UiDirection
,
MouseButton
,
U
iElementInfo
,
Ui
EventObserver
}
from
'
@ohos.UiTest
'
;
import
{
UiComponent
,
UiDriver
,
Component
,
Driver
,
UiWindow
,
ON
,
BY
,
MatchPattern
,
DisplayRotation
,
ResizeDirection
,
WindowMode
,
PointerMatrix
,
UiDirection
,
MouseButton
,
U
IElementInfo
,
UI
EventObserver
}
from
'
@ohos.UiTest
'
;
```
## MatchPattern
...
...
@@ -141,7 +141,7 @@ import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern
| MOUSE_BUTTON_RIGHT | 1 | 鼠标右键。 |
| MOUSE_BUTTON_MIDDLE | 2 | 鼠标中间键。 |
## U
i
ElementInfo<sup>10+</sup>
## U
I
ElementInfo<sup>10+</sup>
UI事件的相关信息。
...
...
@@ -576,8 +576,8 @@ click(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -603,8 +603,8 @@ doubleClick(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -630,8 +630,8 @@ longClick(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -663,8 +663,8 @@ getId(): Promise\<string>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -696,8 +696,8 @@ getText(): Promise\<string>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -729,8 +729,8 @@ getType(): Promise\<string>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -762,8 +762,8 @@ getBounds(): Promise\<Rect>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -795,8 +795,8 @@ getBoundsCenter(): Promise\<Point>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -828,8 +828,8 @@ isClickable(): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -865,8 +865,8 @@ isLongClickable(): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -902,8 +902,8 @@ isChecked(): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -939,8 +939,8 @@ isCheckable(): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -976,8 +976,8 @@ isScrollable(): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1014,8 +1014,8 @@ isEnabled(): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1052,8 +1052,8 @@ isFocused(): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1089,8 +1089,8 @@ isSelected(): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1126,8 +1126,8 @@ inputText(text: string): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1151,8 +1151,8 @@ clearText(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1190,8 +1190,8 @@ scrollSearch(on: On): Promise\<Component>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1223,8 +1223,8 @@ scrollToTop(speed?: number): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1256,8 +1256,8 @@ scrollToBottom(speed?: number): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1289,8 +1289,8 @@ dragTo(target: Component): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1323,8 +1323,8 @@ pinchOut(scale: number): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1356,8 +1356,8 @@ pinchIn(scale: number): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -1424,7 +1424,7 @@ Driver对象在给定的时间内延时。
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1461,7 +1461,7 @@ findComponent(on: On): Promise\<Component>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1498,7 +1498,7 @@ findComponents(on: On): Promise\<Array\<Component>>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1535,7 +1535,7 @@ findWindow(filter: WindowFilter): Promise\<UiWindow>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1573,7 +1573,7 @@ waitForComponent(on: On, time: number): Promise\<Component>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1604,7 +1604,7 @@ assertComponentExist(on: On): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
| 17000003 | Component existence assertion failed. |
**示例:**
...
...
@@ -1630,7 +1630,7 @@ Driver对象进行点击BACK键的操作。
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1661,7 +1661,7 @@ Driver对象采取如下操作:传入key值实现模拟点击对应按键的
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1694,7 +1694,7 @@ Driver对象通过给定的key值,找到对应组合键并点击。例如,Ke
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1727,7 +1727,7 @@ Driver对象采取如下操作:在目标坐标点单击。
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1759,7 +1759,7 @@ Driver对象采取如下操作:在目标坐标点双击。
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1791,7 +1791,7 @@ Driver对象采取如下操作:在目标坐标点长按。
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1826,7 +1826,7 @@ Driver对象采取如下操作:从起始坐标点滑向目的坐标点。
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1861,7 +1861,7 @@ Driver对象采取如下操作:从起始坐标点拖拽至目的坐标点。
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1898,7 +1898,7 @@ Driver对象采取如下操作:捕获当前屏幕,并保存为PNG格式的
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1929,7 +1929,7 @@ setDisplayRotation(rotation: DisplayRotation): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1960,7 +1960,7 @@ getDisplayRotation(): Promise\<DisplayRotation>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -1991,7 +1991,7 @@ setDisplayRotationEnabled(enabled: boolean): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2022,7 +2022,7 @@ getDisplaySize(): Promise\<Point>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2053,7 +2053,7 @@ getDisplayDensity(): Promise\<Point>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2078,7 +2078,7 @@ wakeUpDisplay(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2103,7 +2103,7 @@ pressHome(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2141,7 +2141,7 @@ waitForIdle(idleTime: number, timeout: number): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2175,7 +2175,7 @@ fling(from: Point, to: Point, stepLen: number, speed: number): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2213,7 +2213,7 @@ injectMultiPointerAction(pointers: PointerMatrix, speed?: number): Promise\<bool
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2233,7 +2233,7 @@ async function demo() {
### fling<sup>10+</sup>
fling(direction: UiDirection, speed: number): Promise
<void>
;
fling(direction: UiDirection, speed: number): Promise
\
<
void>;
指定方向和速度,模拟手指滑动后脱离屏幕的快速滑动操作。
...
...
@@ -2252,7 +2252,7 @@ fling(direction: UiDirection, speed: number): Promise<void>;
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2265,7 +2265,7 @@ async function demo() {
### screenCapture<sup>10+</sup>
screenCapture(savePath: string, rect?: Rect): Promise
<boolean>
;
screenCapture(savePath: string, rect?: Rect): Promise
\
<
boolean>;
捕获当前屏幕的指定区域,并保存为PNG格式的图片至给出的保存路径中。
...
...
@@ -2290,7 +2290,7 @@ screenCapture(savePath: string, rect?: Rect): Promise<boolean>;
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2303,7 +2303,7 @@ async function demo() {
### mouseClick<sup>10+</sup>
mouseClick(p: Point, btnId: MouseButton, key1?: number, key2?: number): Promise
<void>
;
mouseClick(p: Point, btnId: MouseButton, key1?: number, key2?: number): Promise
\
<
void>;
在指定坐标点注入鼠标点击动作,支持同时按下对应键盘组合键。例如,Key值为2072时,按下ctrl并进行鼠标点击动作。
...
...
@@ -2315,7 +2315,7 @@ mouseClick(p: Point, btnId: MouseButton, key1?: number, key2?: number): Promise<
| ------ | ----------------------------- | ---- | ------------------- |
| p |
[
Point
](
#point9
)
| 是 | 鼠标点击的坐标。 |
| btnId |
[
MouseButton
](
#mousebutton10
)
| 是 | 按下的鼠标按钮。 |
| key1 | number |
是
| 指定的第一个key值。 |
| key1 | number |
否
| 指定的第一个key值。 |
| key2 | number | 否 | 指定的第二个key值。 |
**错误码:**
...
...
@@ -2324,7 +2324,7 @@ mouseClick(p: Point, btnId: MouseButton, key1?: number, key2?: number): Promise<
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2337,7 +2337,7 @@ async function demo() {
### mouseScroll<sup>10+</sup>
mouseScroll(p: Point, down: boolean, d: number, key1?: number, key2?: number): Promise
<void>
;
mouseScroll(p: Point, down: boolean, d: number, key1?: number, key2?: number): Promise
\
<
void>;
在指定坐标点注入鼠标滚轮滑动动作,支持同时按下对应键盘组合键。例如,Key值为2072时,按下ctrl并进行鼠标滚轮滑动动作。
...
...
@@ -2350,7 +2350,7 @@ mouseScroll(p: Point, down: boolean, d: number, key1?: number, key2?: number): P
| p |
[
Point
](
#point9
)
| 是 | 鼠标点击的坐标。 |
| down | boolean | 是 | 滚轮滑动方向是否向下。 |
| d | number | 是 | 鼠标滚轮滚动的格数,每格对应目标点位移120个像素点。 |
| key1 | number |
是
| 指定的第一个key值。 |
| key1 | number |
否
| 指定的第一个key值。 |
| key2 | number | 否 | 指定的第二个key值。 |
**错误码:**
...
...
@@ -2359,7 +2359,7 @@ mouseScroll(p: Point, down: boolean, d: number, key1?: number, key2?: number): P
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2372,7 +2372,7 @@ async function demo() {
### mouseMoveTo<sup>10+</sup>
mouseMoveTo(p: Point): Promise
<void>
;
mouseMoveTo(p: Point): Promise
\
<
void>;
将鼠标光标移到目标点。
...
...
@@ -2390,7 +2390,7 @@ mouseMoveTo(p: Point): Promise<void>;
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2401,9 +2401,9 @@ async function demo() {
}
```
### createU
i
EventObserver<sup>10+</sup>
### createU
I
EventObserver<sup>10+</sup>
createU
iEventObserver(): Ui
EventObserver;
createU
IEventObserver(): UI
EventObserver;
创建一个UI事件监听器。
...
...
@@ -2413,7 +2413,7 @@ createUiEventObserver(): UiEventObserver;
| 类型 | 说明 |
| ----------------------------------------------- | ------------------------------------- |
| Promise
\<
[
U
i
EventObserver
](
#uieventobserver10
)
> | 以Promise形式返回找到的目标窗口对象。 |
| Promise
\<
[
U
I
EventObserver
](
#uieventobserver10
)
> | 以Promise形式返回找到的目标窗口对象。 |
**错误码:**
...
...
@@ -2421,7 +2421,7 @@ createUiEventObserver(): UiEventObserver;
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000002 |
if the async function was not called with await
. |
**示例:**
...
...
@@ -2520,8 +2520,8 @@ getBundleName(): Promise\<string>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -2553,8 +2553,8 @@ getBounds(): Promise\<Rect>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -2586,8 +2586,8 @@ getTitle(): Promise\<string>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -2619,8 +2619,8 @@ getWindowMode(): Promise\<WindowMode>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -2652,8 +2652,8 @@ isFocused(): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -2685,8 +2685,8 @@ isActived(): Promise\<boolean>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -2712,8 +2712,8 @@ focus(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
**示例:**
...
...
@@ -2746,8 +2746,8 @@ moveTo(x: number, y: number): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
| 17000005 | This operation is not supported. |
**示例:**
...
...
@@ -2782,8 +2782,8 @@ resize(wide: number, height: number, direction: ResizeDirection): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
| 17000005 | This operation is not supported. |
**示例:**
...
...
@@ -2810,8 +2810,8 @@ split(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
| 17000005 | This operation is not supported. |
**示例:**
...
...
@@ -2838,8 +2838,8 @@ maximize(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
| 17000005 | This operation is not supported. |
**示例:**
...
...
@@ -2866,8 +2866,8 @@ minimize(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
| 17000005 | This operation is not supported. |
**示例:**
...
...
@@ -2894,8 +2894,8 @@ resume(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
| 17000005 | This operation is not supported. |
**示例:**
...
...
@@ -2922,8 +2922,8 @@ close(): Promise\<void>
| 错误码ID | 错误信息 |
| -------- | ---------------------------------------- |
| 17000002 |
API does not allow calling concurrently
. |
| 17000004 |
Component lost/UiWindow lost.
|
| 17000002 |
if the async function was not called with await
. |
| 17000004 |
if the component is invisible or destroyed.
|
| 17000005 | This operation is not supported. |
**示例:**
...
...
@@ -2936,38 +2936,64 @@ async function demo() {
}
```
## U
i
EventObserver<sup>10+</sup>
## U
I
EventObserver<sup>10+</sup>
UI事件监听器。
### once<sup>10+</sup>
### once
('toastShow')
<sup>10+</sup>
once(type: 'toastShow', callback: Callback
<UiElementInfo>
):
void;
once(type: 'toastShow', callback: Callback
\<
UIElementInfo>):
void;
once(type: 'dialogShow', callback: Callback
<UiElementInfo>
): void;
监听事件,事件发生时执行对应的回调方法。
开始监听toast控件出现的事件,使用callback的形式返回结果。
**系统能力**
:SystemCapability.Test.UiTest
**参数:**
| 参数名 | 类型
| 必填 | 说明
|
| -------- | -------------------------------------------
| ---- |
-------------------- |
| type | string
| 是 | 监听的事件名称
|
| callback | Callback
<
[
UiElementInfo
](
#uielementinfo10
)
>
| 是 | 事件发生时执行的回调
|
| 参数名 | 类型
| 必填 | 说明
|
| -------- | -------------------------------------------
- | ---- | -------------
-------------------- |
| type | string
| 是 | 订阅的事件类型,取值为'toastShow'
|
| callback | Callback
\<
[
UIElementInfo
](
#uielementinfo10
)
> | 是 | 事件发生时执行的回调函数
|
**示例:**
```
js
async
function
demo
()
{
let
observer
=
await
driver
.
createU
i
EventObserver
()
let
callback
=
(
U
i
ElementInfo
)
=>
{
console
.
info
(
U
i
ElementInfo
.
bundleName
)
console
.
info
(
U
i
ElementInfo
.
text
)
console
.
info
(
U
i
ElementInfo
.
type
)
let
observer
=
await
driver
.
createU
I
EventObserver
()
let
callback
=
(
U
I
ElementInfo
)
=>
{
console
.
info
(
U
I
ElementInfo
.
bundleName
)
console
.
info
(
U
I
ElementInfo
.
text
)
console
.
info
(
U
I
ElementInfo
.
type
)
}
observer
.
once
(
'
toastShow
'
,
callback
)
}
```
### once('dialogShow')<sup>10+</sup>
once(type: 'dialogShow', callback: Callback
\<
UIElementInfo>): void;
开始监听dialog控件出现的事件,使用callback的形式返回结果。
**系统能力**
:SystemCapability.Test.UiTest
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------- | ---- | ---------------------------------- |
| type | string | 是 | 订阅的事件类型,取值为'dialogShow' |
| callback | Callback
\<
[
UIElementInfo
](
#uielementinfo10
)
> | 是 | 事件发生时执行的回调函数 |
**示例:**
```
js
async
function
demo
()
{
let
observer
=
await
driver
.
createUIEventObserver
()
let
callback
=
(
UIElementInfo
)
=>
{
console
.
info
(
UIElementInfo
.
bundleName
)
console
.
info
(
UIElementInfo
.
text
)
console
.
info
(
UIElementInfo
.
type
)
}
observer
.
once
(
'
dialogShow
'
,
callback
)
}
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录