1- import { PROTOCOLS } from 'appium/driver.js' ;
2- import type { DoSetElementValueOpts } from 'appium-android-driver' ;
31import type { Element as AppiumElement , Position , Rect , Size } from '@appium/types' ;
4- import type { AndroidUiautomator2Driver } from '../ driver.js ' ;
2+ import type { DoSetElementValueOpts } from 'appium-android- driver' ;
53import type { Chromedriver } from 'appium-chromedriver' ;
4+ import { PROTOCOLS } from 'appium/driver.js' ;
5+
6+ import type { AndroidUiautomator2Driver } from '../driver.js' ;
67
78/**
89 * Gets the currently active element.
@@ -23,24 +24,15 @@ export async function getAttribute(
2324 attribute : string ,
2425 elementId : string ,
2526) : Promise < string > {
26- return String (
27- await this . uiautomator2 . jwproxy . command (
28- `/element/${ elementId } /attribute/${ attribute } ` ,
29- 'GET' ,
30- { } ,
31- ) ,
32- ) ;
27+ return String ( await this . uiautomator2 . jwproxy . command ( `/element/${ elementId } /attribute/${ attribute } ` , 'GET' , { } ) ) ;
3328}
3429
3530/**
3631 * Returns whether the element is displayed.
3732 * @param elementId - ID of the element.
3833 * @returns True if the element is displayed, false otherwise.
3934 */
40- export async function elementDisplayed (
41- this : AndroidUiautomator2Driver ,
42- elementId : string ,
43- ) : Promise < boolean > {
35+ export async function elementDisplayed ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < boolean > {
4436 return toBool ( await this . getAttribute ( 'displayed' , elementId ) ) ;
4537}
4638
@@ -49,10 +41,7 @@ export async function elementDisplayed(
4941 * @param elementId - ID of the element.
5042 * @returns True if the element is enabled, false otherwise.
5143 */
52- export async function elementEnabled (
53- this : AndroidUiautomator2Driver ,
54- elementId : string ,
55- ) : Promise < boolean > {
44+ export async function elementEnabled ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < boolean > {
5645 return toBool ( await this . getAttribute ( 'enabled' , elementId ) ) ;
5746}
5847
@@ -61,10 +50,7 @@ export async function elementEnabled(
6150 * @param elementId - ID of the element.
6251 * @returns True if the element is selected, false otherwise.
6352 */
64- export async function elementSelected (
65- this : AndroidUiautomator2Driver ,
66- elementId : string ,
67- ) : Promise < boolean > {
53+ export async function elementSelected ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < boolean > {
6854 return toBool ( await this . getAttribute ( 'selected' , elementId ) ) ;
6955}
7056
@@ -74,27 +60,16 @@ export async function elementSelected(
7460 * @returns The element tag name.
7561 */
7662export async function getName ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < string > {
77- return ( await this . uiautomator2 . jwproxy . command (
78- `/element/${ elementId } /name` ,
79- 'GET' ,
80- { } ,
81- ) ) as string ;
63+ return ( await this . uiautomator2 . jwproxy . command ( `/element/${ elementId } /name` , 'GET' , { } ) ) as string ;
8264}
8365
8466/**
8567 * Gets the element location.
8668 * @param elementId - ID of the element.
8769 * @returns The element position coordinates (x, y).
8870 */
89- export async function getLocation (
90- this : AndroidUiautomator2Driver ,
91- elementId : string ,
92- ) : Promise < Position > {
93- return ( await this . uiautomator2 . jwproxy . command (
94- `/element/${ elementId } /location` ,
95- 'GET' ,
96- { } ,
97- ) ) as Position ;
71+ export async function getLocation ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < Position > {
72+ return ( await this . uiautomator2 . jwproxy . command ( `/element/${ elementId } /location` , 'GET' , { } ) ) as Position ;
9873}
9974
10075/**
@@ -110,10 +85,7 @@ export async function getSize(this: AndroidUiautomator2Driver, elementId: string
11085 * Sets the value of an element using the upstream driver API.
11186 * @param params - Options containing the element ID and value to set.
11287 */
113- export async function doSetElementValue (
114- this : AndroidUiautomator2Driver ,
115- params : DoSetElementValueOpts ,
116- ) : Promise < void > {
88+ export async function doSetElementValue ( this : AndroidUiautomator2Driver , params : DoSetElementValueOpts ) : Promise < void > {
11789 await this . uiautomator2 . jwproxy . command ( `/element/${ params . elementId } /value` , 'POST' , params ) ;
11890}
11991
@@ -156,13 +128,8 @@ export async function click(this: AndroidUiautomator2Driver, element: string): P
156128 * @param element - ID of the element.
157129 * @returns Base64-encoded PNG screenshot of the element.
158130 */
159- export async function getElementScreenshot (
160- this : AndroidUiautomator2Driver ,
161- element : string ,
162- ) : Promise < string > {
163- return String (
164- await this . uiautomator2 . jwproxy . command ( `/element/${ element } /screenshot` , 'GET' , { } ) ,
165- ) ;
131+ export async function getElementScreenshot ( this : AndroidUiautomator2Driver , element : string ) : Promise < string > {
132+ return String ( await this . uiautomator2 . jwproxy . command ( `/element/${ element } /screenshot` , 'GET' , { } ) ) ;
166133}
167134
168135/**
@@ -178,10 +145,7 @@ export async function clear(this: AndroidUiautomator2Driver, elementId: string):
178145 * @param elementId - ID of the element.
179146 * @returns The element rectangle (x, y, width, height).
180147 */
181- export async function getElementRect (
182- this : AndroidUiautomator2Driver ,
183- elementId : string ,
184- ) : Promise < Rect > {
148+ export async function getElementRect ( this : AndroidUiautomator2Driver , elementId : string ) : Promise < Rect > {
185149 if ( ! this . isWebContext ( ) ) {
186150 return ( await this . uiautomator2 . jwproxy . command ( `/element/${ elementId } /rect` , 'GET' ) ) as Rect ;
187151 }
0 commit comments