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