• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AccessibilityExtensionContext (Accessibility Extension Context)
2
3The **AccessibilityExtensionContext** module, inherited from **ExtensionContext**, provides context for **AccessibilityExtensionAbility**.
4
5You can use the APIs of this module to configure the concerned information, obtain root information, and inject gestures.
6
7> **NOTE**
8>
9> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
10
11## Usage
12
13Before using the **AccessibilityExtensionContext** module, you must define a child class that inherits from **AccessibilityExtensionAbility**.
14
15```ts
16import { AccessibilityExtensionAbility } from '@kit.AccessibilityKit';
17
18class EntryAbility extends AccessibilityExtensionAbility {
19  onConnect(): void {
20    let axContext = this.context;
21  }
22}
23```
24
25## ElementAttributeValues
26
27Provides attribute names and value types of a node element.
28
29**System capability**: SystemCapability.BarrierFree.Accessibility.Core
30
31### Attributes
32
33| Name                  | Type                                                                | Readable | Writable | Description                 |
34|----------------------|--------------------------------------------------------------------|-----|-----| ------------------- |
35| accessibilityFocused | boolean                                                            | Yes  | No  |   Accessibility focus status.  |
36| accessibilityText<sup>12+</sup> | string                                                  | Yes  | No  | Accessibility text information of an element.|
37| bundleName           | string                                                             | Yes  | No  | Bundle name.|
38| checkable            | boolean                                                            | Yes  | No  | Whether the element is checkable.|
39| checked              | boolean                                                            | Yes  | No  | Whether the element is checked.|
40| children             | Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;        | Yes  | No  | All child elements.|
41| clickable            | boolean                                                            | Yes  | No  | Whether the element is clickable.|
42| componentId          | number                                                             | Yes  | No  | ID of the component to which the element belongs.|
43| componentType        | string                                                             | Yes  | No  | Type of the component to which the element belongs.|
44| contents             | Array&lt;string&gt;                                                | Yes  | No  | Content.|
45| currentIndex         | number                                                             | Yes  | No  | Index of the current item.|
46| description          | string                                                             | Yes  | No  | Description of the element.|
47| editable             | boolean                                                            | Yes  | No  | Whether the element is editable.|
48| endIndex             | number                                                             | Yes  | No  | Index of the last list item displayed on the screen.|
49| error                | string                                                             | Yes  | No  | Error status.|
50| focusable            | boolean                                                            | Yes  | No  | Whether the element is focusable.|
51| hintText             | string                                                             | Yes  | No  | Hint text.|
52| inputType            | number                                                             | Yes  | No  | Type of the input text.|
53| inspectorKey         | string                                                             | Yes  | No  | Inspector key.|
54| isActive             | boolean                                                            | Yes  | No  | Whether the element is active.|
55| isEnable             | boolean                                                            | Yes  | No  | Whether the element is enabled.|
56| isHint               | boolean                                                            | Yes  | No  | Whether the element is in the hint state.|
57| isFocused            | boolean                                                            | Yes  | No  | Whether the element is focused.|
58| isPassword           | boolean                                                            | Yes  | No  | Whether the element is a password.|
59| isVisible            | boolean                                                            | Yes  | No  | Whether the element is visible.|
60| itemCount            | number                                                             | Yes  | No  | Total number of items.|
61| lastContent          | string                                                             | Yes  | No  | Last content.|
62| layer                | number                                                             | Yes  | No  | Display layer of the element.|
63| longClickable        | boolean                                                            | Yes  | No  | Whether the element is long-clickable.|
64| pageId               | number                                                             | Yes  | No  | Page ID.|
65| parent               | [AccessibilityElement](#accessibilityelement9)                     | Yes  | No  | Parent element of the element.|
66| pluralLineSupported  | boolean                                                            | Yes  | No  | Whether the element supports multiple lines of text.|
67| rect                 | [Rect](#rect)                                                      | Yes  | No  | Area of the element.|
68| resourceName         | string                                                             | Yes  | No  | Resource name of the element.|
69| rootElement          | [AccessibilityElement](#accessibilityelement9)                     | Yes  | No  | Root element of the window element.|
70| screenRect           | [Rect](#rect)                                                      | Yes  | No  | Display area of the element.|
71| scrollable           | boolean                                                            | Yes  | No  | Whether the element is scrollable.|
72| selected             | boolean                                                            | Yes  | No  | Whether the element is selected.|
73| startIndex           | number                                                             | Yes  | No  | Index of the first list item on the screen.|
74| text                 | string                                                             | Yes  | No  | Text of the element.|
75| textLengthLimit      | number                                                             | Yes  | No  | Maximum text length of the element.|
76| textMoveUnit         | [accessibility.TextMoveUnit](js-apis-accessibility.md#textmoveunit) | Yes  | No  | Unit of movement when the text is read.|
77| triggerAction        | [accessibility.Action](js-apis-accessibility.md#action)         | Yes  | No  | Action that triggers the element event.|
78| type                 | [WindowType](#windowtype)                                          | Yes  | No  | Window type of the element.|
79| valueMax             | number                                                             | Yes  | No  | Maximum value.|
80| valueMin             | number                                                             | Yes  | No  | Minimum value.|
81| valueNow             | number                                                             | Yes  | No  | Current value.|
82| windowId             | number                                                             | Yes  | No  | Window ID.|
83| textType<sup>12+</sup>             | string                                                             | Yes  | No  | Accessibility text type of an element, which is configured by the **accessibilityTextHint** attribute of the component.|
84| offset<sup>12+</sup>             | number                                                             | Yes  | No  | Pixel offset of the content area relative to the top coordinate of a scrollable component, such as **List** and **Grid**.|
85| hotArea<sup>12+</sup>             | [Rect](#rect)                                                              | Yes  | No  | Touchable area of an element.|
86| customComponentType<sup>18+</sup>             | string                                                             | Yes  | No  | Custom component type.|
87| accessibilityNextFocusId<sup>18+</sup>             | number                | Yes  | No  | ID of the next component to be focused on. You can use **findElement('elementId')** to obtain the value of this attribute set on the component from the **AccessibilityElementInfo** object.|
88| accessibilityPreviousFocusId<sup>18+</sup>             | number                | Yes  | No  | ID of the previous component to be focused on. You can use **findElement('elementId')** to obtain the value of this attribute set on the component from the **AccessibilityElementInfo** object.|
89| extraInfo<sup>18+</sup>             | string     | Yes  | No  | Extended attributes, which are used to define the attributes of specific components, including:<br>- **CheckboxGroupSelectedStatus**: selection status of the **CheckboxGroup** component. The options are as follows:<br>**0**: selected<br>**1**: partially selected<br>**2**: not selected<br>- **Row**: row where an focused item is located in **Grid**.<br>- **Column**: column where an focused item is located in **Grid**.<br>- **ListItemIndex**: row where an focused item is located in **List**.<br>- **SideBarContainerStates**: expansion state of the expandable components (such as **SideBarContainer** and **Select**). The options are as follows:<br>**0**: collapsed<br>**1**: expanded<br>- **ToggleType**: type of the **Toggle** component. The options are as follows:<br>**0**: checkbox<br>**1**: switch<br>**2**: button<br>- **BindSheet**: state of the **BindSheet** component. The options are as follows:<br>**0**: high<br>**1**: middle<br>**2**: low<br>- **hasRegisteredHover**: whether the component has registered the **onAccessibilityHover** event callback. The value **1** indicates that the component has registered the event callback; otherwise, this field is not used.<br>- **direction**: layout direction of the **List** component. The value can be **vertical** or **horizontal**.<br>- **expandedState**: expanded state of list items in the **List** component. The value can be **expanded** or **collapsed**. |
90| accessibilityScrollable<sup>18+</sup>             | boolean                 | Yes  | No  | Whether an element is scrollable for accessibility. This attribute has a higher priority than **scrollable**. <br>- **true** (default): the element is scrollable.<br>- **false**: the element is not scrollable.|
91
92## FocusDirection
93
94type FocusDirection = 'up' | 'down' | 'left' | 'right' | 'forward' | 'backward'
95
96Enumerates the focus directions.
97
98**System capability**: SystemCapability.BarrierFree.Accessibility.Core
99
100| Type      | Description     |
101| -------- | ------- |
102| 'up'       | Search for the next focusable item above the current item in focus.|
103| 'down'     | Search for the next focusable item below the current item in focus.|
104| 'left'     | Search for the next focusable item on the left of the current item in focus.|
105| 'right'    | Search for the next focusable item on the right of the current item in focus.|
106| 'forward'  | Search for the next focusable item before the current item in focus.|
107| 'backward' | Search for the next focusable item after the current item in focus.|
108
109## FocusType
110
111type FocusType = 'accessibility' | 'normal'
112
113Enumerates the focus types.
114
115**System capability**: SystemCapability.BarrierFree.Accessibility.Core
116
117| Type           | Description         |
118| ------------- | ----------- |
119| 'accessibility' | Accessibility focus.|
120| 'normal'        | Normal focus. |
121
122## Rect
123
124Defines a rectangle.
125
126**System capability**: SystemCapability.BarrierFree.Accessibility.Core
127
128| Name    | Type    | Readable  | Writable  | Description       |
129| ------ | ------ | ---- | ---- | --------- |
130| left   | number | Yes   | No   | Left boundary of the rectangle.|
131| top    | number | Yes   | No   | Top boundary of the rectangle.|
132| width  | number | Yes   | No   | Width of the rectangle. |
133| height | number | Yes   | No   | Height of the rectangle. |
134
135## WindowType
136
137type WindowType = 'application' | 'system'
138
139Enumerates the window types.
140
141**System capability**: SystemCapability.BarrierFree.Accessibility.Core
142
143| Type         | Description       |
144| ----------- | --------- |
145| 'application' | Application window.|
146| 'system'      | System window.|
147
148## AccessibilityExtensionContext.setTargetBundleName<sup>(deprecated)</sup>
149
150setTargetBundleName(targetNames: Array\<string>): Promise\<void>;
151
152Sets the concerned target bundle. This API uses a promise to return the result.
153
154> **NOTE**
155>
156> This API is deprecated since API version 12.
157
158**System capability**: SystemCapability.BarrierFree.Accessibility.Core
159
160**Parameters**
161
162| Name        | Type                 | Mandatory  | Description      |
163| ----------- | ------------------- | ---- | -------- |
164| targetNames | Array&lt;string&gt; | Yes   | Bundle name of the concerned target application. The service receives accessibility events of the concerned application. By default, accessibility events of all applications are received. Pass in an empty array if there is no concerned application.|
165
166**Return value**
167
168| Type                 | Description              |
169| ------------------- | ---------------- |
170| Promise&lt;void&gt; | Promise that returns no value.|
171
172**Error codes**
173
174For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
175
176| ID| Error Message|
177| ------- | -------------------------------- |
178| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
179
180**Example**
181
182```ts
183import { BusinessError } from '@kit.BasicServicesKit';
184
185let targetNames = ['com.ohos.xyz'];
186axContext.setTargetBundleName(targetNames).then(() => {
187  console.info(`Succeeded in set target bundle names, targetNames is ${targetNames}`);
188}).catch((err: BusinessError) => {
189  console.error(`failed to set target bundle names, Code is ${err.code}, message is ${err.message}`);
190})
191```
192
193## AccessibilityExtensionContext.setTargetBundleName<sup>(deprecated)</sup>
194
195setTargetBundleName(targetNames: Array\<string>, callback: AsyncCallback\<void>): void;
196
197Sets the concerned target bundle. This API uses an asynchronous callback to return the result.
198
199> **NOTE**
200>
201> This API is deprecated since API version 12.
202
203**System capability**: SystemCapability.BarrierFree.Accessibility.Core
204
205**Parameters**
206
207| Name        | Type                       | Mandatory  | Description                                      |
208| ----------- | ------------------------- | ---- | ---------------------------------------- |
209| targetNames | Array&lt;string&gt;       | Yes   | Bundle name of the concerned target application. The service receives accessibility events of the concerned application. By default, accessibility events of all applications are received. Pass in an empty array if there is no concerned application.                                |
210| callback    | AsyncCallback&lt;void&gt; | Yes   | Callback used to return the result. If the operation fails, **err** that contains data is returned.|
211
212**Error codes**
213
214For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
215
216| ID| Error Message|
217| ------- | -------------------------------- |
218| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
219
220**Example**
221
222```ts
223import { BusinessError } from '@kit.BasicServicesKit';
224
225let targetNames = ['com.ohos.xyz'];
226try {
227  axContext.setTargetBundleName(targetNames, (err: BusinessError) => {
228    if (err && err.code) {
229      console.error(`failed to set target bundle names, Code is ${err.code}, message is ${err.message}`);
230      return;
231    }
232    console.info(`Succeeded in set target bundle names, targetNames is ${targetNames}`);
233  });
234} catch (error) {
235  console.error(`failed to set target bundle names, Because ${JSON.stringify(error)}`);
236}
237```
238
239## AccessibilityExtensionContext.getFocusElement<sup>(deprecated)</sup>
240
241getFocusElement(isAccessibilityFocus?: boolean): Promise\<AccessibilityElement>;
242
243Obtains the focus element. This API uses a promise to return the result.
244
245> **NOTE**
246>
247> This API is deprecated since API version 12.
248
249**System capability**: SystemCapability.BarrierFree.Accessibility.Core
250
251**Parameters**
252
253| Name                 | Type     | Mandatory  | Description                 |
254| -------------------- | ------- | ---- | ------------------- |
255| isAccessibilityFocus | boolean | No   | Whether the obtained focus element is an accessibility focus. The value **True** means that the obtained focus element is an accessibility focus, and **False** means the opposite. The default value is **False**.|
256
257**Return value**
258| Type                                 | Description                    |
259| ----------------------------------- | ---------------------- |
260| Promise&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Promise used to return the current focus element.|
261
262**Error codes**
263
264For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
265
266| ID  | Error Message                                    |
267| ------- | ---------------------------------------- |
268| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
269| 9300003 | No accessibility permission to perform the operation. |
270
271**Example**
272
273```ts
274import { AccessibilityElement } from '@kit.AccessibilityKit';
275import { BusinessError } from '@kit.BasicServicesKit';
276
277let rootElement: AccessibilityElement;
278
279axContext.getFocusElement().then((data: AccessibilityElement) => {
280  rootElement = data;
281  console.log(`Succeeded in get focus element,${JSON.stringify(data)}`);
282}).catch((err: BusinessError) => {
283  console.error(`failed to get focus element, Code is ${err.code}, message is ${err.message}`);
284})
285```
286
287## AccessibilityExtensionContext.getFocusElement<sup>(deprecated)</sup>
288
289getFocusElement(callback: AsyncCallback\<AccessibilityElement>): void;
290
291Obtains the focus element. This API uses an asynchronous callback to return the result.
292
293> **NOTE**
294>
295> This API is deprecated since API version 12.
296
297**System capability**: SystemCapability.BarrierFree.Accessibility.Core
298
299**Parameters**
300
301| Name     | Type                                      | Mandatory  | Description               |
302| -------- | ---------------------------------------- | ---- | ----------------- |
303| callback | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Yes   | Callback used to return the current focus element.|
304
305**Error codes**
306
307For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
308
309| ID  | Error Message                                    |
310| ------- | ---------------------------------------- |
311| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
312| 9300003 | No accessibility permission to perform the operation. |
313
314**Example**
315
316```ts
317import { AccessibilityElement } from '@kit.AccessibilityKit';
318import { BusinessError } from '@kit.BasicServicesKit';
319
320let rootElement: AccessibilityElement;
321
322axContext.getFocusElement((err: BusinessError, data: AccessibilityElement) => {
323  if (err && err.code) {
324    console.error(`failed to get focus element, Code is ${err.code}, message is ${err.message}`);
325    return;
326  }
327  rootElement = data;
328  console.info(`Succeeded in get focus element, ${JSON.stringify(data)}`);
329});
330```
331
332## AccessibilityExtensionContext.getFocusElement<sup>(deprecated)</sup>
333
334getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\<AccessibilityElement>): void;
335
336Obtains the focus element. This API uses an asynchronous callback to return the result.
337
338> **NOTE**
339>
340> This API is deprecated since API version 12.
341
342**System capability**: SystemCapability.BarrierFree.Accessibility.Core
343
344**Parameters**
345
346| Name                 | Type                                      | Mandatory  | Description               |
347| -------------------- | ---------------------------------------- | ---- | ----------------- |
348| isAccessibilityFocus | boolean                                  | Yes   | Whether the obtained focus element is an accessibility focus. The value **True** means that the obtained focus element is an accessibility focus, and **False** means the opposite.   |
349| callback             | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Yes   | Callback used to return the current focus element.|
350
351**Error codes**
352
353For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
354
355| ID  | Error Message                                    |
356| ------- | ---------------------------------------- |
357| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
358| 9300003 | No accessibility permission to perform the operation. |
359
360**Example**
361
362```ts
363import { AccessibilityElement } from '@kit.AccessibilityKit';
364import { BusinessError } from '@kit.BasicServicesKit';
365
366let isAccessibilityFocus = true;
367let rootElement: AccessibilityElement;
368
369axContext.getFocusElement(isAccessibilityFocus, (err: BusinessError, data: AccessibilityElement)=> {
370  if (err && err.code) {
371    console.error(`failed to get focus element, Code is ${err.code}, message is ${err.message}`);
372    return;
373  }
374  rootElement = data;
375  console.info(`Succeeded in get focus element, ${JSON.stringify(data)}`);
376});
377```
378
379## AccessibilityExtensionContext.getWindowRootElement<sup>(deprecated)</sup>
380
381getWindowRootElement(windowId?: number): Promise\<AccessibilityElement>;
382
383Obtains the root element of a window. This API uses a promise to return the result.
384
385> **NOTE**
386>
387> This API is deprecated since API version 12.
388
389**System capability**: SystemCapability.BarrierFree.Accessibility.Core
390
391**Parameters**
392
393| Name     | Type    | Mandatory  | Description                    |
394| -------- | ------ | ---- | ---------------------- |
395| windowId | number | No   | Window for which you want to obtain the root element. If this parameter is not specified, it indicates the current active window.|
396
397**Return value**
398
399| Type                                 | Description                    |
400| ----------------------------------- | ---------------------- |
401| Promise&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Promise used to return the root element of the specified window.|
402
403**Error codes**
404
405For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
406
407| ID  | Error Message                                    |
408| ------- | ---------------------------------------- |
409| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
410| 9300003 | No accessibility permission to perform the operation. |
411
412**Example**
413
414```ts
415import { AccessibilityElement } from '@kit.AccessibilityKit';
416import { BusinessError } from '@kit.BasicServicesKit';
417
418let rootElement: AccessibilityElement;
419
420axContext.getWindowRootElement().then((data: AccessibilityElement) => {
421  rootElement = data;
422  console.log(`Succeeded in get root element of the window, ${JSON.stringify(data)}`);
423}).catch((err: BusinessError) => {
424  console.error(`failed to get root element of the window, Code is ${err.code}, message is ${err.message}`);
425});
426```
427
428## AccessibilityExtensionContext.getWindowRootElement<sup>(deprecated)</sup>
429
430getWindowRootElement(callback: AsyncCallback\<AccessibilityElement>): void;
431
432Obtains the root element of a window. This API uses an asynchronous callback to return the result.
433
434> **NOTE**
435>
436> This API is deprecated since API version 12.
437
438**System capability**: SystemCapability.BarrierFree.Accessibility.Core
439
440**Parameters**
441
442| Name     | Type                                      | Mandatory  | Description                |
443| -------- | ---------------------------------------- | ---- | ------------------ |
444| callback | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Yes   | Callback used to return the root element.|
445
446**Error codes**
447
448For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
449
450| ID  | Error Message                                    |
451| ------- | ---------------------------------------- |
452| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
453| 9300003 | No accessibility permission to perform the operation. |
454
455**Example**
456
457```ts
458import { AccessibilityElement } from '@kit.AccessibilityKit';
459import { BusinessError } from '@kit.BasicServicesKit';
460
461let rootElement: AccessibilityElement;
462
463axContext.getWindowRootElement((err: BusinessError, data: AccessibilityElement) => {
464  if (err && err.code) {
465    console.error(`failed to get root element of the window, Code is ${err.code}, message is ${err.message}`);
466    return;
467  }
468  rootElement = data;
469  console.info(`Succeeded in get root element of the window, ${JSON.stringify(data)}`);
470});
471```
472
473## AccessibilityExtensionContext.getWindowRootElement<sup>(deprecated)</sup>
474
475getWindowRootElement(windowId: number, callback: AsyncCallback\<AccessibilityElement>): void;
476
477Obtains the root element of a window. This API uses an asynchronous callback to return the result.
478
479> **NOTE**
480>
481> This API is deprecated since API version 12.
482
483**System capability**: SystemCapability.BarrierFree.Accessibility.Core
484
485**Parameters**
486
487| Name     | Type                                      | Mandatory  | Description                    |
488| -------- | ---------------------------------------- | ---- | ---------------------- |
489| windowId | number                                   | Yes   | Window for which you want to obtain the root element. If this parameter is not specified, it indicates the current active window.|
490| callback | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Yes   | Callback used to return the root element.    |
491
492**Error codes**
493
494For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
495
496| ID  | Error Message                                    |
497| ------- | ---------------------------------------- |
498| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
499| 9300003 | No accessibility permission to perform the operation. |
500
501**Example**
502
503```ts
504import { AccessibilityElement } from '@kit.AccessibilityKit';
505import { BusinessError } from '@kit.BasicServicesKit';
506
507let windowId = 10;
508let rootElement: AccessibilityElement;
509
510axContext.getWindowRootElement(windowId, (err: BusinessError, data: AccessibilityElement) => {
511  if (err && err.code) {
512    console.error(`failed to get root element of the window, Code is ${err.code}, message is ${err.message}`);
513    return;
514  }
515  rootElement = data;
516  console.info(`Succeeded in get root element of the window, ${JSON.stringify(data)}`);
517});
518```
519
520## AccessibilityExtensionContext.getWindows<sup>(deprecated)</sup>
521
522getWindows(displayId?: number): Promise\<Array\<AccessibilityElement>>;
523
524Obtains the list of windows on a display. This API uses a promise to return the result.
525
526> **NOTE**
527>
528> This API is deprecated since API version 12.
529
530**System capability**: SystemCapability.BarrierFree.Accessibility.Core
531
532**Parameters**
533
534| Name      | Type    | Mandatory  | Description                   |
535| --------- | ------ | ---- | --------------------- |
536| displayId | number | No   | ID of the display from which the window information is obtained. If this parameter is not specified, it indicates the default main display.|
537
538**Return value**
539
540| Type                                      | Description                    |
541| ---------------------------------------- | ---------------------- |
542| Promise&lt;Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;&gt; | Promise used to return the window list.|
543
544**Error codes**
545
546For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
547
548| ID  | Error Message                                    |
549| ------- | ---------------------------------------- |
550| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
551| 9300003 | No accessibility permission to perform the operation. |
552
553**Example**
554
555```ts
556import { AccessibilityElement } from '@kit.AccessibilityKit';
557import { BusinessError } from '@kit.BasicServicesKit';
558
559axContext.getWindows().then((data: AccessibilityElement[]) => {
560  console.log(`Succeeded in get windows, ${JSON.stringify(data)}`);
561}).catch((err: BusinessError) => {
562  console.error(`failed to get windows, Code is ${err.code}, message is ${err.message}`);
563});
564```
565
566## AccessibilityExtensionContext.getWindows<sup>(deprecated)</sup>
567
568getWindows(callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
569
570Obtains the list of windows on a display. This API uses an asynchronous callback to return the result.
571
572> **NOTE**
573>
574> This API is deprecated since API version 12.
575
576**System capability**: SystemCapability.BarrierFree.Accessibility.Core
577
578**Parameters**
579
580| Name     | Type                                      | Mandatory  | Description               |
581| -------- | ---------------------------------------- | ---- | ----------------- |
582| callback | AsyncCallback&lt;Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;&gt; | Yes   | Callback used to return the window list.|
583
584**Error codes**
585
586For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
587
588| ID  | Error Message                                    |
589| ------- | ---------------------------------------- |
590| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
591| 9300003 | No accessibility permission to perform the operation. |
592
593**Example**
594
595```ts
596import { AccessibilityElement } from '@kit.AccessibilityKit';
597import { BusinessError } from '@kit.BasicServicesKit';
598
599axContext.getWindows((err: BusinessError, data: AccessibilityElement[]) => {
600  if (err && err.code) {
601    console.error(`failed to get windows, Code is ${err.code}, message is ${err.message}`);
602    return;
603  }
604  console.info(`Succeeded in get windows, ${JSON.stringify(data)}`);
605});
606```
607
608## AccessibilityExtensionContext.getWindows<sup>(deprecated)</sup>
609
610getWindows(displayId: number, callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
611
612Obtains the list of windows on a display. This API uses an asynchronous callback to return the result.
613
614> **NOTE**
615>
616> This API is deprecated since API version 12.
617
618**System capability**: SystemCapability.BarrierFree.Accessibility.Core
619
620**Parameters**
621
622| Name      | Type                                      | Mandatory  | Description                   |
623| --------- | ---------------------------------------- | ---- | --------------------- |
624| displayId | number                                   | Yes   | ID of the display from which the window information is obtained. If this parameter is not specified, it indicates the default main display.|
625| callback  | AsyncCallback&lt;Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;&gt; | Yes   | Callback used to return the window list.    |
626
627**Error codes**
628
629For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
630
631| ID  | Error Message                                    |
632| ------- | ---------------------------------------- |
633| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
634| 9300003 | No accessibility permission to perform the operation. |
635
636**Example**
637
638```ts
639import { AccessibilityElement } from '@kit.AccessibilityKit';
640import { BusinessError } from '@kit.BasicServicesKit';
641
642let displayId = 10;
643axContext.getWindows(displayId, (err: BusinessError, data: AccessibilityElement[]) => {
644  if (err && err.code) {
645    console.error(`failed to get windows, Code is ${err.code}, message is ${err.message}`);
646    return;
647  }
648  console.info(`Succeeded in get windows, ${JSON.stringify(data)}`);
649});
650```
651
652## AccessibilityExtensionContext.injectGesture<sup>(deprecated)</sup>
653
654injectGesture(gesturePath: GesturePath): Promise\<void>;
655
656> **NOTE**
657>
658> This API is deprecated since API version 10.
659
660Injects a gesture. This API uses a promise to return the result.
661
662**System capability**: SystemCapability.BarrierFree.Accessibility.Core
663
664**Parameters**
665
666| Name        | Type                                                                | Mandatory  | Description        |
667| ----------- |--------------------------------------------------------------------| ---- | ---------- |
668| gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | Yes   | Path of the gesture to inject.|
669
670**Return value**
671
672| Type                 | Description              |
673| ------------------- | ---------------- |
674| Promise&lt;void&gt; | Promise that returns no value.|
675
676**Error codes**
677
678For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
679
680| ID  | Error Message                                    |
681| ------- | ---------------------------------------- |
682| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
683| 9300003 | No accessibility permission to perform the operation. |
684
685**Example**
686
687```ts
688import { GesturePath, GesturePoint } from '@kit.AccessibilityKit';
689import { BusinessError } from '@kit.BasicServicesKit';
690
691let gesturePath: GesturePath = new GesturePath(100);
692
693for (let i = 0; i < 10; i++) {
694  let gesturePoint = new GesturePoint(100, i * 200);
695  gesturePath.points.push(gesturePoint);
696}
697axContext.injectGesture(gesturePath).then(() => {
698  console.info(`Succeeded in inject gesture,gesturePath is ${gesturePath}`);
699}).catch((err: BusinessError) => {
700  console.error(`failed to inject gesture, Code is ${err.code}, message is ${err.message}`);
701});
702```
703## AccessibilityExtensionContext.injectGesture<sup>(deprecated)</sup>
704
705injectGesture(gesturePath: GesturePath, callback: AsyncCallback\<void>): void
706
707> **NOTE**
708>
709> This API is deprecated since API version 10.
710
711Injects a gesture. This API uses an asynchronous callback to return the result.
712
713**System capability**: SystemCapability.BarrierFree.Accessibility.Core
714
715**Parameters**
716
717| Name        | Type                                                                | Mandatory  | Description                 |
718| ----------- |--------------------------------------------------------------------| ---- | ------------------- |
719| gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | Yes   | Path of the gesture to inject.         |
720| callback    | AsyncCallback&lt;void&gt;                                          | Yes   | Callback used to return the result.|
721
722**Error codes**
723
724For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
725
726| ID  | Error Message                                    |
727| ------- | ---------------------------------------- |
728| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
729| 9300003 | No accessibility permission to perform the operation. |
730
731**Example**
732
733```ts
734import { GesturePath, GesturePoint } from '@kit.AccessibilityKit';
735import { BusinessError } from '@kit.BasicServicesKit';
736
737let gesturePath: GesturePath = new GesturePath(100);
738for (let i = 0; i < 10; i++) {
739  let gesturePoint = new GesturePoint(100, i * 200);
740  gesturePath.points.push(gesturePoint);
741}
742axContext.injectGesture(gesturePath, (err: BusinessError) => {
743  if (err) {
744    console.error(`failed to inject gesture, Code is ${err.code}, message is ${err.message}`);
745    return;
746  }
747  console.info(`Succeeded in inject gesture,gesturePath is ${gesturePath}`);
748});
749```
750## AccessibilityExtensionContext.injectGestureSync<sup>(deprecated)</sup>
751
752injectGestureSync(gesturePath: GesturePath): void
753
754Injects a gesture.
755
756> **NOTE**
757>
758> This API is deprecated since API version 12.
759
760**System capability**: SystemCapability.BarrierFree.Accessibility.Core
761
762**Parameters**
763
764| Name     | Type                                                                | Mandatory| Description                |
765| ----------- |--------------------------------------------------------------------| ---- | -------------------- |
766| gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | Yes  | Path of the gesture to inject.|
767
768**Error codes**
769
770For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
771
772| ID| Error Message                                           |
773| -------- | --------------------------------------------------- |
774| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
775| 9300003  | No accessibility permission to perform the operation. |
776
777**Example**
778
779```ts
780import { GesturePath, GesturePoint } from '@kit.AccessibilityKit';
781
782let gesturePath: GesturePath = new GesturePath(100);
783for (let i = 0; i < 10; i++) {
784  let gesturePoint = new GesturePoint(100, i * 200);
785  gesturePath.points.push(gesturePoint);
786}
787axContext.injectGestureSync(gesturePath);
788```
789
790## AccessibilityElement<sup>9+</sup>
791
792Defines the **AccessibilityElement**. Before calling APIs of **AccessibilityElement**, you must call [AccessibilityExtensionContext.getFocusElement()](#accessibilityextensioncontextgetfocuselementdeprecated) or [AccessibilityExtensionContext.getWindowRootElement()](#accessibilityextensioncontextgetwindowrootelementdeprecated) to obtain an **AccessibilityElement** instance.
793
794**System capability**: SystemCapability.BarrierFree.Accessibility.Core
795
796### attributeNames<sup>(deprecated)</sup>
797
798attributeNames\<T extends keyof ElementAttributeValues>() : Promise\<Array\<T>>;
799
800Obtains all attribute names of this element. This API uses a promise to return the result.
801
802> **NOTE**
803>
804> This API is deprecated since API version 12.
805
806**System capability**: SystemCapability.BarrierFree.Accessibility.Core
807
808**Return value**
809
810| Type                           | Description                      |
811| ----------------------------- | ------------------------ |
812| Promise&lt;Array&lt;T&gt;&gt; | Promise used to return all attribute names of the element.|
813
814**Example**
815
816```ts
817import { ElementAttributeKeys } from '@kit.AccessibilityKit';
818import { BusinessError } from '@kit.BasicServicesKit';
819
820// rootElement is an instance of AccessibilityElement.
821rootElement.attributeNames().then((data: ElementAttributeKeys[]) => {
822  console.log(`Succeeded in get attribute names, ${JSON.stringify(data)}`);
823}).catch((err: BusinessError) => {
824  console.log(`failed to get attribute names, Code is ${err.code}, message is ${err.message}`);
825});
826```
827
828### attributeNames<sup>(deprecated)</sup>
829
830attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\<Array\<T>>): void;
831
832Obtains all attribute names of this element. This API uses an asynchronous callback to return the result.
833
834> **NOTE**
835>
836> This API is deprecated since API version 12.
837
838**System capability**: SystemCapability.BarrierFree.Accessibility.Core
839
840**Parameters**
841
842| Name     | Type                                 | Mandatory  | Description                 |
843| -------- | ----------------------------------- | ---- | ------------------- |
844| callback | AsyncCallback&lt;Array&lt;T&gt;&gt; | Yes   | Callback used to return all attribute names of the element.|
845
846**Example**
847
848```ts
849import { ElementAttributeKeys } from '@kit.AccessibilityKit';
850import { BusinessError } from '@kit.BasicServicesKit';
851
852// rootElement is an instance of AccessibilityElement.
853rootElement.attributeNames((err: BusinessError, data: ElementAttributeKeys[]) => {
854  if (err && err.code) {
855    console.error(`failed to get attribute names, Code is ${err.code}, message is ${err.message}`);
856    return;
857  }
858  console.info(`Succeeded in get attribute names, ${JSON.stringify(data)}`);
859});
860```
861
862### attributeValue<sup>(deprecated)</sup>
863
864attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promise\<ElementAttributeValues[T]>;
865
866Obtains the attribute value based on an attribute name. This API uses a promise to return the result.
867
868> **NOTE**
869>
870> This API is deprecated since API version 12.
871
872**System capability**: SystemCapability.BarrierFree.Accessibility.Core
873
874
875**Parameters**
876
877| Name          | Type  | Mandatory  | Description      |
878| ------------- | ---- | ---- | -------- |
879| attributeName | ElementAttributeKeys  | Yes   | Attribute name.|
880
881**Return value**
882
883| Type                                      | Description                         |
884| ---------------------------------------- | --------------------------- |
885| Promise&lt;ElementAttributeValues[T]&gt; | Promise used to return the attribute value.|
886
887**Error codes**
888
889For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
890
891| ID  | Error Message                         |
892| ------- | ----------------------------- |
893| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
894| 9300004 | This property does not exist. |
895
896
897**Example**
898
899```ts
900import { ElementAttributeKeys } from '@kit.AccessibilityKit';
901import { BusinessError } from '@kit.BasicServicesKit';
902
903let attributeName: ElementAttributeKeys = 'bundleName';
904
905// rootElement is an instance of AccessibilityElement.
906rootElement.attributeValue(attributeName).then((data: string) => {
907  console.log(`Succeeded in get attribute value by name, ${JSON.stringify(data)}`);
908}).catch((err: BusinessError) => {
909  console.error(`failed to get attribute value, Code is ${err.code}, message is ${err.message}`);
910});
911```
912
913### attributeValue<sup>(deprecated)</sup>
914
915attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T,
916    callback: AsyncCallback\<ElementAttributeValues[T]>): void;
917
918Obtains the attribute value based on an attribute name. This API uses an asynchronous callback to return the result.
919
920> **NOTE**
921>
922> This API is deprecated since API version 12.
923
924**System capability**: SystemCapability.BarrierFree.Accessibility.Core
925
926**Parameters**
927
928| Name          | Type                                      | Mandatory  | Description                    |
929| ------------- | ---------------------------------------- | ---- | ---------------------- |
930| attributeName | ElementAttributeKeys                         | Yes   | Attribute name.              |
931| callback      | AsyncCallback&lt;ElementAttributeValues[T]&gt; | Yes   | Callback used to return the attribute value.|
932
933**Error codes**
934
935For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
936
937| ID  | Error Message                         |
938| ------- | ----------------------------- |
939| 401  | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
940| 9300004 | This property does not exist. |
941
942**Example**
943
944```ts
945import { ElementAttributeKeys } from '@kit.AccessibilityKit';
946import { BusinessError } from '@kit.BasicServicesKit';
947
948let attributeName: ElementAttributeKeys = 'bundleName';
949
950// rootElement is an instance of AccessibilityElement.
951rootElement.attributeValue(attributeName, (err: BusinessError, data: string) => {
952  if (err && err.code) {
953    console.error(`failed to get attribute value, Code is ${err.code}, message is ${err.message}`);
954    return;
955  }
956  console.info(`Succeeded in get attribute value, ${JSON.stringify(data)}`);
957});
958```
959
960### actionNames<sup>(deprecated)</sup>
961
962actionNames(): Promise\<Array\<string>>;
963
964Obtains the names of all actions supported by this element. This API uses a promise to return the result.
965
966> **NOTE**
967>
968> This API is deprecated since API version 12.
969
970**System capability**: SystemCapability.BarrierFree.Accessibility.Core
971
972**Return value**
973
974| Type                                | Description                        |
975| ---------------------------------- | -------------------------- |
976| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the names of all actions supported by the element.|
977
978**Example**
979
980```ts
981import { BusinessError } from '@kit.BasicServicesKit';
982
983// rootElement is an instance of AccessibilityElement.
984rootElement.actionNames().then((data: string[]) => {
985  console.log(`Succeeded in get action names, ${JSON.stringify(data)}`);
986}).catch((err: BusinessError) => {
987  console.error(`failed to get action names, Code is ${err.code}, message is ${err.message}`);
988})
989```
990
991### actionNames<sup>(deprecated)</sup>
992
993actionNames(callback: AsyncCallback\<Array\<string>>): void;
994
995Obtains the names of all actions supported by this element. This API uses an asynchronous callback to return the result.
996
997> **NOTE**
998>
999> This API is deprecated since API version 12.
1000
1001**System capability**: SystemCapability.BarrierFree.Accessibility.Core
1002
1003**Parameters**
1004
1005| Name     | Type                                      | Mandatory  | Description                   |
1006| -------- | ---------------------------------------- | ---- | --------------------- |
1007| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes   | Callback used to return the names of all actions supported by the element.|
1008
1009**Example**
1010
1011```ts
1012// rootElement is an instance of AccessibilityElement.
1013rootElement.actionNames((err: BusinessError, data: string[]) => {
1014  if (err && err.code) {
1015    console.error(`failed to get action names, Code is ${err.code}, message is ${err.message}`);
1016    return;
1017  }
1018  console.info(`Succeeded in get action names, ${JSON.stringify(data)}`);
1019})
1020```
1021
1022### performAction<sup>(deprecated)</sup>
1023
1024performAction(actionName: string, parameters?: object): Promise\<void>;
1025
1026Performs an action based on the specified action name. This API uses a promise to return the result.
1027
1028> **NOTE**
1029>
1030> This API is deprecated since API version 12.
1031
1032**System capability**: SystemCapability.BarrierFree.Accessibility.Core
1033
1034**Parameters**
1035
1036| Name        | Type                                    | Mandatory  | Description      |
1037| ----------- | ---------------------------------------- | ---- |----------------------------------------------------------|
1038| actionName | string | Yes   | Action name. For details, see [Action](./js-apis-accessibility.md#action). |
1039| parameters | object | No   | Parameters required for performing the target action. Empty by default.                            |
1040
1041**Return value**
1042
1043| Type                 | Description              |
1044| ------------------- | ---------------- |
1045| Promise&lt;void&gt; | Promise that returns no value.|
1046
1047**Error codes**
1048
1049For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
1050
1051| ID  | Error Message                         |
1052| ------- | ----------------------------- |
1053| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1054| 9300005 | This action is not supported. |
1055
1056**Example**
1057
1058```ts
1059import { BusinessError } from '@kit.BasicServicesKit';
1060
1061let actionName = 'action';
1062
1063// rootElement is an instance of AccessibilityElement.
1064rootElement.performAction(actionName).then(() => {
1065  console.info(`Succeeded in perform action,actionName is ${actionName}`);
1066}).catch((err: BusinessError) => {
1067  console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1068});
1069```
1070
1071**Example of an action without parameters:**
1072
1073```ts
1074import { BusinessError } from '@kit.BasicServicesKit';
1075
1076// rootElement is an instance of AccessibilityElement.
1077// An action that does not require any parameter setting is an action without parameters, as specified in the action description.
1078rootElement.performAction('click').then(() => {
1079  console.info(`Succeeded in perform action.`);
1080}).catch((err: BusinessError) => {
1081  console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1082});
1083```
1084
1085**Example of an action with parameters:**
1086
1087```ts
1088import { BusinessError } from '@kit.BasicServicesKit';
1089
1090// rootElement is an instance of AccessibilityElement.
1091// Sample code of setSelection
1092rootElement.performAction('setSelection', {
1093  selectTextBegin: '0', // Indicates the start position of selection.
1094  selectTextEnd: '8',   // Indicates the end position of selection.
1095  selectTextInForWard: true   // true indicates the insertion point, and false indicates the selection range.
1096}).then(() => {
1097  console.info(`Succeeded in perform action`);
1098}).catch((err: BusinessError) => {
1099  console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1100});
1101```
1102
1103```ts
1104import { BusinessError } from '@kit.BasicServicesKit';
1105
1106// rootElement is an instance of AccessibilityElement.
1107// Sample code of setCursorPosition
1108rootElement.performAction('setCursorPosition', {
1109  offset: '1'   // Position of the cursor.
1110}).then(() => {
1111  console.info(`Succeeded in perform action`);
1112}).catch((err: BusinessError) => {
1113  console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1114});
1115```
1116
1117### performAction<sup>(deprecated)</sup>
1118
1119performAction(actionName: string, callback: AsyncCallback\<void>): void;
1120
1121Performs an action based on the specified action name. This API uses an asynchronous callback to return the result.
1122
1123> **NOTE**
1124>
1125> This API is deprecated since API version 12.
1126
1127**System capability**: SystemCapability.BarrierFree.Accessibility.Core
1128
1129**Parameters**
1130
1131| Name        | Type                                    | Mandatory  | Description            |
1132| ----------- | ---------------------------------------- | ---- | -------------- |
1133| actionName | string | Yes   | Action name. For details, see [Action](./js-apis-accessibility.md#action). |
1134| callback | AsyncCallback&lt;void&gt; | Yes   | Callback used to return the result.|
1135
1136**Error codes**
1137
1138For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
1139
1140| ID  | Error Message                         |
1141| ------- | ----------------------------- |
1142| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1143| 9300005 | This action is not supported. |
1144
1145**Example**
1146
1147```ts
1148import { BusinessError } from '@kit.BasicServicesKit';
1149
1150let actionName = 'action';
1151
1152// rootElement is an instance of AccessibilityElement.
1153rootElement.performAction(actionName, (err: BusinessError) => {
1154  if (err && err.code) {
1155    console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1156    return;
1157  }
1158  console.info(`Succeeded in perform action, actionName is ${actionName}`);
1159});
1160```
1161
1162### performAction<sup>(deprecated)</sup>
1163
1164performAction(actionName: string, parameters: object, callback: AsyncCallback\<void>): void;
1165
1166Performs an action based on the specified action name. This API uses an asynchronous callback to return the result.
1167
1168> **NOTE**
1169>
1170> This API is deprecated since API version 12.
1171
1172**System capability**: SystemCapability.BarrierFree.Accessibility.Core
1173
1174**Parameters**
1175
1176| Name       | Type                       | Mandatory  | Description                                                         |
1177| ---------- | ------------------------- | ---- |-------------------------------------------------------------|
1178| actionName | string                    | Yes   | Action name. For details, see [Action](./js-apis-accessibility.md#action).|
1179| parameters | object                    | Yes   | Parameters required for performing the target action. Empty by default.                               |
1180| callback   | AsyncCallback&lt;void&gt; | Yes   | Callback used to return the result.                                          |
1181
1182**Error codes**
1183
1184For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
1185
1186| ID  | Error Message                         |
1187| ------- | ----------------------------- |
1188| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1189| 9300005 | This action is not supported. |
1190
1191**Example**
1192
1193```ts
1194import { BusinessError } from '@kit.BasicServicesKit';
1195
1196let actionName = 'action';
1197let parameters: object = [];
1198
1199// rootElement is an instance of AccessibilityElement.
1200rootElement.performAction(actionName, parameters, (err: BusinessError) => {
1201  if (err && err.code) {
1202    console.error(`failed to perform action, Code is ${err.code}, message is ${err.message}`);
1203    return;
1204  }
1205  console.info(`Succeeded in perform action,actionName is ${actionName}, parameters is ${parameters}`);
1206});
1207```
1208
1209### findElement('content')<sup>(deprecated)</sup>
1210
1211findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityElement>>;
1212
1213Finds an element based on the content type. This API uses a promise to return the result.
1214
1215> **NOTE**
1216>
1217> This API is deprecated since API version 12.
1218
1219**System capability**: SystemCapability.BarrierFree.Accessibility.Core
1220
1221**Parameters**
1222
1223| Name      | Type    | Mandatory  | Description                           |
1224| --------- | ------ | ---- | ----------------------------- |
1225| type      | string | Yes   | Type of element finding. The value is fixed at **'content'**.|
1226| condition | string | Yes   | Search criteria.                     |
1227
1228**Return value**
1229
1230| Type                                      | Description                           |
1231| ---------------------------------------- | ----------------------------- |
1232| Promise&lt;Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;&gt; | Promise used to return the result.|
1233
1234**Error codes**
1235
1236For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
1237
1238| ID  | Error Message                         |
1239| ------- | ----------------------------- |
1240| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1241
1242**Example**
1243
1244```ts
1245import { BusinessError } from '@kit.BasicServicesKit';
1246
1247let condition = 'keyword';
1248
1249// rootElement is an instance of AccessibilityElement.
1250rootElement.findElement('content', condition).then((data: AccessibilityElement[]) => {
1251  console.log(`Succeeded in find element, ${JSON.stringify(data)}`);
1252}).catch((err: BusinessError) => {
1253  console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1254});
1255```
1256
1257### findElement('content')<sup>(deprecated)</sup>
1258
1259findElement(type: 'content', condition: string, callback: AsyncCallback\<Array\<AccessibilityElement>>): void;
1260
1261Finds an element based on the content type. This API uses an asynchronous callback to return the result.
1262
1263> **NOTE**
1264>
1265> This API is deprecated since API version 12.
1266
1267**System capability**: SystemCapability.BarrierFree.Accessibility.Core
1268
1269**Parameters**
1270
1271| Name      | Type                                      | Mandatory  | Description                          |
1272| --------- | ---------------------------------------- | ---- | ---------------------------- |
1273| type      | string                                   | Yes   | Type of element finding. The value is fixed at **'content'**.|
1274| condition | string                                   | Yes   | Search criteria.                    |
1275| callback  | AsyncCallback&lt;Array&lt;[AccessibilityElement](#accessibilityelement9)&gt;&gt; | Yes   | Callback used to return the result.    |
1276
1277**Error codes**
1278
1279For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
1280
1281| ID  | Error Message                         |
1282| ------- | ----------------------------- |
1283| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1284
1285**Example**
1286
1287```ts
1288import { BusinessError } from '@kit.BasicServicesKit';
1289
1290let condition = 'keyword';
1291
1292// rootElement is an instance of AccessibilityElement.
1293rootElement.findElement('content', condition, (err: BusinessError, data: AccessibilityElement[])=>{
1294  if (err && err.code) {
1295    console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1296    return;
1297  }
1298  console.info(`Succeeded in find element, ${JSON.stringify(data)}`);
1299});
1300```
1301
1302### findElement('focusType')<sup>(deprecated)</sup>
1303
1304findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElement>;
1305
1306Finds an element based on the focus type. This API uses a promise to return the result.
1307
1308> **NOTE**
1309>
1310> This API is deprecated since API version 12.
1311
1312**System capability**: SystemCapability.BarrierFree.Accessibility.Core
1313
1314**Parameters**
1315
1316| Name      | Type                     | Mandatory  | Description                                |
1317| --------- | ----------------------- | ---- | ---------------------------------- |
1318| type      | string                  | Yes   | Type of element finding. The value is fixed at **'focusType'**.|
1319| condition | [FocusType](#focustype) | Yes   | Focus type.                      |
1320
1321**Return value**
1322
1323| Type                                 | Description                            |
1324| ----------------------------------- | ------------------------------ |
1325| Promise&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Promise used to return the result.|
1326
1327**Error codes**
1328
1329For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
1330
1331| ID  | Error Message                         |
1332| ------- | ----------------------------- |
1333| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1334
1335**Example**
1336
1337```ts
1338import { FocusType } from '@kit.AccessibilityKit';
1339import { BusinessError } from '@kit.BasicServicesKit';
1340
1341let condition: FocusType = 'normal';
1342
1343// rootElement is an instance of AccessibilityElement.
1344rootElement.findElement('focusType', condition).then((data: AccessibilityElement) => {
1345  console.log(`Succeeded in find element,${JSON.stringify(data)}`);
1346}).catch((err: BusinessError) => {
1347  console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1348});
1349```
1350
1351### findElement('focusType')<sup>(deprecated)</sup>
1352
1353findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<AccessibilityElement>): void;
1354
1355Finds an element based on the focus type. This API uses an asynchronous callback to return the result.
1356
1357> **NOTE**
1358>
1359> This API is deprecated since API version 12.
1360
1361**System capability**: SystemCapability.BarrierFree.Accessibility.Core
1362
1363**Parameters**
1364
1365| Name      | Type                                      | Mandatory  | Description                                |
1366| --------- | ---------------------------------------- | ---- | ---------------------------------- |
1367| type      | string                                   | Yes   | Type of element finding. The value is fixed at **'focusType'**.|
1368| condition | [FocusType](#focustype)                  | Yes   | Focus type.                      |
1369| callback  | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Yes   | Callback used to return the result.         |
1370
1371**Error codes**
1372
1373For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
1374
1375| ID  | Error Message                         |
1376| ------- | ----------------------------- |
1377| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1378
1379**Example**
1380
1381```ts
1382import { FocusType } from '@kit.AccessibilityKit';
1383import { BusinessError } from '@kit.BasicServicesKit';
1384
1385let condition: FocusType = 'normal';
1386
1387// rootElement is an instance of AccessibilityElement.
1388rootElement.findElement('focusType', condition, (err: BusinessError, data: AccessibilityElement)=>{
1389  if (err && err.code) {
1390    console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1391    return;
1392  }
1393  console.info(`Succeeded in find element, ${JSON.stringify(data)}`);
1394});
1395```
1396
1397### findElement('focusDirection')<sup>(deprecated)</sup>
1398
1399findElement(type: 'focusDirection', condition: FocusDirection): Promise\<AccessibilityElement>;
1400
1401Finds an element based on the focus direction. This API uses a promise to return the result.
1402
1403> **NOTE**
1404>
1405> This API is deprecated since API version 12.
1406
1407**System capability**: SystemCapability.BarrierFree.Accessibility.Core
1408
1409**Parameters**
1410
1411| Name      | Type                               | Mandatory  | Description                                      |
1412| --------- | --------------------------------- | ---- | ---------------------------------------- |
1413| type      | string                            | Yes   | Type of element finding. The value is fixed at **'focusDirection'**.|
1414| condition | [FocusDirection](#focusdirection) | Yes   | Focus direction.                          |
1415
1416**Return value**
1417
1418| Type                                 | Description                              |
1419| ----------------------------------- | -------------------------------- |
1420| Promise&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Promise used to return the result.|
1421
1422**Error codes**
1423
1424For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
1425
1426| ID  | Error Message                         |
1427| ------- | ----------------------------- |
1428| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1429
1430**Example**
1431
1432```ts
1433import { FocusDirection } from '@kit.AccessibilityKit';
1434import { BusinessError } from '@kit.BasicServicesKit';
1435
1436let condition: FocusDirection = 'up';
1437
1438// rootElement is an instance of AccessibilityElement.
1439rootElement.findElement('focusDirection', condition).then((data: AccessibilityElement) => {
1440  console.log(`Succeeded in find element, ${JSON.stringify(data)}`);
1441}).catch((err: BusinessError) => {
1442  console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1443});
1444```
1445
1446### findElement('focusDirection')<sup>(deprecated)</sup>
1447
1448findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\<AccessibilityElement>): void;
1449
1450Finds an element based on the focus direction. This API uses an asynchronous callback to return the result.
1451
1452> **NOTE**
1453>
1454> This API is deprecated since API version 12.
1455
1456**System capability**: SystemCapability.BarrierFree.Accessibility.Core
1457
1458**Parameters**
1459
1460| Name      | Type                                      | Mandatory  | Description                                      |
1461| --------- | ---------------------------------------- | ---- | ---------------------------------------- |
1462| type      | string                                   | Yes   | Type of element finding. The value is fixed at **'focusDirection'**.|
1463| condition | [FocusDirection](#focusdirection)        | Yes   | Direction of the next focus element.                          |
1464| callback  | AsyncCallback&lt;[AccessibilityElement](#accessibilityelement9)&gt; | Yes   | Callback used to return the result.             |
1465
1466**Error codes**
1467
1468For details about the error codes, see [Accessibility Error Codes](errorcode-accessibility.md).
1469
1470| ID  | Error Message                         |
1471| ------- | ----------------------------- |
1472| 401  |Input parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1473
1474**Example**
1475
1476```ts
1477import { FocusDirection } from '@kit.AccessibilityKit';
1478import { BusinessError } from '@kit.BasicServicesKit';
1479
1480let condition: FocusDirection = 'up';
1481
1482// rootElement is an instance of AccessibilityElement.
1483rootElement.findElement('focusDirection', condition, (err: BusinessError, data: AccessibilityElement) =>{
1484  if (err && err.code) {
1485    console.error(`failed to find element, Code is ${err.code}, message is ${err.message}`);
1486    return;
1487  }
1488  console.info(`Succeeded in find element, ${JSON.stringify(data)}`);
1489});
1490```
1491