未验证 提交 059101aa 编写于 作者: O openharmony_ci 提交者: Gitee

!23988 【挑单Monthly分支】翻译完成...

!23988 【挑单Monthly分支】翻译完成 23661+23276+23354+23828+23377+23196+23630:自定义弹窗文档+js-apis-uitest.md整改+系统参数文档修改
Merge pull request !23988 from ester.zhou/M-0905
# @ohos.systemParameter (System Parameter) # @ohos.systemParameter (System Parameter)
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters. The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see
[Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md). For details about the system parameter design principles and definitions, see [Parameter Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
> **NOTE** > **NOTE**
> - The APIs of this module are no longer maintained since API version 9. It is recommended that you use [@ohos.systemParameterEnhance](js-apis-system-parameterEnhance.md) instead. > - The APIs of this module are no longer maintained since API version 9. It is recommended that you use [@ohos.systemParameterEnhance](js-apis-system-parameterEnhance.md) instead.
...@@ -14,7 +14,7 @@ For details about the system parameter design principles and definitions, see ...@@ -14,7 +14,7 @@ For details about the system parameter design principles and definitions, see
## Modules to Import ## Modules to Import
```ts ```ts
import systemparameter from '@ohos.systemparameter' import systemparameter from '@ohos.systemparameter';
``` ```
## systemparameter.getSync<sup>(deprecated)</sup> ## systemparameter.getSync<sup>(deprecated)</sup>
...@@ -30,19 +30,19 @@ Obtains the value of the system parameter with the specified key. ...@@ -30,19 +30,19 @@ Obtains the value of the system parameter with the specified key.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system parameter.| | key | string | Yes| Key of the system parameter.|
| def | string | No| Default value of the system parameter.<br>It works only when the system parameter does not exist.<br>The value can be **undefined** or any custom value. | | def | string | No| Default value of the system parameter.<br> It works only when the system parameter does not exist.<br>The value can be **undefined** or any custom value.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Value of the system parameter.<br>If the specified key exists, the set value is returned.<br>If the specified key does not exist and **def** is set to a valid value, the set value is returned. If the specified key does not exist and **def** is set to an invalid value (such as **undefined**) or is not set, an empty string is returned. | | string | Value of the system parameter.<br>If the specified key exists, the set value is returned.<br>If the specified key does not exist and **def** is set to a valid value, the set value is returned. If the specified key does not exist and **def** is set to an invalid value (such as **undefined**) or is not set, an empty string is returned.|
**Example** **Example**
```ts ```ts
try { try {
var info = systemparameter.getSync("const.ohos.apiversion"); let info = systemparameter.getSync("const.ohos.apiversion");
console.log(JSON.stringify(info)); console.log(JSON.stringify(info));
} catch(e) { } catch(e) {
console.log("getSync unexpected error: " + e); console.log("getSync unexpected error: " + e);
...@@ -67,8 +67,10 @@ Obtains the value of the system parameter with the specified key. This API uses ...@@ -67,8 +67,10 @@ Obtains the value of the system parameter with the specified key. This API uses
**Example** **Example**
```ts ```ts
import { BusinessError } from '@ohos.base';
try { try {
systemparameter.get("const.ohos.apiversion", function (err, data) { systemparameter.get("const.ohos.apiversion", (err: BusinessError, data: string) => {
if (err == undefined) { if (err == undefined) {
console.log("get test.parameter.key value success:" + data) console.log("get test.parameter.key value success:" + data)
} else { } else {
...@@ -98,8 +100,10 @@ Obtains the value of the system parameter with the specified key. This API uses ...@@ -98,8 +100,10 @@ Obtains the value of the system parameter with the specified key. This API uses
**Example** **Example**
```ts ```ts
import { BusinessError } from '@ohos.base';
try { try {
systemparameter.get("const.ohos.apiversion", "default", function (err, data) { systemparameter.get("const.ohos.apiversion", "default", (err: BusinessError, data: string) => {
if (err == undefined) { if (err == undefined) {
console.log("get test.parameter.key value success:" + data) console.log("get test.parameter.key value success:" + data)
} else { } else {
...@@ -124,7 +128,7 @@ Obtains the value of the system parameter with the specified key. This API uses ...@@ -124,7 +128,7 @@ Obtains the value of the system parameter with the specified key. This API uses
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system parameter.| | key | string | Yes| Key of the system parameter.|
| def | string | No| Default value of the system parameter.<br>It works only when the system parameter does not exist.<br>The value can be **undefined** or any custom value. | | def | string | No| Default value of the system parameter.<br> It works only when the system parameter does not exist.<br> The value can be **undefined** or any custom value.|
**Return value** **Return value**
...@@ -135,11 +139,13 @@ Obtains the value of the system parameter with the specified key. This API uses ...@@ -135,11 +139,13 @@ Obtains the value of the system parameter with the specified key. This API uses
**Example** **Example**
```ts ```ts
import { BusinessError } from '@ohos.base';
try { try {
var p = systemparameter.get("const.ohos.apiversion"); let p = systemparameter.get("const.ohos.apiversion");
p.then(function (value) { p.then((value: string) => {
console.log("get test.parameter.key success: " + value); console.log("get test.parameter.key success: " + value);
}).catch(function (err) { }).catch((err: BusinessError) => {
console.log("get test.parameter.key error: " + err.code); console.log("get test.parameter.key error: " + err.code);
}); });
} catch(e) { } catch(e) {
...@@ -200,8 +206,10 @@ Sets a value for the system parameter with the specified key. This API uses an a ...@@ -200,8 +206,10 @@ Sets a value for the system parameter with the specified key. This API uses an a
**Example** **Example**
```ts ```ts
import { BusinessError } from '@ohos.base';
try { try {
systemparameter.set("test.parameter.key", "testValue", function (err, data) { systemparameter.set("test.parameter.key", "testValue", (err: BusinessError, data: void) =>{
if (err == undefined) { if (err == undefined) {
console.log("set test.parameter.key value success :" + data) console.log("set test.parameter.key value success :" + data)
} else { } else {
...@@ -240,11 +248,13 @@ Sets a value for the system parameter with the specified key. This API uses a pr ...@@ -240,11 +248,13 @@ Sets a value for the system parameter with the specified key. This API uses a pr
**Example** **Example**
```ts ```ts
import { BusinessError } from '@ohos.base';
try { try {
var p = systemparameter.set("test.parameter.key", "testValue"); let p = systemparameter.set("test.parameter.key", "testValue");
p.then(function (value) { p.then((value: void) => {
console.log("set test.parameter.key success: " + value); console.log("set test.parameter.key success: " + value);
}).catch(function (err) { }).catch((err: BusinessError) => {
console.log(" set test.parameter.key error: " + err.code); console.log(" set test.parameter.key error: " + err.code);
}); });
} catch(e) { } catch(e) {
......
# @ohos.systemParameterEnhance (System Parameter) # @ohos.systemParameterEnhance (System Parameter)
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters. The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see
[Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md). For details about the system parameter design principles and definitions, see [Parameter Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
> **NOTE** > **NOTE**
> >
...@@ -13,7 +13,7 @@ For details about the system parameter design principles and definitions, see ...@@ -13,7 +13,7 @@ For details about the system parameter design principles and definitions, see
## Modules to Import ## Modules to Import
```ts ```ts
import systemparameter from '@ohos.systemParameterEnhance' import systemparameter from '@ohos.systemParameterEnhance';
``` ```
## systemparameter.getSync ## systemparameter.getSync
...@@ -29,19 +29,30 @@ Obtains the value of the system parameter with the specified key. ...@@ -29,19 +29,30 @@ Obtains the value of the system parameter with the specified key.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system parameter.| | key | string | Yes| Key of the system parameter.|
| def | string | No| Default value of the system parameter.<br>It works only when the system parameter does not exist.<br>The value can be **undefined** or any custom value. | | def | string | No| Default value of the system parameter.<br> It works only when the system parameter does not exist.<br> The value can be **undefined** or any custom value.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Value of the system parameter.<br>If the specified key exists, the set value is returned.<br>If the specified key does not exist and **def** is set to a valid value, the set value is returned. If the specified key does not exist and **def** is set to an invalid value (such as **undefined**) or is not set, an exception is thrown. | | string | Value of the system parameter.<br> If the specified key exists, the set value is returned.<br> If the specified key does not exist and **def** is set to a valid value, the set value is returned. If the specified key does not exist and **def** is set to an invalid value (such as **undefined**) or is not set, an exception is thrown.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700101 | System parameter can not be found. |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example** **Example**
```ts ```ts
try { try {
var info = systemparameter.getSync("const.ohos.apiversion"); let info = systemparameter.getSync("const.ohos.apiversion");
console.log(JSON.stringify(info)); console.log(JSON.stringify(info));
} catch(e) { } catch(e) {
console.log("getSync unexpected error: " + e); console.log("getSync unexpected error: " + e);
...@@ -63,11 +74,24 @@ Obtains the value of the system parameter with the specified key. ...@@ -63,11 +74,24 @@ Obtains the value of the system parameter with the specified key.
| key | string | Yes| Key of the system parameter.| | key | string | Yes| Key of the system parameter.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700101 | System parameter can not be found. |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example** **Example**
```ts ```ts
import { BusinessError } from '@ohos.base';
try { try {
systemparameter.get("const.ohos.apiversion", function (err, data) { systemparameter.get("const.ohos.apiversion", (err: BusinessError, data: string) => {
if (err == undefined) { if (err == undefined) {
console.log("get test.parameter.key value success:" + data) console.log("get test.parameter.key value success:" + data)
} else { } else {
...@@ -94,11 +118,24 @@ Obtains the value of the system parameter with the specified key. This API uses ...@@ -94,11 +118,24 @@ Obtains the value of the system parameter with the specified key. This API uses
| def | string | Yes| Default value.| | def | string | Yes| Default value.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700101 | System parameter can not be found. |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example** **Example**
```ts ```ts
import { BusinessError } from '@ohos.base';
try { try {
systemparameter.get("const.ohos.apiversion", "default", function (err, data) { systemparameter.get("const.ohos.apiversion", "default", (err: BusinessError, data: string) => {
if (err == undefined) { if (err == undefined) {
console.log("get test.parameter.key value success:" + data) console.log("get test.parameter.key value success:" + data)
} else { } else {
...@@ -123,7 +160,7 @@ Obtains the value of the system parameter with the specified key. This API uses ...@@ -123,7 +160,7 @@ Obtains the value of the system parameter with the specified key. This API uses
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system parameter.| | key | string | Yes| Key of the system parameter.|
| def | string | No| Default value of the system parameter.<br>It works only when the system parameter does not exist.<br>The value can be **undefined** or any custom value. | | def | string | No| Default value of the system parameter.<br> It works only when the system parameter does not exist.<br> The value can be **undefined** or any custom value.|
**Return value** **Return value**
...@@ -131,14 +168,27 @@ Obtains the value of the system parameter with the specified key. This API uses ...@@ -131,14 +168,27 @@ Obtains the value of the system parameter with the specified key. This API uses
| -------- | -------- | | -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the execution result.| | Promise&lt;string&gt; | Promise used to return the execution result.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700101 | System parameter can not be found. |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example** **Example**
```ts ```ts
import { BusinessError } from '@ohos.base';
try { try {
var p = systemparameter.get("const.ohos.apiversion"); let p = systemparameter.get("const.ohos.apiversion");
p.then(function (value) { p.then((value: string) => {
console.log("get test.parameter.key success: " + value); console.log("get test.parameter.key success: " + value);
}).catch(function (err) { }).catch((err: BusinessError) => {
console.log("get test.parameter.key error: " + err.code); console.log("get test.parameter.key error: " + err.code);
}); });
} catch(e) { } catch(e) {
...@@ -161,9 +211,21 @@ Sets a value for the system parameter with the specified key. ...@@ -161,9 +211,21 @@ Sets a value for the system parameter with the specified key.
| key | string | Yes| Key of the system parameter.| | key | string | Yes| Key of the system parameter.|
| value | string | Yes| Value of the system parameter to set.| | value | string | Yes| Value of the system parameter to set.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example** **Example**
```ts ```ts
import { BusinessError } from '@ohos.base';
try { try {
systemparameter.setSync("test.parameter.key", "default"); systemparameter.setSync("test.parameter.key", "default");
} catch(e) { } catch(e) {
...@@ -187,11 +249,23 @@ Sets a value for the system parameter with the specified key. This API uses an a ...@@ -187,11 +249,23 @@ Sets a value for the system parameter with the specified key. This API uses an a
| value | string | Yes| Value of the system parameter to set.| | value | string | Yes| Value of the system parameter to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example** **Example**
```ts ```ts
import { BusinessError } from '@ohos.base';
try { try {
systemparameter.set("test.parameter.key", "testValue", function (err, data) { systemparameter.set("test.parameter.key", "testValue", (err: BusinessError, data: void) => {
if (err == undefined) { if (err == undefined) {
console.log("set test.parameter.key value success :" + data) console.log("set test.parameter.key value success :" + data)
} else { } else {
...@@ -223,14 +297,26 @@ Sets a value for the system parameter with the specified key. This API uses a pr ...@@ -223,14 +297,26 @@ Sets a value for the system parameter with the specified key. This API uses a pr
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise used to return the execution result.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example** **Example**
```ts ```ts
import { BusinessError } from '@ohos.base';
try { try {
var p = systemparameter.set("test.parameter.key", "testValue"); let p = systemparameter.set("test.parameter.key", "testValue");
p.then(function (value) { p.then((value: void) => {
console.log("set test.parameter.key success: " + value); console.log("set test.parameter.key success: " + value);
}).catch(function (err) { }).catch((err: BusinessError) => {
console.log(" set test.parameter.key error: " + err.code); console.log(" set test.parameter.key error: " + err.code);
}); });
} catch(e) { } catch(e) {
......
...@@ -19,7 +19,7 @@ This module provides the following functions: ...@@ -19,7 +19,7 @@ This module provides the following functions:
## Modules to Import ## Modules to Import
```js ```ts
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';
``` ```
...@@ -165,7 +165,8 @@ The API capabilities provided by the **On** class exhibit the following features ...@@ -165,7 +165,8 @@ The API capabilities provided by the **On** class exhibit the following features
All APIs provided in the **On** class are synchronous. You are advised to use the static constructor **ON** to create an **On** object in chain mode. All APIs provided in the **On** class are synchronous. You are advised to use the static constructor **ON** to create an **On** object in chain mode.
```js ```ts
import { ON } from '@ohos.UiTest';
ON.text('123').type('button'); ON.text('123').type('button');
``` ```
...@@ -192,11 +193,11 @@ Specifies the text attribute of the target component. Multiple match patterns ar ...@@ -192,11 +193,11 @@ Specifies the text attribute of the target component. Multiple match patterns ar
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.text('123'); // Use the static constructor ON to create an On object and specify the text attribute of the target component. let on = ON.text('123'); // Use the static constructor ON to create an On object and specify the text attribute of the target component.
``` ```
### id<sup>9+</sup> ### id<sup>9+</sup>
id(id: string): On id(id: string): On
...@@ -219,7 +220,8 @@ Specifies the ID attribute of the target component. ...@@ -219,7 +220,8 @@ Specifies the ID attribute of the target component.
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.id('123'); // Use the static constructor ON to create an On object and specify the ID attribute of the target component. let on = ON.id('123'); // Use the static constructor ON to create an On object and specify the ID attribute of the target component.
``` ```
...@@ -246,7 +248,8 @@ Specifies the type attribute of the target component. ...@@ -246,7 +248,8 @@ Specifies the type attribute of the target component.
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.type('button'); // Use the static constructor ON to create an On object and specify the type attribute of the target component. let on = ON.type('button'); // Use the static constructor ON to create an On object and specify the type attribute of the target component.
``` ```
...@@ -273,7 +276,8 @@ Specifies the clickable status attribute of the target component. ...@@ -273,7 +276,8 @@ Specifies the clickable status attribute of the target component.
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.clickable(true); // Use the static constructor ON to create an On object and specify the clickable status attribute of the target component. let on = ON.clickable(true); // Use the static constructor ON to create an On object and specify the clickable status attribute of the target component.
``` ```
...@@ -299,7 +303,8 @@ Specifies the long-clickable status attribute of the target component. ...@@ -299,7 +303,8 @@ Specifies the long-clickable status attribute of the target component.
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.longClickable(true); // Use the static constructor ON to create an On object and specify the long-clickable status attribute of the target component. let on = ON.longClickable(true); // Use the static constructor ON to create an On object and specify the long-clickable status attribute of the target component.
``` ```
...@@ -326,7 +331,8 @@ Specifies the scrollable status attribute of the target component. ...@@ -326,7 +331,8 @@ Specifies the scrollable status attribute of the target component.
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.scrollable(true); // Use the static constructor ON to create an On object and specify the scrollable status attribute of the target component. let on = ON.scrollable(true); // Use the static constructor ON to create an On object and specify the scrollable status attribute of the target component.
``` ```
...@@ -352,7 +358,8 @@ Specifies the enabled status attribute of the target component. ...@@ -352,7 +358,8 @@ Specifies the enabled status attribute of the target component.
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.enabled(true); // Use the static constructor ON to create an On object and specify the enabled status attribute of the target component. let on = ON.enabled(true); // Use the static constructor ON to create an On object and specify the enabled status attribute of the target component.
``` ```
...@@ -378,7 +385,8 @@ Specifies the focused status attribute of the target component. ...@@ -378,7 +385,8 @@ Specifies the focused status attribute of the target component.
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.focused(true); // Use the static constructor ON to create an On object and specify the focused status attribute of the target component. let on = ON.focused(true); // Use the static constructor ON to create an On object and specify the focused status attribute of the target component.
``` ```
...@@ -404,7 +412,8 @@ Specifies the selected status attribute of the target component. ...@@ -404,7 +412,8 @@ Specifies the selected status attribute of the target component.
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.selected(true); // Use the static constructor ON to create an On object and specify the selected status attribute of the target component. let on = ON.selected(true); // Use the static constructor ON to create an On object and specify the selected status attribute of the target component.
``` ```
...@@ -430,7 +439,8 @@ Specifies the checked status attribute of the target component. ...@@ -430,7 +439,8 @@ Specifies the checked status attribute of the target component.
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.checked(true); // Use the static constructor ON to create an On object and specify the checked status attribute of the target component. let on = ON.checked(true); // Use the static constructor ON to create an On object and specify the checked status attribute of the target component.
``` ```
...@@ -456,7 +466,8 @@ Specifies the checkable status attribute of the target component. ...@@ -456,7 +466,8 @@ Specifies the checkable status attribute of the target component.
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.checkable(true); // Use the static constructor ON to create an On object and specify the checkable status attribute of the target component. let on = ON.checkable(true); // Use the static constructor ON to create an On object and specify the checkable status attribute of the target component.
``` ```
...@@ -482,7 +493,8 @@ Specifies that the target component is located before the given attribute compon ...@@ -482,7 +493,8 @@ Specifies that the target component is located before the given attribute compon
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.isBefore(ON.text('123')); // Create an On object using the static constructor ON, specifying that the target component is located before the given attribute component. let on = ON.isBefore(ON.text('123')); // Create an On object using the static constructor ON, specifying that the target component is located before the given attribute component.
``` ```
...@@ -508,7 +520,8 @@ Specifies that the target component is located after the given attribute compone ...@@ -508,7 +520,8 @@ Specifies that the target component is located after the given attribute compone
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.isAfter(ON.text('123')); // Create an On object using the static constructor ON, specifying that the target component is located after the given attribute component. let on = ON.isAfter(ON.text('123')); // Create an On object using the static constructor ON, specifying that the target component is located after the given attribute component.
``` ```
...@@ -534,7 +547,8 @@ Specifies that the target component is located within the given attribute compon ...@@ -534,7 +547,8 @@ Specifies that the target component is located within the given attribute compon
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.within(ON.type('List')); // Create an On object using the static constructor ON, specifying that the target component is located within the given attribute component. let on = ON.within(ON.type('List')); // Create an On object using the static constructor ON, specifying that the target component is located within the given attribute component.
``` ```
...@@ -560,7 +574,8 @@ Specifies that the target component is located within the given application wind ...@@ -560,7 +574,8 @@ Specifies that the target component is located within the given application wind
**Example** **Example**
```js ```ts
import { ON } from '@ohos.UiTest';
let on = ON.inWindow('com.uitestScene.acts'); // Create an On object using the static constructor ON, specifying that the target component is located within the given application window. let on = ON.inWindow('com.uitestScene.acts'); // Create an On object using the static constructor ON, specifying that the target component is located within the given application window.
``` ```
...@@ -589,7 +604,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -589,7 +604,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -616,7 +632,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -616,7 +632,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -643,7 +660,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -643,7 +660,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -676,7 +694,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -676,7 +694,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -709,7 +728,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -709,7 +728,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -742,7 +762,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -742,7 +762,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -775,7 +796,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -775,7 +796,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -808,7 +830,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -808,7 +830,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -841,7 +864,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -841,7 +864,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -855,7 +879,7 @@ async function demo() { ...@@ -855,7 +879,7 @@ async function demo() {
### isLongClickable<sup>9+</sup> ### isLongClickable<sup>9+</sup>
isLongClickable(): Promise\<boolean> isLongClickable(): Promise\<boolean>
Obtains the long-clickable status of this component. Obtains the long-clickable status of this component.
...@@ -878,7 +902,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -878,7 +902,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -915,7 +940,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -915,7 +940,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let checkBox = await driver.findComponent(ON.type('Checkbox')); let checkBox = await driver.findComponent(ON.type('Checkbox'));
...@@ -952,7 +978,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -952,7 +978,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let checkBox = await driver.findComponent(ON.type('Checkbox')); let checkBox = await driver.findComponent(ON.type('Checkbox'));
...@@ -989,7 +1016,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -989,7 +1016,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let scrollBar = await driver.findComponent(ON.scrollable(true)); let scrollBar = await driver.findComponent(ON.scrollable(true));
...@@ -1027,7 +1055,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1027,7 +1055,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -1065,7 +1094,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1065,7 +1094,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -1102,7 +1132,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1102,7 +1132,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -1139,7 +1170,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1139,7 +1170,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let text = await driver.findComponent(ON.text('hello world')); let text = await driver.findComponent(ON.text('hello world'));
...@@ -1164,7 +1196,8 @@ Clears text in this component. This API is applicable to text boxes. ...@@ -1164,7 +1196,8 @@ Clears text in this component. This API is applicable to text boxes.
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let text = await driver.findComponent(ON.text('hello world')); let text = await driver.findComponent(ON.text('hello world'));
...@@ -1203,7 +1236,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1203,7 +1236,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let scrollBar = await driver.findComponent(ON.type('Scroll')); let scrollBar = await driver.findComponent(ON.type('Scroll'));
...@@ -1236,7 +1270,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1236,7 +1270,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let scrollBar = await driver.findComponent(ON.type('Scroll')); let scrollBar = await driver.findComponent(ON.type('Scroll'));
...@@ -1269,7 +1304,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1269,7 +1304,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let scrollBar = await driver.findComponent(ON.type('Scroll')); let scrollBar = await driver.findComponent(ON.type('Scroll'));
...@@ -1302,7 +1338,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1302,7 +1338,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.type('button')); let button = await driver.findComponent(ON.type('button'));
...@@ -1336,7 +1373,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1336,7 +1373,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let image = await driver.findComponent(ON.type('image')); let image = await driver.findComponent(ON.type('image'));
...@@ -1369,7 +1407,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1369,7 +1407,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let image = await driver.findComponent(ON.type('image')); let image = await driver.findComponent(ON.type('image'));
...@@ -1407,7 +1446,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1407,7 +1446,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
} }
...@@ -1437,7 +1477,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1437,7 +1477,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.delayMs(1000); await driver.delayMs(1000);
...@@ -1474,7 +1515,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1474,7 +1515,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.findComponent(ON.text('next page')); let button = await driver.findComponent(ON.text('next page'));
...@@ -1511,7 +1553,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1511,7 +1553,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let buttonList = await driver.findComponents(ON.text('next page')); let buttonList = await driver.findComponents(ON.text('next page'));
...@@ -1548,7 +1591,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1548,7 +1591,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -1586,7 +1630,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1586,7 +1630,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let button = await driver.waitForComponent(ON.text('next page'),500); let button = await driver.waitForComponent(ON.text('next page'),500);
...@@ -1618,7 +1663,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1618,7 +1663,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ON } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.assertComponentExist(ON.text('next page')); await driver.assertComponentExist(ON.text('next page'));
...@@ -1643,7 +1689,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1643,7 +1689,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.pressBack(); await driver.pressBack();
...@@ -1674,7 +1721,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1674,7 +1721,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.triggerKey(123); await driver.triggerKey(123);
...@@ -1707,7 +1755,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1707,7 +1755,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.triggerCombineKeys(2072, 2047, 2035); await driver.triggerCombineKeys(2072, 2047, 2035);
...@@ -1740,7 +1789,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1740,7 +1789,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.click(100,100); await driver.click(100,100);
...@@ -1772,7 +1822,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1772,7 +1822,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.doubleClick(100,100); await driver.doubleClick(100,100);
...@@ -1804,7 +1855,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1804,7 +1855,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.longClick(100,100); await driver.longClick(100,100);
...@@ -1839,7 +1891,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1839,7 +1891,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.swipe(100,100,200,200,600); await driver.swipe(100,100,200,200,600);
...@@ -1874,7 +1927,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1874,7 +1927,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.drag(100,100,200,200,600); await driver.drag(100,100,200,200,600);
...@@ -1911,7 +1965,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1911,7 +1965,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.screenCap('/data/storage/el2/base/cache/1.png'); await driver.screenCap('/data/storage/el2/base/cache/1.png');
...@@ -1942,7 +1997,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1942,7 +1997,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, DisplayRotation } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.setDisplayRotation(DisplayRotation.ROTATION_180); await driver.setDisplayRotation(DisplayRotation.ROTATION_180);
...@@ -1973,7 +2029,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -1973,7 +2029,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let rotation = await driver.getDisplayRotation(); let rotation = await driver.getDisplayRotation();
...@@ -2004,7 +2061,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2004,7 +2061,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.setDisplayRotationEnabled(false); await driver.setDisplayRotationEnabled(false);
...@@ -2035,7 +2093,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2035,7 +2093,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let size = await driver.getDisplaySize(); let size = await driver.getDisplaySize();
...@@ -2066,7 +2125,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2066,7 +2125,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let density = await driver.getDisplayDensity(); let density = await driver.getDisplayDensity();
...@@ -2091,7 +2151,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2091,7 +2151,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.wakeUpDisplay(); await driver.wakeUpDisplay();
...@@ -2116,7 +2177,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2116,7 +2177,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.pressHome(); await driver.pressHome();
...@@ -2154,7 +2216,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2154,7 +2216,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let idled = await driver.waitForIdle(4000,5000); let idled = await driver.waitForIdle(4000,5000);
...@@ -2188,7 +2251,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2188,7 +2251,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.fling({x: 500, y: 480},{x: 450, y: 480},5,600); await driver.fling({x: 500, y: 480},{x: 450, y: 480},5,600);
...@@ -2226,7 +2290,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2226,7 +2290,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, PointerMatrix } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let pointers = PointerMatrix.create(2,3); let pointers = PointerMatrix.create(2,3);
...@@ -2265,7 +2330,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2265,7 +2330,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, UiDirection } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.fling(UiDirection.DOWN, 10000); await driver.fling(UiDirection.DOWN, 10000);
...@@ -2303,7 +2369,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2303,7 +2369,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.screenCapture('/data/storage/el2/base/cache/1.png', {left: 0, top: 0, right: 100, bottom: 100}); await driver.screenCapture('/data/storage/el2/base/cache/1.png', {left: 0, top: 0, right: 100, bottom: 100});
...@@ -2337,7 +2404,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2337,7 +2404,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver,MouseButton } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.mouseClick({x:248, y:194}, MouseButton.MOUSE_BUTTON_LEFT, 2072); await driver.mouseClick({x:248, y:194}, MouseButton.MOUSE_BUTTON_LEFT, 2072);
...@@ -2372,7 +2440,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2372,7 +2440,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.mouseScroll({x:360, y:640}, true, 30, 2072) await driver.mouseScroll({x:360, y:640}, true, 30, 2072)
...@@ -2403,7 +2472,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2403,7 +2472,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
await driver.mouseMoveTo({x:100, y:100}) await driver.mouseMoveTo({x:100, y:100})
...@@ -2434,7 +2504,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2434,7 +2504,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let observer = await driver.createUIEventObserver() let observer = await driver.createUIEventObserver()
...@@ -2468,7 +2539,8 @@ Creates a **PointerMatrix** object and returns the object created. This API is a ...@@ -2468,7 +2539,8 @@ Creates a **PointerMatrix** object and returns the object created. This API is a
**Example** **Example**
```js ```ts
import { PointerMatrix } from '@ohos.UiTest';
async function demo() { async function demo() {
let pointerMatrix = PointerMatrix.create(2,3); let pointerMatrix = PointerMatrix.create(2,3);
} }
...@@ -2492,7 +2564,8 @@ Sets the coordinates for the action corresponding to the specified finger and st ...@@ -2492,7 +2564,8 @@ Sets the coordinates for the action corresponding to the specified finger and st
**Example** **Example**
```js ```ts
import { PointerMatrix } from '@ohos.UiTest';
async function demo() { async function demo() {
let pointers = PointerMatrix.create(2,3); let pointers = PointerMatrix.create(2,3);
pointers.setPoint(0,0,{x:230,y:480}); pointers.setPoint(0,0,{x:230,y:480});
...@@ -2535,7 +2608,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2535,7 +2608,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2568,7 +2642,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2568,7 +2642,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2601,7 +2676,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2601,7 +2676,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2634,7 +2710,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2634,7 +2710,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2667,7 +2744,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2667,7 +2744,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2700,7 +2778,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2700,7 +2778,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2727,7 +2806,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2727,7 +2806,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2762,7 +2842,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2762,7 +2842,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2798,7 +2879,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2798,7 +2879,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver, ResizeDirection } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2826,7 +2908,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2826,7 +2908,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2854,7 +2937,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2854,7 +2937,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2882,7 +2966,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2882,7 +2966,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2910,7 +2995,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2910,7 +2995,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2938,7 +3024,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc ...@@ -2938,7 +3024,8 @@ For details about the error codes, see [UiTest Error Codes](../errorcodes/errorc
**Example** **Example**
```js ```ts
import { Driver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let window = await driver.findWindow({actived: true}); let window = await driver.findWindow({actived: true});
...@@ -2967,11 +3054,12 @@ Subscribes to events of the toast component. This API uses a callback to return ...@@ -2967,11 +3054,12 @@ Subscribes to events of the toast component. This API uses a callback to return
**Example** **Example**
```js ```ts
import { Driver, UIElementInfo } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let observer = await driver.createUIEventObserver() let observer = await driver.createUIEventObserver()
let callback = (UIElementInfo)=>{ let callback = (UIElementInfo: UIElementInfo)=>{
console.info(UIElementInfo.bundleName) console.info(UIElementInfo.bundleName)
console.info(UIElementInfo.text) console.info(UIElementInfo.text)
console.info(UIElementInfo.type) console.info(UIElementInfo.type)
...@@ -2997,11 +3085,12 @@ Subscribes to events of the dialog component. This API uses a callback to return ...@@ -2997,11 +3085,12 @@ Subscribes to events of the dialog component. This API uses a callback to return
**Example** **Example**
```js ```ts
import { Driver, UIElementInfo } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = Driver.create(); let driver = Driver.create();
let observer = await driver.createUIEventObserver() let observer = await driver.createUIEventObserver()
let callback = (UIElementInfo)=>{ let callback = (UIElementInfo: UIElementInfo)=>{
console.info(UIElementInfo.bundleName) console.info(UIElementInfo.bundleName)
console.info(UIElementInfo.text) console.info(UIElementInfo.text)
console.info(UIElementInfo.type) console.info(UIElementInfo.type)
...@@ -3024,7 +3113,8 @@ All APIs provided in the **By** class are synchronous. You are advised to use th ...@@ -3024,7 +3113,8 @@ All APIs provided in the **By** class are synchronous. You are advised to use th
This class is deprecated since API version 9. You are advised to use [On<sup>9+</sup>](#on9) instead. This class is deprecated since API version 9. You are advised to use [On<sup>9+</sup>](#on9) instead.
```js ```ts
import { BY } from '@ohos.UiTest';
BY.text('123').type('button'); BY.text('123').type('button');
``` ```
...@@ -3053,7 +3143,8 @@ This API is deprecated since API version 9. You are advised to use [text<sup>9+< ...@@ -3053,7 +3143,8 @@ This API is deprecated since API version 9. You are advised to use [text<sup>9+<
**Example** **Example**
```js ```ts
import { BY } from '@ohos.UiTest';
let by = BY.text('123'); // Use the static constructor BY to create a By object and specify the text attribute of the target component. let by = BY.text('123'); // Use the static constructor BY to create a By object and specify the text attribute of the target component.
``` ```
...@@ -3082,7 +3173,8 @@ This API is deprecated since API version 9. You are advised to use [id<sup>9+</s ...@@ -3082,7 +3173,8 @@ This API is deprecated since API version 9. You are advised to use [id<sup>9+</s
**Example** **Example**
```js ```ts
import { BY } from '@ohos.UiTest';
let by = BY.key('123'); // Use the static constructor BY to create a By object and specify the key attribute of the target component. let by = BY.key('123'); // Use the static constructor BY to create a By object and specify the key attribute of the target component.
``` ```
...@@ -3111,7 +3203,8 @@ This API is deprecated since API version 9. ...@@ -3111,7 +3203,8 @@ This API is deprecated since API version 9.
**Example** **Example**
```js ```ts
import { BY } from '@ohos.UiTest';
let by = BY.id(123); // Use the static constructor BY to create a By object and specify the ID attribute of the target component. let by = BY.id(123); // Use the static constructor BY to create a By object and specify the ID attribute of the target component.
``` ```
...@@ -3140,7 +3233,8 @@ This API is deprecated since API version 9. You are advised to use [type<sup>9+< ...@@ -3140,7 +3233,8 @@ This API is deprecated since API version 9. You are advised to use [type<sup>9+<
**Example** **Example**
```js ```ts
import { BY } from '@ohos.UiTest';
let by = BY.type('button'); // Use the static constructor BY to create a By object and specify the type attribute of the target component. let by = BY.type('button'); // Use the static constructor BY to create a By object and specify the type attribute of the target component.
``` ```
...@@ -3169,7 +3263,8 @@ This API is deprecated since API version 9. You are advised to use [clickable<su ...@@ -3169,7 +3263,8 @@ This API is deprecated since API version 9. You are advised to use [clickable<su
**Example** **Example**
```js ```ts
import { BY } from '@ohos.UiTest';
let by = BY.clickable(true); // Use the static constructor BY to create a By object and specify the clickable status attribute of the target component. let by = BY.clickable(true); // Use the static constructor BY to create a By object and specify the clickable status attribute of the target component.
``` ```
...@@ -3198,7 +3293,8 @@ This API is deprecated since API version 9. You are advised to use [scrollable<s ...@@ -3198,7 +3293,8 @@ This API is deprecated since API version 9. You are advised to use [scrollable<s
**Example** **Example**
```js ```ts
import { BY } from '@ohos.UiTest';
let by = BY.scrollable(true); // Use the static constructor BY to create a By object and specify the scrollable status attribute of the target component. let by = BY.scrollable(true); // Use the static constructor BY to create a By object and specify the scrollable status attribute of the target component.
``` ```
...@@ -3226,7 +3322,8 @@ This API is deprecated since API version 9. You are advised to use [enabled<sup> ...@@ -3226,7 +3322,8 @@ This API is deprecated since API version 9. You are advised to use [enabled<sup>
**Example** **Example**
```js ```ts
import { BY } from '@ohos.UiTest';
let by = BY.enabled(true); // Use the static constructor BY to create a By object and specify the enabled status attribute of the target component. let by = BY.enabled(true); // Use the static constructor BY to create a By object and specify the enabled status attribute of the target component.
``` ```
...@@ -3254,7 +3351,8 @@ This API is deprecated since API version 9. You are advised to use [focused<sup> ...@@ -3254,7 +3351,8 @@ This API is deprecated since API version 9. You are advised to use [focused<sup>
**Example** **Example**
```js ```ts
import { BY } from '@ohos.UiTest';
let by = BY.focused(true); // Use the static constructor BY to create a By object and specify the focused status attribute of the target component. let by = BY.focused(true); // Use the static constructor BY to create a By object and specify the focused status attribute of the target component.
``` ```
...@@ -3282,7 +3380,8 @@ This API is deprecated since API version 9. You are advised to use [selected<sup ...@@ -3282,7 +3380,8 @@ This API is deprecated since API version 9. You are advised to use [selected<sup
**Example** **Example**
```js ```ts
import { BY } from '@ohos.UiTest';
let by = BY.selected(true); // Use the static constructor BY to create a By object and specify the selected status attribute of the target component. let by = BY.selected(true); // Use the static constructor BY to create a By object and specify the selected status attribute of the target component.
``` ```
...@@ -3310,7 +3409,8 @@ This API is deprecated since API version 9. You are advised to use [isBefore<sup ...@@ -3310,7 +3409,8 @@ This API is deprecated since API version 9. You are advised to use [isBefore<sup
**Example** **Example**
```js ```ts
import { BY } from '@ohos.UiTest';
let by = BY.isBefore(BY.text('123')); // Use the static constructor BY to create a By object, specifying that the target component is located before the given attribute component. let by = BY.isBefore(BY.text('123')); // Use the static constructor BY to create a By object, specifying that the target component is located before the given attribute component.
``` ```
...@@ -3338,7 +3438,8 @@ This API is deprecated since API version 9. You are advised to use [isAfter<sup> ...@@ -3338,7 +3438,8 @@ This API is deprecated since API version 9. You are advised to use [isAfter<sup>
**Example** **Example**
```js ```ts
import { BY } from '@ohos.UiTest';
let by = BY.isAfter(BY.text('123')); // Use the static constructor BY to create a By object, specifying that the target component is located after the given attribute component. let by = BY.isAfter(BY.text('123')); // Use the static constructor BY to create a By object, specifying that the target component is located after the given attribute component.
``` ```
...@@ -3362,7 +3463,8 @@ This API is deprecated since API version 9. You are advised to use [click<sup>9+ ...@@ -3362,7 +3463,8 @@ This API is deprecated since API version 9. You are advised to use [click<sup>9+
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.type('button')); let button = await driver.findComponent(BY.type('button'));
...@@ -3382,7 +3484,8 @@ This API is deprecated since API version 9. You are advised to use [doubleClick< ...@@ -3382,7 +3484,8 @@ This API is deprecated since API version 9. You are advised to use [doubleClick<
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.type('button')); let button = await driver.findComponent(BY.type('button'));
...@@ -3402,7 +3505,8 @@ This API is deprecated since API version 9. You are advised to use [longClick<su ...@@ -3402,7 +3505,8 @@ This API is deprecated since API version 9. You are advised to use [longClick<su
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.type('button')); let button = await driver.findComponent(BY.type('button'));
...@@ -3428,7 +3532,8 @@ This API is deprecated since API version 9. ...@@ -3428,7 +3532,8 @@ This API is deprecated since API version 9.
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.type('button')); let button = await driver.findComponent(BY.type('button'));
...@@ -3454,7 +3559,8 @@ This API is deprecated since API version 9. You are advised to use [getId<sup>9+ ...@@ -3454,7 +3559,8 @@ This API is deprecated since API version 9. You are advised to use [getId<sup>9+
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.type('button')); let button = await driver.findComponent(BY.type('button'));
...@@ -3480,7 +3586,8 @@ This API is deprecated since API version 9. You are advised to use [getText<sup> ...@@ -3480,7 +3586,8 @@ This API is deprecated since API version 9. You are advised to use [getText<sup>
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.type('button')); let button = await driver.findComponent(BY.type('button'));
...@@ -3506,7 +3613,8 @@ This API is deprecated since API version 9. You are advised to use [getType<sup> ...@@ -3506,7 +3613,8 @@ This API is deprecated since API version 9. You are advised to use [getType<sup>
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.type('button')); let button = await driver.findComponent(BY.type('button'));
...@@ -3532,7 +3640,8 @@ This API is deprecated since API version 9. You are advised to use [isClickable< ...@@ -3532,7 +3640,8 @@ This API is deprecated since API version 9. You are advised to use [isClickable<
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.type('button')); let button = await driver.findComponent(BY.type('button'));
...@@ -3562,7 +3671,8 @@ This API is deprecated since API version 9. You are advised to use [isScrollable ...@@ -3562,7 +3671,8 @@ This API is deprecated since API version 9. You are advised to use [isScrollable
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let scrollBar = await driver.findComponent(BY.scrollable(true)); let scrollBar = await driver.findComponent(BY.scrollable(true));
...@@ -3593,7 +3703,8 @@ This API is deprecated since API version 9. You are advised to use [isEnabled<su ...@@ -3593,7 +3703,8 @@ This API is deprecated since API version 9. You are advised to use [isEnabled<su
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.type('button')); let button = await driver.findComponent(BY.type('button'));
...@@ -3624,7 +3735,8 @@ This API is deprecated since API version 9. You are advised to use [isFocused<su ...@@ -3624,7 +3735,8 @@ This API is deprecated since API version 9. You are advised to use [isFocused<su
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.type('button')); let button = await driver.findComponent(BY.type('button'));
...@@ -3654,7 +3766,8 @@ This API is deprecated since API version 9. You are advised to use [isSelected<s ...@@ -3654,7 +3766,8 @@ This API is deprecated since API version 9. You are advised to use [isSelected<s
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.type('button')); let button = await driver.findComponent(BY.type('button'));
...@@ -3684,7 +3797,8 @@ This API is deprecated since API version 9. You are advised to use [inputText<su ...@@ -3684,7 +3797,8 @@ This API is deprecated since API version 9. You are advised to use [inputText<su
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let text = await driver.findComponent(BY.text('hello world')); let text = await driver.findComponent(BY.text('hello world'));
...@@ -3716,7 +3830,8 @@ This API is deprecated since API version 9. You are advised to use [scrollSearch ...@@ -3716,7 +3830,8 @@ This API is deprecated since API version 9. You are advised to use [scrollSearch
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let scrollBar = await driver.findComponent(BY.type('Scroll')); let scrollBar = await driver.findComponent(BY.type('Scroll'));
...@@ -3750,7 +3865,8 @@ This API is deprecated since API version 9. You are advised to use [create<sup>9 ...@@ -3750,7 +3865,8 @@ This API is deprecated since API version 9. You are advised to use [create<sup>9
**Example** **Example**
```js ```ts
import { UiDriver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
} }
...@@ -3774,7 +3890,8 @@ This API is deprecated since API version 9. You are advised to use [delayMs<sup> ...@@ -3774,7 +3890,8 @@ This API is deprecated since API version 9. You are advised to use [delayMs<sup>
**Example** **Example**
```js ```ts
import { UiDriver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
await driver.delayMs(1000); await driver.delayMs(1000);
...@@ -3805,7 +3922,8 @@ This API is deprecated since API version 9. You are advised to use [findComponen ...@@ -3805,7 +3922,8 @@ This API is deprecated since API version 9. You are advised to use [findComponen
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let button = await driver.findComponent(BY.text('next page')); let button = await driver.findComponent(BY.text('next page'));
...@@ -3836,7 +3954,8 @@ This API is deprecated since API version 9. You are advised to use [findComponen ...@@ -3836,7 +3954,8 @@ This API is deprecated since API version 9. You are advised to use [findComponen
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
let buttonList = await driver.findComponents(BY.text('next page')); let buttonList = await driver.findComponents(BY.text('next page'));
...@@ -3859,9 +3978,19 @@ This API is deprecated since API version 9. You are advised to use [assertCompon ...@@ -3859,9 +3978,19 @@ This API is deprecated since API version 9. You are advised to use [assertCompon
| ------ | ------------------- | ---- | -------------------- | | ------ | ------------------- | ---- | -------------------- |
| by | [By](#bydeprecated) | Yes | Attributes of the target component.| | by | [By](#bydeprecated) | Yes | Attributes of the target component.|
**Error codes**
For details about the error codes, see [UiTest Error Codes](../errorcodes/errorcode-uitest.md).
| ID| Error Message |
| -------- | ------------------------------------------------ |
| 17000002 | if the async function was not called with await. |
| 17000003 | if the assertion failed. |
**Example** **Example**
```js ```ts
import { UiDriver, BY } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
await driver.assertComponentExist(BY.text('next page')); await driver.assertComponentExist(BY.text('next page'));
...@@ -3880,7 +4009,8 @@ This API is deprecated since API version 9. You are advised to use [pressBack<su ...@@ -3880,7 +4009,8 @@ This API is deprecated since API version 9. You are advised to use [pressBack<su
**Example** **Example**
```js ```ts
import { UiDriver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
await driver.pressBack(); await driver.pressBack();
...@@ -3905,7 +4035,8 @@ This API is deprecated since API version 9. You are advised to use [triggerKey<s ...@@ -3905,7 +4035,8 @@ This API is deprecated since API version 9. You are advised to use [triggerKey<s
**Example** **Example**
```js ```ts
import { UiDriver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
await driver.triggerKey(123); await driver.triggerKey(123);
...@@ -3932,7 +4063,8 @@ This API is deprecated since API version 9. You are advised to use [click<sup>9+ ...@@ -3932,7 +4063,8 @@ This API is deprecated since API version 9. You are advised to use [click<sup>9+
**Example** **Example**
```js ```ts
import { UiDriver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
await driver.click(100,100); await driver.click(100,100);
...@@ -3958,7 +4090,8 @@ This API is deprecated since API version 9. You are advised to use [doubleClick< ...@@ -3958,7 +4090,8 @@ This API is deprecated since API version 9. You are advised to use [doubleClick<
**Example** **Example**
```js ```ts
import { UiDriver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
await driver.doubleClick(100,100); await driver.doubleClick(100,100);
...@@ -3984,7 +4117,8 @@ This API is deprecated since API version 9. You are advised to use [longClick<su ...@@ -3984,7 +4117,8 @@ This API is deprecated since API version 9. You are advised to use [longClick<su
**Example** **Example**
```js ```ts
import { UiDriver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
await driver.longClick(100,100); await driver.longClick(100,100);
...@@ -4012,7 +4146,8 @@ This API is deprecated since API version 9. You are advised to use [swipe<sup>9+ ...@@ -4012,7 +4146,8 @@ This API is deprecated since API version 9. You are advised to use [swipe<sup>9+
**Example** **Example**
```js ```ts
import { UiDriver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
await driver.swipe(100,100,200,200); await driver.swipe(100,100,200,200);
...@@ -4043,7 +4178,8 @@ This API is deprecated since API version 9. You are advised to use [screenCap<su ...@@ -4043,7 +4178,8 @@ This API is deprecated since API version 9. You are advised to use [screenCap<su
**Example** **Example**
```js ```ts
import { UiDriver } from '@ohos.UiTest';
async function demo() { async function demo() {
let driver = UiDriver.create(); let driver = UiDriver.create();
await driver.screenCap('/data/storage/el2/base/cache/1.png'); await driver.screenCap('/data/storage/el2/base/cache/1.png');
......
...@@ -17,7 +17,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut ...@@ -17,7 +17,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------------------------- | ---------------------------------------- | ---- | ---------------------------------------- | | ----------------------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| builder | CustomDialog | Yes | Constructor of the custom dialog box content. | | builder | CustomDialog | Yes | Builder of the custom dialog box content. |
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay exits. | | cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay exits. |
| autoCancel | boolean | No | Whether to allow users to click the overlay to exit.<br>Default value: **true** | | autoCancel | boolean | No | Whether to allow users to click the overlay to exit.<br>Default value: **true** |
| alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**| | alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**|
...@@ -29,7 +29,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut ...@@ -29,7 +29,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut
| openAnimation<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the open animation of the dialog box.<br>**NOTE**<br>**iterations**: The default value is **1**, indicating that the animation is played once; any other value evaluates to the default value.<br>**playMode**: The default value is **PlayMode.Normal**; any other value evaluates to the default value.| | openAnimation<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the open animation of the dialog box.<br>**NOTE**<br>**iterations**: The default value is **1**, indicating that the animation is played once; any other value evaluates to the default value.<br>**playMode**: The default value is **PlayMode.Normal**; any other value evaluates to the default value.|
| closeAniamtion<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the close animation of the dialog box.<br>**NOTE**<br>**iterations**: The default value is **1**, indicating that the animation is played once; any other value evaluates to the default value.<br>**playMode**: The default value is **PlayMode.Normal**; any other value evaluates to the default value. | | closeAniamtion<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the close animation of the dialog box.<br>**NOTE**<br>**iterations**: The default value is **1**, indicating that the animation is played once; any other value evaluates to the default value.<br>**playMode**: The default value is **PlayMode.Normal**; any other value evaluates to the default value. |
| showInSubWindow<sup>10+</sup> | boolean | No | Whether to display a dialog box in a subwindow.<br>Default value: **false**, indicating that the dialog box is not displayed in the subwindow<br>**NOTE**<br>A dialog box whose **showInSubWindow** attribute is **true** cannot trigger the display of another dialog box whose **showInSubWindow** attribute is also **true**.| | showInSubWindow<sup>10+</sup> | boolean | No | Whether to display a dialog box in a subwindow.<br>Default value: **false**, indicating that the dialog box is not displayed in the subwindow<br>**NOTE**<br>A dialog box whose **showInSubWindow** attribute is **true** cannot trigger the display of another dialog box whose **showInSubWindow** attribute is also **true**.|
| backgroundColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No | Background color of the dialog box. | | backgroundColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No | Background color of the dialog box.<br>**NOTE**<br>If the content builder also has the background color set, the background color set here will be overridden by the background color of the content builder.|
| cornerRadius<sup>10+</sup> | [BorderRadiuses](ts-types.md#borderradiuses9) \| [Dimension](ts-types.md#dimension10) | No | Radius of the rounded corners of the background.<br>You can set separate radiuses for the four rounded corners.<br>Default value: **{ topLeft: '24vp', topRight: '24vp', bottomLeft: '24vp', bottomRight: '24vp' }**<br>**NOTE**<br>This attribute must be used together with the [borderRadius](ts-universal-attributes-border.md) attribute.| | cornerRadius<sup>10+</sup> | [BorderRadiuses](ts-types.md#borderradiuses9) \| [Dimension](ts-types.md#dimension10) | No | Radius of the rounded corners of the background.<br>You can set separate radiuses for the four rounded corners.<br>Default value: **{ topLeft: '24vp', topRight: '24vp', bottomLeft: '24vp', bottomRight: '24vp' }**<br>**NOTE**<br>This attribute must be used together with the [borderRadius](ts-universal-attributes-border.md) attribute.|
## CustomDialogController ## CustomDialogController
...@@ -110,7 +110,7 @@ struct CustomDialogUser { ...@@ -110,7 +110,7 @@ struct CustomDialogUser {
}), }),
cancel: this.existApp, cancel: this.existApp,
autoCancel: true, autoCancel: true,
alignment: DialogAlignment.Default, alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: -20 }, offset: { dx: 0, dy: -20 },
gridCount: 4, gridCount: 4,
customStyle: false, customStyle: false,
......
...@@ -44,7 +44,7 @@ You can bind a popup to a component, specifying its content, interaction logic, ...@@ -44,7 +44,7 @@ You can bind a popup to a component, specifying its content, interaction logic,
| ---------------------------- | ---------------------------------------- | ---- | ---------------------------------------- | | ---------------------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| builder | [CustomBuilder](ts-types.md#custombuilder8) | Yes | Popup builder.<br>**NOTE**<br>The **popup** attribute is a universal attribute. A custom popup does not support display of another popup. The **position** attribute cannot be used for the first-layer container under the builder. If the **position** attribute is used, the popup will not be displayed. | | builder | [CustomBuilder](ts-types.md#custombuilder8) | Yes | Popup builder.<br>**NOTE**<br>The **popup** attribute is a universal attribute. A custom popup does not support display of another popup. The **position** attribute cannot be used for the first-layer container under the builder. If the **position** attribute is used, the popup will not be displayed. |
| placement | [Placement](ts-appendix-enums.md#placement8) | No | Preferred position of the popup. If the set position is insufficient for holding the popup, it will be automatically adjusted.<br>Default value: **Placement.Bottom**| | placement | [Placement](ts-appendix-enums.md#placement8) | No | Preferred position of the popup. If the set position is insufficient for holding the popup, it will be automatically adjusted.<br>Default value: **Placement.Bottom**|
| popupColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color of the popup. | | popupColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color of the popup.<br>Default value: **'#4d4d4d'**|
| enableArrow | boolean | No | Whether to display an arrow.<br>Since API version 9, if the position set for the popup is not large enough, the arrow will not be displayed. For example, if **placement** is set to **Left**, but the popup height (80 vp) is less than the sum of the arrow width (32 vp) and diameter of popup rounded corner (48 vp), the arrow will not be displayed.<br>Default value: **true**| | enableArrow | boolean | No | Whether to display an arrow.<br>Since API version 9, if the position set for the popup is not large enough, the arrow will not be displayed. For example, if **placement** is set to **Left**, but the popup height (80 vp) is less than the sum of the arrow width (32 vp) and diameter of popup rounded corner (48 vp), the arrow will not be displayed.<br>Default value: **true**|
| autoCancel | boolean | No | Whether to automatically close the popup when an operation is performed on the page.<br>Default value: **true** | | autoCancel | boolean | No | Whether to automatically close the popup when an operation is performed on the page.<br>Default value: **true** |
| onStateChange | (event: { isVisible: boolean }) =&gt; void | No | Callback for the popup status change event.<br/>**isVisible**: whether the popup is visible. | | onStateChange | (event: { isVisible: boolean }) =&gt; void | No | Callback for the popup status change event.<br/>**isVisible**: whether the popup is visible. |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册