@@ -20,16 +20,29 @@ export async function active(this: AndroidUiautomator2Driver): Promise<AppiumEle
2020 * @param elementId - ID of the element.
2121 * @returns The attribute value as a string.
2222 */
23- export async function getAttribute ( this : AndroidUiautomator2Driver , attribute : string , elementId : string ) : Promise < string > {
24- return String ( await this . uiautomator2 . jwproxy . command ( `/element/${ elementId } /attribute/${ attribute } ` , 'GET' , { } ) ) ;
23+ export async function getAttribute (
24+ this : AndroidUiautomator2Driver ,
25+ attribute : string ,
26+ elementId : string ,
27+ ) : Promise < string > {
28+ return String (
29+ await this . uiautomator2 . jwproxy . command (
30+ `/element/${ elementId } /attribute/${ attribute } ` ,
31+ 'GET' ,
32+ { } ,
33+ ) ,
34+ ) ;
2535}
2636
2737/**
2838 * Returns whether the element is displayed.
2939 * @param elementId - ID of the element.
3040 * @returns True if the element is displayed, false otherwise.
3141 */
32- export async function elementDisplayed ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < boolean > {
42+ export async function elementDisplayed (
43+ this : AndroidUiautomator2Driver ,
44+ elementId : string ,
45+ ) : Promise < boolean > {
3346 return toBool ( await this . getAttribute ( 'displayed' , elementId ) ) ;
3447}
3548
@@ -38,7 +51,10 @@ export async function elementDisplayed(this: AndroidUiautomator2Driver, elementI
3851 * @param elementId - ID of the element.
3952 * @returns True if the element is enabled, false otherwise.
4053 */
41- export async function elementEnabled ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < boolean > {
54+ export async function elementEnabled (
55+ this : AndroidUiautomator2Driver ,
56+ elementId : string ,
57+ ) : Promise < boolean > {
4258 return toBool ( await this . getAttribute ( 'enabled' , elementId ) ) ;
4359}
4460
@@ -47,7 +63,10 @@ export async function elementEnabled(this: AndroidUiautomator2Driver, elementId:
4763 * @param elementId - ID of the element.
4864 * @returns True if the element is selected, false otherwise.
4965 */
50- export async function elementSelected ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < boolean > {
66+ export async function elementSelected (
67+ this : AndroidUiautomator2Driver ,
68+ elementId : string ,
69+ ) : Promise < boolean > {
5170 return toBool ( await this . getAttribute ( 'selected' , elementId ) ) ;
5271}
5372
@@ -57,16 +76,27 @@ export async function elementSelected(this: AndroidUiautomator2Driver, elementId
5776 * @returns The element tag name.
5877 */
5978export async function getName ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < string > {
60- return ( await this . uiautomator2 . jwproxy . command ( `/element/${ elementId } /name` , 'GET' , { } ) ) as string ;
79+ return ( await this . uiautomator2 . jwproxy . command (
80+ `/element/${ elementId } /name` ,
81+ 'GET' ,
82+ { } ,
83+ ) ) as string ;
6184}
6285
6386/**
6487 * Gets the element location.
6588 * @param elementId - ID of the element.
6689 * @returns The element position coordinates (x, y).
6790 */
68- export async function getLocation ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < Position > {
69- return ( await this . uiautomator2 . jwproxy . command ( `/element/${ elementId } /location` , 'GET' , { } ) ) as Position ;
91+ export async function getLocation (
92+ this : AndroidUiautomator2Driver ,
93+ elementId : string ,
94+ ) : Promise < Position > {
95+ return ( await this . uiautomator2 . jwproxy . command (
96+ `/element/${ elementId } /location` ,
97+ 'GET' ,
98+ { } ,
99+ ) ) as Position ;
70100}
71101
72102/**
@@ -82,7 +112,10 @@ export async function getSize(this: AndroidUiautomator2Driver, elementId: string
82112 * Sets the value of an element using the upstream driver API.
83113 * @param params - Options containing the element ID and value to set.
84114 */
85- export async function doSetElementValue ( this : AndroidUiautomator2Driver , params : DoSetElementValueOpts ) : Promise < void > {
115+ export async function doSetElementValue (
116+ this : AndroidUiautomator2Driver ,
117+ params : DoSetElementValueOpts ,
118+ ) : Promise < void > {
86119 await this . uiautomator2 . jwproxy . command ( `/element/${ params . elementId } /value` , 'POST' , params ) ;
87120}
88121
@@ -125,8 +158,13 @@ export async function click(this: AndroidUiautomator2Driver, element: string): P
125158 * @param element - ID of the element.
126159 * @returns Base64-encoded PNG screenshot of the element.
127160 */
128- export async function getElementScreenshot ( this : AndroidUiautomator2Driver , element : string ) : Promise < string > {
129- return String ( await this . uiautomator2 . jwproxy . command ( `/element/${ element } /screenshot` , 'GET' , { } ) ) ;
161+ export async function getElementScreenshot (
162+ this : AndroidUiautomator2Driver ,
163+ element : string ,
164+ ) : Promise < string > {
165+ return String (
166+ await this . uiautomator2 . jwproxy . command ( `/element/${ element } /screenshot` , 'GET' , { } ) ,
167+ ) ;
130168}
131169
132170/**
@@ -142,7 +180,10 @@ export async function clear(this: AndroidUiautomator2Driver, elementId: string):
142180 * @param elementId - ID of the element.
143181 * @returns The element rectangle (x, y, width, height).
144182 */
145- export async function getElementRect ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < Rect > {
183+ export async function getElementRect (
184+ this : AndroidUiautomator2Driver ,
185+ elementId : string ,
186+ ) : Promise < Rect > {
146187 if ( ! this . isWebContext ( ) ) {
147188 return ( await this . uiautomator2 . jwproxy . command ( `/element/${ elementId } /rect` , 'GET' ) ) as Rect ;
148189 }
@@ -177,4 +218,3 @@ export async function mobileReplaceElementValue(
177218function toBool ( value : any ) : boolean {
178219 return _ . isString ( value ) ? value . toLowerCase ( ) === 'true' : ! ! value ;
179220}
180-
0 commit comments