提交 df005cf6 编写于 作者: Z zhouke

modify.Signed-off-by: <zhouke35@huawei.com>.

Signed-off-by: Nzhouke <zhouke35@huawei.com>
上级 55b9befd
......@@ -20,7 +20,7 @@ UiTest提供模拟UI操作的能力,供开发者在测试场景使用,主要
## 导入模块
```js
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix, UiDirection, MouseButton, UiElementInfo, UiEventObserver} from '@ohos.UiTest';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix, UiDirection, MouseButton, UIElementInfo, UIEventObserver} 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 | 鼠标中间键。 |
## UiElementInfo<sup>10+</sup>
## UIElementInfo<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() {
}
```
### createUiEventObserver<sup>10+</sup>
### createUIEventObserver<sup>10+</sup>
createUiEventObserver(): UiEventObserver;
createUIEventObserver(): UIEventObserver;
创建一个UI事件监听器。
......@@ -2413,7 +2413,7 @@ createUiEventObserver(): UiEventObserver;
| 类型 | 说明 |
| ----------------------------------------------- | ------------------------------------- |
| Promise\<[UiEventObserver](#uieventobserver10)> | 以Promise形式返回找到的目标窗口对象。 |
| Promise\<[UIEventObserver](#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() {
}
```
## UiEventObserver<sup>10+</sup>
## UIEventObserver<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.createUiEventObserver()
let callback = (UiElementInfo)=>{
console.info(UiElementInfo.bundleName)
console.info(UiElementInfo.text)
console.info(UiElementInfo.type)
let observer = await driver.createUIEventObserver()
let callback = (UIElementInfo)=>{
console.info(UIElementInfo.bundleName)
console.info(UIElementInfo.text)
console.info(UIElementInfo.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.
先完成此消息的编辑!
想要评论请 注册