diff --git a/api/@ohos.uitest.d.ts b/api/@ohos.uitest.d.ts index c7582608738c10ab6f8d0237113bbdbe10540dff..eeb34b69b9c969162092a90b60b76e664fcae2fc 100644 --- a/api/@ohos.uitest.d.ts +++ b/api/@ohos.uitest.d.ts @@ -14,590 +14,1114 @@ */ /** - * Resize direction for the window. + * Enumerates the string value match pattern. * @syscap SystemCapability.Test.UiTest - * @since 9 + * @since 8 */ - declare enum ResizeDirection{ - LEFT, - RIGHT, - UP, - DOWN, - LEFT_UP, - LEFT_DOWN, - RIGHT_UP, - RIGHT_DOWN - } +declare enum MatchPattern { + /** + * Equals to a string. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + EQUALS = 0, + /** + * Contains a substring. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + CONTAINS = 1, + /** + * StartsWith a substring. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + STARTS_WITH = 2, + /** + * EndsWith a substring. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @test + */ + ENDS_WITH = 3 +} + /** - * Enumerates the string value match pattern. + * Describes the attribute requirements for the target UiComponents. + * + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.On * @syscap SystemCapability.Test.UiTest + */ +declare class By { + /** + * Specifies the text for the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param txt The text value. + * @param pattern The {@link MatchPattern} of the text value,default to {@link MatchPattern.EQUALS} + * @return Returns this {@link By} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.On#text + * @test + */ + text(txt: string, pattern?: MatchPattern): By; + + /** + * Specifies the inspector key of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param key The inspectorKey value. + * @return Returns this {@link By} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.On#id + * @test + */ + key(key: string): By; + + /** + * Specifies the id of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param id The id value. + * @return Returns this {@link By} object. + * @since 8 + * @deprecated since 9 + * @test + */ + id(id: number): By; + + /** + * Specifies the type of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param tp The type value. + * @return Returns this {@link By} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.On#type + * @test + */ + type(tp: string): By; + + /** + * Specifies the clickable status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b The clickable status,default to true. + * @return Returns this {@link By} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.On#clickable + * @test + */ + clickable(b?: boolean): By; + + /** + * Specifies the scrollable status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b The scrollable status,default to true. + * @return Returns this {@link By} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.On#scrollable + * @test + */ + scrollable(b?: boolean): By; + + /** + * Specifies the enabled status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b The enabled status,default to true. + * @return Returns this {@link By} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.On#enabled + * @test + */ + enabled(b?: boolean): By; + + /** + * Specifies the focused status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b The focused status,default to true. + * @return Returns this {@link By} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.On#focused + * @test + */ + focused(b?: boolean): By; + + /** + * Specifies the selected status of the target UiComponent. + * @syscap SystemCapability.Test.UiTest + * @param b The selected status,default to true. + * @return Returns this {@link By} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.On#selected + * @test + */ + selected(b?: boolean): By; + + /** + * Requires the target UiComponent which is before another UiComponent that specified by the given {@link By} + * object,used to locate UiComponent relatively. + * @syscap SystemCapability.Test.UiTest + * @param by Describes the attribute requirements of UiComponent which the target one is in front of. + * @return Returns this {@link By} object. + * @since 8 + * @deprecated since 9 + * @useinstead {@link On.isBefore} + * @test + */ + isBefore(by: By): By; + + /** + * Requires the target UiComponent which is after another UiComponent that specified by the given {@link By} + * object,used to locate UiComponent relatively. + * @syscap SystemCapability.Test.UiTest + * @param by Describes the attribute requirements of UiComponent which the target one is in back of. + * @return Returns this {@link By} object. + * @since 8 + * @deprecated since 9 + * @useinstead {@link On.isAfter} + * @test + */ + isAfter(by: By): By; +} + +/** + * Represents a UiComponent of the ohos application,user can perform operations or query attributes on it. + * * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.Component + * @test + * @syscap SystemCapability.Test.UiTest */ - declare enum MatchPattern{ - /** - * Equals to a string. - * @syscap SystemCapability.Test.UiTest - * @since 8 - * @test - */ - EQUALS = 0, - /** - * Contains a substring. - * @syscap SystemCapability.Test.UiTest - * @since 8 - * @test - */ - CONTAINS = 1, - /** - * StartsWith a substring. - * @syscap SystemCapability.Test.UiTest - * @since 8 - * @test - */ - STARTS_WITH = 2, - /** - * EndsWith a substring. - * @syscap SystemCapability.Test.UiTest - * @since 8 - * @test - */ - ENDS_WITH = 3 +declare class UiComponent { + /** + * Click this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.Component#click + * @test + */ + click(): Promise; + + /** + * Double click this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.doubleClick} + * @test + */ + doubleClick(): Promise; + + /** + * Long click this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.longClick} + * @test + */ + longClick(): Promise; + + /** + * Get the id attribute value. + * @syscap SystemCapability.Test.UiTest + * @returns the id value. + * @since 8 + * @deprecated since 9 + * @test + */ + getId(): Promise; + + /** + * Get the inspectorKey attribute value. + * @syscap SystemCapability.Test.UiTest + * @returns the inspectorKey value. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.getId} + * @test + */ + getKey(): Promise; + + /** + * Get the text attribute value. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.getText} + * @test + */ + getText(): Promise; + + /** + * Get the type name. + * @syscap SystemCapability.Test.UiTest + * @returns the type name. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.getType} + * @test + */ + getType(): Promise; + + /** + * Get the clickable status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the clickable status. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.isClickable} + * @test + */ + isClickable(): Promise; + + /** + * Get the scrollable status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the scrollable status. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.isScrollable} + * @test + */ + isScrollable(): Promise; + + /** + * Get the enabled status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the enabled status. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.isEnabled} + * @test + */ + isEnabled(): Promise; + + /** + * Get the focused status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the focused status. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.isFocused} + * @test + */ + isFocused(): Promise; + + /** + * Get the selected status of this {@link UiComponent}. + * @syscap SystemCapability.Test.UiTest + * @returns the selected status. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.isSelected} + * @test + */ + isSelected(): Promise; + + /** + * Inject text to this {@link UiComponent},applicable to TextInput. + * @syscap SystemCapability.Test.UiTest + * @param text The text to inject. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.inputText} + * @test + */ + inputText(text: string): Promise; + + /** + * Scroll on this {@link UiComponent}to find matched {@link UiComponent},applicable to scrollable one. + * @syscap SystemCapability.Test.UiTest + * @param by The attribute requirements of the target {@link UiComponent}. + * @return the found result,or undefined if not found. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Component.scrollSearch} + * @test + */ + scrollSearch(by: By): Promise; } +/** + * The unified facade of UiTest framework,can be used to find {@link UiComponent},trigger keyEvents,perform + * coordinates-based UI actions,capture screen and so on. + * + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.Driver + * @test + * @syscap SystemCapability.Test.UiTest + */ +declare class UiDriver { + /** + * Create an {@link UiDriver} object. + * @syscap SystemCapability.Test.UiTest + * @returns the {@link UiDriver} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.Driver#create + * @test + */ + static create(): UiDriver; + + /** + * Delay with specified duration. + * @syscap SystemCapability.Test.UiTest + * @param duration The delay duration in milliseconds. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Driver.delayMs} + * @test + */ + delayMs(duration: number): Promise; + + /** + * Find the first matched {@link UiComponent} on current UI. + * @syscap SystemCapability.Test.UiTest + * @param by The attribute requirements of the target {@link UiComponent}. + * @returns the first matched {@link UiComponent} or undefined. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Driver.findComponent} + * @test + */ + findComponent(by: By): Promise; + + /** + * Find all the matched {@link UiComponent}s on current UI. + * @syscap SystemCapability.Test.UiTest + * @param by The attribute requirements of the target {@link UiComponent}. + * @returns the matched {@link UiComponent}s list. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Driver.findComponents} + * @test + */ + findComponents(by: By): Promise>; + + /** + * Assert t the matched {@link UiComponent}s exists on current UI;if not,assertError will be raised. + * @syscap SystemCapability.Test.UiTest + * @param by The attribute requirements of the target {@link UiComponent}. + * @throws Throws this exception if following error occurs:{@code ComponentExistAssertion Failure}. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Driver.assertComponentExist} + * @test + */ + assertComponentExist(by: By): Promise; + + /** + * Press the BACK key. + * @syscap SystemCapability.Test.UiTest + * @since 8 + * @deprecated since 9 + * @useinstead {@link Driver.pressBack} + * @test + */ + pressBack(): Promise; + + /** + * Press the specified key. + * @syscap SystemCapability.Test.UiTest + * @param keyCode the target keyCode. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Driver.pressHome} + * @test + */ + triggerKey(keyCode: number): Promise; + + /** + * Click on the specified location on the screen. + * @syscap SystemCapability.Test.UiTest + * @param x The x-coordinate. + * @param y The y-coordinate. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.Driver#click + * @test + */ + click(x: number, y: number): Promise; + + /** + * DoubleClick on the specified location on the screen. + * @syscap SystemCapability.Test.UiTest + * @param x The x-coordinate. + * @param y The y-coordinate. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Driver.doubleClick} + * @test + */ + doubleClick(x: number, y: number): Promise; + + /** + * LongClick on the specified location on the screen. + * @syscap SystemCapability.Test.UiTest + * @param x The x-coordinate. + * @param y The y-coordinate. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Driver.longClick} + * @test + */ + longClick(x: number, y: number): Promise; + + /** + * Swipe on the screen between the specified points. + * @syscap SystemCapability.Test.UiTest + * @param startx The x-coordinate of the starting point. + * @param starty The y-coordinate of the starting point. + * @param endx The x-coordinate of the ending point. + * @param endy The y-coordinate of the ending point. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.Driver#swipe + * @test + */ + swipe(startx: number, starty: number, endx: number, endy: number): Promise; + + /** + * Capture current screen and save as picture which PNG format. + * @syscap SystemCapability.Test.UiTest + * @param savePath the path where to store the picture. + * @returns true if screen-capturing and file-storing are completed successfully,false otherwise. + * @since 8 + * @deprecated since 9 + * @useinstead {@link Driver.screenCap} + * @test + */ + screenCap(savePath: string): Promise; +} + + /** * Describes the window mode of the tested window * @syscap SystemCapability.Test.UiTest * @since 9 */ - declare enum WindowMode{ - FULLSCREEN, - PRIMARY, - SECONDARY, - FLOATING - } +declare enum WindowMode { + FULLSCREEN, + PRIMARY, + SECONDARY, + FLOATING +} + +/** + * Resize direction for the window. + * @syscap SystemCapability.Test.UiTest + * @since 9 + */ +declare enum ResizeDirection { + LEFT, + RIGHT, + UP, + DOWN, + LEFT_UP, + LEFT_DOWN, + RIGHT_UP, + RIGHT_DOWN +} + +/** + * Describes the rotation of the device display + * @syscap SystemCapability.Test.UiTest + * @since 9 + */ +declare enum DisplayRotation { + ROTATION_0, + ROTATION_90, + ROTATION_180, + ROTATION_270 +} + +/** + * Represents the point on the device screen. + * @syscap SystemCapability.Test.UiTest + * @since 9 + */ +declare interface Point { + readonly X: number; + readonly Y: number; +} + +/** + * Represents the rectangle area on the device screen. + * @syscap SystemCapability.Test.UiTest + * @since 9 + */ +declare interface Rect { + readonly leftX: number; + readonly topY: number; + readonly rightX: number; + readonly bottomY: number; +} + +/** + * Represents filer condition to get the window . + * @syscap SystemCapability.Test.UiTest + * @since 9 + */ +declare interface WindowFilter { + readonly bundleName?: string; + readonly title?: string; + readonly focused?: boolean; + readonly actived?: boolean; +} + +/** + * Describes the attribute requirements for the target Components. + * + * @since 9 + * @syscap SystemCapability.Test.UiTest + */ +declare class On { + /** + * Specifies the text for the target Component. + * @syscap SystemCapability.Test.UiTest + * @param txt The text value. + * @param pattern The {@link MatchPattern} of the text value, default to {@link MatchPattern.EQUALS} + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + text(txt: string, pattern?: MatchPattern): On; + + /** + * Specifies the id of the target Component. + * @syscap SystemCapability.Test.UiTest + * @param id The id value. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + id(id: string): On; + + /** + * Specifies the type of the target Component. + * @syscap SystemCapability.Test.UiTest + * @param tp The type value. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + type(tp: string): On; + + /** + * Specifies the clickable status of the target Component. + * @syscap SystemCapability.Test.UiTest + * @param b The clickable status,default to true. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + clickable(b?: boolean): On; + + /** + * Specifies the longClickable status of the target Component. + * @syscap SystemCapability.Test.UiTest + * @param b The clickable status,default to true. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + longClickable(b?: boolean): On; + + /** + * Specifies the scrollable status of the target Component. + * @syscap SystemCapability.Test.UiTest + * @param b The scrollable status,default to true. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + scrollable(b?: boolean): On; + + /** + * Specifies the enabled status of the target Component. + * @syscap SystemCapability.Test.UiTest + * @param b The enabled status,default to true. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + enabled(b?: boolean): On; + + /** + * Specifies the focused status of the target Component. + * @syscap SystemCapability.Test.UiTest + * @param b The focused status,default to true. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + focused(b?: boolean): On; + + /** + * Specifies the selected status of the target Component. + * @syscap SystemCapability.Test.UiTest + * @param b The selected status,default to true. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + selected(b?: boolean): On; + + /** + * Specifies the checked status of the target Component. + * @syscap SystemCapability.Test.UiTest + * @param b The checked status,default to false. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + checked(b?: boolean): On; -/** - * Describes the rotation of the device display - * @syscap SystemCapability.Test.UiTest - * @since 9 - */ -declare enum DisplayRotation { - ROTATION_0, - ROTATION_90, - ROTATION_180, - ROTATION_270 -} - -/** - * Represents the point on the device screen. - * @syscap SystemCapability.Test.UiTest - * @since 9 - */ -declare interface Point { - readonly X: number; - readonly Y: number; -} + /** + * Specifies the checkable status of the target Component. + * @syscap SystemCapability.Test.UiTest + * @param b The checkable status,default to false. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + checkable(b?: boolean): On; -/** - * Represents the rectangle area on the device screen. - * @syscap SystemCapability.Test.UiTest - * @since 9 - */ -declare interface Rect { - readonly leftX: number; - readonly topY: number; - readonly rightX: number; - readonly bottomY: number; -} + /** + * Requires that the target Component which is before another Component that specified by the given {@link On} + * object,used to locate Component relatively. + * @syscap SystemCapability.Test.UiTest + * @param on Describes the attribute requirements of Component which the target one is in front of. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + isBefore(on: On): On; -/** - * Represents filer condition to get the window . - * @syscap SystemCapability.Test.UiTest - * @since 9 - */ -declare interface WindowFilter { - readonly bundleName?: string; - readonly title?: string; - readonly focused?: boolean; - readonly actived?: boolean; + /** + * Requires that the target Component which is after another Component that specified by the given {@link On} + * object,used to locate Component relatively. + * @syscap SystemCapability.Test.UiTest + * @param on Describes the attribute requirements of Component which the target one is in back of. + * @return Returns this {@link On} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @since 9 + * @test + */ + isAfter(on: On): On; } /** - * Describes the attribute requirements for the target UiComponents. - * - * @since 8 - * @syscap SystemCapability.Test.UiTest - */ - declare class By{ - - /** - * Specifies the text for the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param txt the text value. - * @param pattern the {@link MatchPattern} of the text value,default to {@link MatchPattern.EQUALS} - * @return Returns this {@link By} object. - * @since 8 - * @test - */ - text(txt:string,pattern?:MatchPattern):By; - - /** - * Specifies the inspectorKey of the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param key the inspectorKey value. - * @return Returns this {@link By} object. - * @since 8 - * @test - */ - key(key:string):By; - - /** - * Specifies the id of the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param id the id value. - * @return Returns this {@link By} object. - * @since 8 - * @test - */ - id(id:number):By; - - /** - * Specifies the type of the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param tp the type value. - * @return Returns this {@link By} object. - * @since 8 - * @test - */ - type(tp:string):By; - - /** - * Specifies the clickable status of the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param b the clickable status,default to true. - * @return Returns this {@link By} object. - * @since 8 - * @test - */ - clickable(b?:boolean):By; - - /** - * Specifies the longClickable status of the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param b the clickable status,default to true. - * @return Returns this {@link By} object. - * @since 9 - * @test - */ - longClickable(b?: boolean): By; - - /** - * Specifies the scrollable status of the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param b the scrollable status,default to true. - * @return Returns this {@link By} object. - * @since 8 - * @test - */ - scrollable(b?:boolean):By; - - /** - * Specifies the enabled status of the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param b the enabled status,default to true. - * @return Returns this {@link By} object. - * @since 8 - * @test - */ - enabled(b?:boolean):By; - - /** - * Specifies the focused status of the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param b the focused status,default to true. - * @return Returns this {@link By} object. - * @since 8 - * @test - */ - focused(b?:boolean):By; - - /** - * Specifies the selected status of the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param b the selected status,default to true. - * @return Returns this {@link By} object. - * @since 8 - * @test - */ - selected(b?:boolean):By; - - /** - * Specifies the checked status of the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param b the checked status,default to false. - * @return Returns this {@link By} object. - * @since 9 - * @test - */ - checked(b?: boolean): By; - - /** - * Specifies the checkable status of the target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param b the checkable status,default to false. - * @return Returns this {@link By} object. - * @since 9 - * @test - */ - checkable(b?: boolean): By; - - /** - * Requires that the target UiComponent which is before another UiComponent that specified by the given {@link By} - * object,used to locate UiComponent relatively. - * @syscap SystemCapability.Test.UiTest - * @param by describes the attribute requirements of UiComponent which the target one is in front of. - * @return Returns this {@link By} object. - * @since 8 - * @test - */ - isBefore(by:By):By; - - /** - * Requires that the target UiComponent which is after another UiComponent that specified by the given {@link By} - * object,used to locate UiComponent relatively. - * @syscap SystemCapability.Test.UiTest - * @param by describes the attribute requirements of UiComponent which the target one is in back of. - * @return Returns this {@link By} object. - * @since 8 - * @test - */ - isAfter(by:By):By; - } - -/** - * Represents a UiComponent of the ohos application,user can perform operations or query attributes on it. + * Represents an Component of the ohos application,user can perform operations or query attributes on it. * - * @since 8 + * @since 9 * @test * @syscap SystemCapability.Test.UiTest */ -declare class UiComponent{ - /** - * Click this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @since 8 - * @test - */ - click():Promise; - - /** - * Double click this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @since 8 - * @test - */ - doubleClick():Promise; - - /** - * Long click this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @since 8 - * @test - */ - longClick():Promise; - - /** - * Get the id attribute value. - * @syscap SystemCapability.Test.UiTest - * @returns the id value. - * @since 8 - * @test - */ - getId():Promise; - - /** - * Get the inspectorKey attribute value. - * @syscap SystemCapability.Test.UiTest - * @returns the inspectorKey value. - * @since 8 - * @test - */ - getKey():Promise; - - /** - * Get the text attribute value. - * @syscap SystemCapability.Test.UiTest - * @since 8 - * @test - */ - getText():Promise; - - /** - * Get the type name. - * @syscap SystemCapability.Test.UiTest - * @returns the type name. - * @since 8 - * @test - */ - getType():Promise; - - /** - * Get the clickable status of this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @returns the clickable status. - * @since 8 - * @test - */ - isClickable():Promise; - - /** - * Get the longClickable status of this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @returns the longClickable status. - * @since 9 - * @test - */ - isLongClickable(): Promise; - - /** - * Get the scrollable status of this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @returns the scrollable status. - * @since 8 - * @test - */ - isScrollable():Promise; - - /** - * Get the enabled status of this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @returns the enabled status. - * @since 8 - * @test - */ - isEnabled():Promise; - - /** - * Get the focused status of this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @returns the focused status. - * @since 8 - * @test - */ - isFocused():Promise; - - /** - * Get the selected status of this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @returns the selected status. - * @since 8 - * @test - */ - isSelected():Promise; - - /** - * Get the checked status of this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @returns the checked status. - * @since 9 - * @test - */ - isChecked(): Promise; - - /** - * Get the checkable status of this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @returns the checkable status. - * @since 9 - * @test - */ - isCheckable(): Promise; - - /** - * Inject text to this {@link UiComponent},applicable to TextInput. - * @syscap SystemCapability.Test.UiTest - * @param text the text to inject. - * @since 8 - * @test - */ - inputText(text: string):Promise; - - /** - * Clear text of this {@link UiComponent},applicable to TextInput. - * @syscap SystemCapability.Test.UiTest - * @since 9 - * @test - */ - clearText(): Promise; - - /** - * Scroll on this {@link UiComponent} to the top,applicable to scrollable one. - * @syscap SystemCapability.Test.UiTest - * @param speed the speed of swipe (pixels per second),default is 600,the value ranges from 200 to 3000,set it 600 if out of range. - * @since 9 - * @test - */ - scrollToTop(speed?: number): Promise; - - /** - * Scroll on this {@link UiComponent} to the bottom,applicable to scrollable one. - * @syscap SystemCapability.Test.UiTest - * @param speed the speed of swipe (pixels per second),default is 600,the value ranges from 200 to 3000,set it 600 if out of range. - * @since 9 - * @test - */ - scrollToBottom(speed?: number): Promise; - - /** - * Scroll on this {@link UiComponent}to find matched {@link UiComponent},applicable to scrollable one. - * @syscap SystemCapability.Test.UiTest - * @param by the attribute requirements of the target {@link UiComponent}. - * @return the found result,or undefined if not found. - * @since 8 - * @test - */ - scrollSearch(by:By):Promise; - - /** - * Get the bounds rect of this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @return the bounds rect object. - * @since 9 - * @test - */ - getBounds(): Promise; - - /** - * Get the boundsCenter of this {@link UiComponent}. - * @syscap SystemCapability.Test.UiTest - * @return the boundsCenter object. - * @since 9 - * @test - */ - getBoundsCenter(): Promise; - - /** - * Drag this {@link UiComponent} to the bounds rect of target UiComponent. - * @syscap SystemCapability.Test.UiTest - * @param target the target {@link UiComponent}. - * @since 9 - * @test - */ - dragTo(target: UiComponent): Promise; - - /** - * Pinch enlarge this {@link UiComponent} to the target scale. - * @syscap SystemCapability.Test.UiTest - * @param scale the scale of the pinch enlarge this {@link UiComponent}'s size. - * @since 9 - * @test - */ - pinchOut(scale: number): Promise; - - /** - * Pinch shrink this {@link UiComponent} to the target scale. - * @syscap SystemCapability.Test.UiTest - * @param scale the scale of the pinch shrink this {@link UiComponent}'s size. - * @since 9 - * @test - */ - pinchIn(scale: number): Promise; +declare class Component { + /** + * Click this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @since 9 + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @test + */ + click(): Promise; + + /** + * Double click this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @since 9 + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @test + */ + doubleClick(): Promise; + + /** + * Long click this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @since 9 + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @test + */ + longClick(): Promise; + + /** + * Get the id attribute value. + * @syscap SystemCapability.Test.UiTest + * @returns the id value. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + getId(): Promise; + + /** + * Get the text attribute value. + * @syscap SystemCapability.Test.UiTest + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + getText(): Promise; + + /** + * Get the type name. + * @syscap SystemCapability.Test.UiTest + * @returns the type name. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + getType(): Promise; + + /** + * Get the clickable status of this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @returns the clickable status. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + isClickable(): Promise; + + /** + * Get the longClickable status of this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @returns the longClickable status. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + isLongClickable(): Promise; + + /** + * Get the scrollable status of this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @returns the scrollable status. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + isScrollable(): Promise; + + /** + * Get the enabled status of this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @returns the enabled status. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + isEnabled(): Promise; + + /** + * Get the focused status of this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @returns the focused status. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + isFocused(): Promise; + + /** + * Get the selected status of this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @returns the selected status. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + isSelected(): Promise; + + /** + * Get the checked status of this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @returns the checked status. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + isChecked(): Promise; + + /** + * Get the checkable status of this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @returns the checkable status. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + isCheckable(): Promise; + + /** + * Inject text to this {@link Component},applicable to TextInput. + * @syscap SystemCapability.Test.UiTest + * @param text The text to inject. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + inputText(text: string): Promise; + + /** + * Clear text of this {@link Component},applicable to TextInput. + * @syscap SystemCapability.Test.UiTest + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + clearText(): Promise; + + /** + * Scroll on this {@link Component} to the top,applicable to scrollable one. + * @syscap SystemCapability.Test.UiTest + * @param speed The speed of swipe (pixels per second),default is 600,the value ranges from 200 to 15000,set it 600 if out of range. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + scrollToTop(speed?: number): Promise; + + /** + * Scroll on this {@link Component} to the bottom,applicable to scrollable one. + * @syscap SystemCapability.Test.UiTest + * @param speed The speed of swipe (pixels per second),default is 600,the value ranges from 200 to 15000,set it 600 if out of range. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + scrollToBottom(speed?: number): Promise; + + /** + * Scroll on this {@link Component}to find matched {@link Component},applicable to scrollable one. + * @syscap SystemCapability.Test.UiTest + * @param on The attribute requirements of the target {@link Component}. + * @return the found result,or undefined if not found. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + scrollSearch(on: On): Promise; + + /** + * Get the bounds rect of this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @return the bounds rect object. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + getBounds(): Promise; + + /** + * Get the boundsCenter of this {@link Component}. + * @syscap SystemCapability.Test.UiTest + * @return the boundsCenter object. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + getBoundsCenter(): Promise; + + /** + * Drag this {@link Component} to the bounds rect of target Component. + * @syscap SystemCapability.Test.UiTest + * @param target The target {@link Component}. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + dragTo(target: Component): Promise; + + /** + * Pinch enlarge this {@link Component} to the target scale. + * @syscap SystemCapability.Test.UiTest + * @param scale The scale of the pinch enlarge this {@link Component}'s size. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + pinchOut(scale: number): Promise; + + /** + * Pinch shrink this {@link Component} to the target scale. + * @syscap SystemCapability.Test.UiTest + * @param scale The scale of the pinch shrink this {@link Component}'s size. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. + * @since 9 + * @test + */ + pinchIn(scale: number): Promise; } /** - * The unified facade of UiTest framework,can be used to find {@link UiComponent},trigger keyEvents,perform + * The unified facade of UiTest framework,can be used to find {@link Component},trigger keyEvents,perform * coordinates-based UI actions,capture screen and so on. * - * @since 8 + * @since 9 * @test * @syscap SystemCapability.Test.UiTest */ - declare class UiDriver{ +declare class Driver { /** - * Create an {@link UiDriver} object. + * Create an {@link Driver} object. * @syscap SystemCapability.Test.UiTest - * @returns the {@link UiDriver} object. - * @since 8 + * @returns the {@link Driver} object. + * @throws {BusinessError} 17000001 - if the test framework failed to initialize. + * @since 9 * @test */ - static create():UiDriver; + static create(): Driver; /** * Delay with specified duration. * @syscap SystemCapability.Test.UiTest - * @param duration the delay duration in milliseconds. - * @since 8 + * @param duration The delay duration in milliseconds. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @since 9 * @test */ - delayMs(duration:number):Promise; + delayMs(duration: number): Promise; /** - * Find the first matched {@link UiComponent} on current UI. + * Find the first matched {@link Component} on current UI. * @syscap SystemCapability.Test.UiTest - * @param by the attribute requirements of the target {@link UiComponent}. - * @returns the first matched {@link UiComponent} or undefined. - * @since 8 + * @param on The attribute requirements of the target {@link Component}. + * @returns the first matched {@link Component} or undefined. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @since 9 * @test */ - findComponent(by:By):Promise; + findComponent(on: On): Promise; /** * Find the first matched {@link UiWindow} window. * @syscap SystemCapability.Test.UiTest - * @param filter the filer condition of the target {@link UiWindow}. + * @param filter The filer condition of the target {@link UiWindow}. * @returns the first matched {@link UiWindow} or undefined. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - findWindow(filter:WindowFilter):Promise; + findWindow(filter: WindowFilter): Promise; /** - * Find the first matched {@link UiComponent} on current UI during the time given. + * Find the first matched {@link Component} on current UI during the time given. * @syscap SystemCapability.Test.UiTest - * @param by the attribute requirements of the target {@link UiComponent}. - * @param time duration of finding in milliseconds - * @returns the first matched {@link UiComponent} or undefined. + * @param on The attribute requirements of the target {@link Component}. + * @param time Duration of finding in milliseconds + * @returns the first matched {@link Component} or undefined. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - waitForComponent(by: By, time: number): Promise; + waitForComponent(on: On, time: number): Promise; /** - * Find all the matched {@link UiComponent}s on current UI. + * Find all the matched {@link Component}s on current UI. * @syscap SystemCapability.Test.UiTest - * @param by the attribute requirements of the target {@link UiComponent}. - * @returns the matched {@link UiComponent}s list. - * @since 8 + * @param on The attribute requirements of the target {@link Component}. + * @returns the matched {@link Component}s list. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @since 9 * @test */ - findComponents(by:By):Promise>; + findComponents(on: On): Promise>; /** - * Assert t the matched {@link UiComponent}s exists on current UI;if not,assertError will be raised. + * Assert t the matched {@link Component}s exists on current UI;if not,assertError will be raised. * @syscap SystemCapability.Test.UiTest - * @param by the attribute requirements of the target {@link UiComponent}. - * @throws Throws this exception if following error occurs:{@code ComponentExistAssertion Failure}. - * @since 8 + * @param on The attribute requirements of the target {@link Component}. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000003 - if the assertion failed. + * @since 9 * @test */ - assertComponentExist(by:By):Promise; + assertComponentExist(on: On): Promise; /** * Press the BACK key. * @syscap SystemCapability.Test.UiTest - * @since 8 + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @since 9 * @test */ - pressBack():Promise; + pressBack(): Promise; /** * Press the specified key. * @syscap SystemCapability.Test.UiTest * @param keyCode the target keyCode. - * @since 8 + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @since 9 * @test */ - triggerKey(keyCode:number):Promise; + triggerKey(keyCode: number): Promise; /** * Press two or three key combinations @@ -605,6 +1129,8 @@ declare class UiComponent{ * @param key0 the first keyCode. * @param key1 the second keyCode. * @param key2 the third keyCode. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ @@ -613,67 +1139,64 @@ declare class UiComponent{ /** * Click on the specified location on the screen. * @syscap SystemCapability.Test.UiTest - * @param x the x-coordinate. - * @param y the y-coordinate. - * @since 8 + * @param x The x-coordinate. + * @param y The y-coordinate. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @since 9 * @test */ - click(x:number,y:number):Promise; + click(x: number, y: number): Promise; /** * DoubleClick on the specified location on the screen. * @syscap SystemCapability.Test.UiTest - * @param x the x-coordinate. - * @param y the y-coordinate. - * @since 8 + * @param x The x-coordinate. + * @param y The y-coordinate. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @since 9 * @test */ - doubleClick(x:number,y:number):Promise; + doubleClick(x: number, y: number): Promise; /** * LongClick on the specified location on the screen. * @syscap SystemCapability.Test.UiTest - * @param x the x-coordinate. - * @param y the y-coordinate. - * @since 8 - * @test - */ - longClick(x:number,y:number):Promise; - - /** - * Swipe on the screen between the specified points. - * @syscap SystemCapability.Test.UiTest - * @param startx the x-coordinate of the starting point. - * @param starty the y-coordinate of the starting point. - * @param endx the x-coordinate of the ending point. - * @param endy the y-coordinate of the ending point. - * @deprecated since 9 - * @since 8 + * @param x The x-coordinate. + * @param y The y-coordinate. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @since 9 * @test */ - swipe(startx:number,starty:number,endx:number,endy:number):Promise; + longClick(x: number, y: number): Promise; /** * Swipe on the screen between the specified points. * @syscap SystemCapability.Test.UiTest - * @param startx the x-coordinate of the starting point. - * @param starty the y-coordinate of the starting point. - * @param endx the x-coordinate of the ending point. - * @param endy the y-coordinate of the ending point. - * @param speed the speed of swipe (pixels per second),default is 600,the value ranges from 200 to 3000,set it 600 if out of range. + * @param startx The x-coordinate of the starting point. + * @param starty The y-coordinate of the starting point. + * @param endx The x-coordinate of the ending point. + * @param endy The y-coordinate of the ending point. + * @param speed The speed of swipe (pixels per second),default is 600,the value ranges from 200 to 15000,set it 600 if out of range. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - swipe(startx:number,starty:number,endx:number,endy:number, speed?: number):Promise; + swipe(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise; -/** + /** * Drag on the screen between the specified points. * @syscap SystemCapability.Test.UiTest - * @param startx the x-coordinate of the starting point. - * @param starty the y-coordinate of the starting point. - * @param endx the x-coordinate of the ending point. - * @param endy the y-coordinate of the ending point. - * @param speed the speed of swipe (pixels per second),default is 600,the value ranges from 200 to 3000,set it 600 if out of range. + * @param startx The x-coordinate of the starting point. + * @param starty The y-coordinate of the starting point. + * @param endx The x-coordinate of the ending point. + * @param endy The y-coordinate of the ending point. + * @param speed The speed of swipe (pixels per second),default is 600,the value ranges from 200 to 15000,set it 600 if out of range. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ @@ -684,240 +1207,290 @@ declare class UiComponent{ * @syscap SystemCapability.Test.UiTest * @param savePath the path where to store the picture. * @returns true if screen-capturing and file-storing are completed successfully,false otherwise. - * @since 8 + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @since 9 * @test */ - screenCap(savePath:string):Promise; + screenCap(savePath: string): Promise; /** * Set the rotation of the device display. * @syscap SystemCapability.Test.UiTest - * @param rotation the target rotation to set. + * @param rotation The target rotation to set. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - setDisplayRotation(rotation: DisplayRotation):Promise; + setDisplayRotation(rotation: DisplayRotation): Promise; /** * Get the rotation of the device display. * @syscap SystemCapability.Test.UiTest * @returns the current display rotation. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - getDisplayRotation():Promise; + getDisplayRotation(): Promise; /** * Enable/disable the rotation of device display. * @syscap SystemCapability.Test.UiTest - * @param enabled enable the rotation or not. + * @param enabled Enable the rotation or not. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - setDisplayRotationEnabled(enabled:boolean):Promise; + setDisplayRotationEnabled(enabled: boolean): Promise; /** * Get the size of the device display. * @syscap SystemCapability.Test.UiTest * @returns the size of the device display. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - getDisplaySize():Promise; + getDisplaySize(): Promise; /** * Get the density of the device display. * @syscap SystemCapability.Test.UiTest * @returns the density of the device display. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - getDisplayDensity():Promise; + getDisplayDensity(): Promise; /** * Wake up the device display. * @syscap SystemCapability.Test.UiTest + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - wakeUpDisplay():Promise; + wakeUpDisplay(): Promise; /** * Press the home key. * @syscap SystemCapability.Test.UiTest + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - pressHome():Promise; + pressHome(): Promise; /** * Wait for the UI become idle. * @syscap SystemCapability.Test.UiTest * @param idleTime the threshold of UI idle time, in millisecond. - * @param timeout the maximum time to wait for idle, in millisecond. + * @param timeout The maximum time to wait for idle, in millisecond. * @returns true if wait for idle succeed in the timeout, false otherwise. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - waitForIdle(idleTime: number, timeout: number):Promise; + waitForIdle(idleTime: number, timeout: number): Promise; /** * Inject fling on the device display. * @syscap SystemCapability.Test.UiTest - * @param from the coordinate point where the finger touches the screen. - * @param to the coordinate point where the finger leaves the screen. + * @param from The coordinate point where the finger touches the screen. + * @param to The coordinate point where the finger leaves the screen. * @param stepLen the length of each step, in pixels. - * @param speed the speed of fling (pixels per second),default is 600,the value ranges from 200 to 3000,set it 600 if out of range. + * @param speed The speed of fling (pixels per second),default is 600,the value ranges from 200 to 15000,set it 600 if out of range. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - fling(from: Point, to: Point, stepLen: number, speed: number):Promise; + fling(from: Point, to: Point, stepLen: number, speed: number): Promise; /** * Inject multi-pointer action on the device display. * @syscap SystemCapability.Test.UiTest - * @param pointers the two-dimensional array of pointers to inject. - * @param speed the speed of swipe (pixels per second),default is 600,the value ranges from 200 to 3000,set it 600 if out of range. + * @param pointers The two-dimensional array of pointers to inject. + * @param speed The speed of swipe (pixels per second),default is 600,the value ranges from 200 to 15000,set it 600 if out of range. + * @returns true if the operation finished, false + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. * @since 9 * @test */ - injectMultiPointerAction(pointers: PointerMatrix, speed?: number):Promise; + injectMultiPointerAction(pointers: PointerMatrix, speed?: number): Promise; } /** - * - * * @since 9 * @test * @syscap SystemCapability.Test.UiTest */ - declare class UiWindow{ +declare class UiWindow { /** * Get the bundle name of this {@link UiWindow}. * @syscap SystemCapability.Test.UiTest * @returns the bundle name. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. * @since 9 * @test */ - getBundleName():Promise; + getBundleName(): Promise; /** * Get the bounds rect of this {@link UiWindow}. * @syscap SystemCapability.Test.UiTest * @return the bounds rect object. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. * @since 9 * @test */ - getBounds():Promise; - + getBounds(): Promise; + /** * Get the title of this {@link UiWindow}. * @syscap SystemCapability.Test.UiTest * @returns the title value. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. * @since 9 * @test */ - getTitle():Promise; - + getTitle(): Promise; + /** - * Get the windoe mode of this {@link UiWindow}. + * Get the window mode of this {@link UiWindow}. * @syscap SystemCapability.Test.UiTest - * @returns the {@link WindowMode} object. + * @returns the {@link WindowMode} object + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. * @since 9 * @test */ - getWindowMode():Promise; + getWindowMode(): Promise; /** * Get the focused status of this {@link UiWindow}. * @syscap SystemCapability.Test.UiTest * @returns the focused status + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. * @since 9 * @test */ - isFocused():Promise; + isFocused(): Promise; /** - * Get the actived status of this {@link UiWindow}. + * Get the active status of this {@link UiWindow}. * @syscap SystemCapability.Test.UiTest * @returns the actived status + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. * @since 9 * @test */ - isActived():Promise; + isActived(): Promise; /** * Set the focused status of this {@link UiWindow}. * @syscap SystemCapability.Test.UiTest - * @returns the result of focus action + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. * @since 9 * @test */ - focus():Promise; + focus(): Promise; /** * Move this {@link UiWindow} to the specified points. * @syscap SystemCapability.Test.UiTest - * @returns the result of move action + * @param x The x coordinate of destination. + * @param y The y coordinate of destination. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. + * @throws {BusinessError} 17000005 - if the action is not supported on this window. * @since 9 * @test */ - moveTo(x: number, y: number):Promise; + moveTo(x: number, y: number): Promise; /** * Resize this {@link UiWindow} to the specified size for the specified direction. * @syscap SystemCapability.Test.UiTest - * @returns the result of resize action + * @param wide The expected wide of the window after resizing. + * @param height The expected height of the window after resizing. + * @param direction The expected direction of the window after resizing. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. + * @throws {BusinessError} 17000005 - if the action is not supported on this window. * @since 9 * @test */ - resize(wide: number, height: number, direction: ResizeDirection):Promise; + resize(wide: number, height: number, direction: ResizeDirection): Promise; /** * Change this {@link UiWindow} into split screen mode. * @syscap SystemCapability.Test.UiTest - * @returns the result of split action + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. + * @throws {BusinessError} 17000005 - if the action is not supported on this window. * @since 9 * @test */ - split():Promise; + split(): Promise; /** * Maximize this {@link UiWindow}. * @syscap SystemCapability.Test.UiTest - * @returns the result of maximize action + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. + * @throws {BusinessError} 17000005 - if the action is not supported on this window. * @since 9 * @test */ - maximize():Promise; + maximize(): Promise; /** * Minimize this {@link UiWindow}. * @syscap SystemCapability.Test.UiTest - * @returns the result of minimize action + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. + * @throws {BusinessError} 17000005 - if the action is not supported on this window. * @since 9 * @test */ - minimize():Promise; + minimize(): Promise; /** * Resume this {@link UiWindow}. * @syscap SystemCapability.Test.UiTest - * @returns the result of resume action + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. + * @throws {BusinessError} 17000005 - if the action is not supported on this window. * @since 9 * @test */ - resume():Promise; + resume(): Promise; /** * Close this {@link UiWindow}. * @syscap SystemCapability.Test.UiTest - * @returns the result of close action + * @throws {BusinessError} 17000002 - if the async function was not called with await. + * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. + * @throws {BusinessError} 17000005 - if the action is not supported on this window. * @since 9 * @test */ - close():Promise; - } + close(): Promise; +} /** * Represents a two-dimensional array of pointers on the device display, it's used to build a @@ -928,35 +1501,47 @@ declare class UiComponent{ * @syscap SystemCapability.Test.UiTest */ declare class PointerMatrix { - /** + /** * Create an {@link PointerMatrix} object. * @syscap SystemCapability.Test.UiTest - * @param fingers the number of fingers. - * @param steps the number of steps of each finger trace. + * @param fingers The number of fingers. + * @param steps The number of steps of each finger trace. * @returns the {@link PointerMatrix} object. + * @throws {BusinessError} 401 - if the input parameters are invalid. * @since 9 * @test */ - static create(fingers: number, steps: number):PointerMatrix; + static create(fingers: number, steps: number): PointerMatrix; + + /** + * Set the point value of an element in the PointerMatrix. + * @syscap SystemCapability.Test.UiTest + * @param finger The index of target finger to set. + * @param step The index of target step to set. + * @param point The coordinate of target step to set. + * @throws {BusinessError} 401 - if the input parameters are invalid. - /** - * Set the point value of an element in the PointerMatrix. - * @syscap SystemCapability.Test.UiTest - * @param finger the index of target finger to set. - * @param step the index of target step to set. - * @param point the coordinate of target step to set. - * @since 9 - * @test - */ - setPoint(finger: number, step: number, point: Point):void; + * @since 9 + * @test + */ + setPoint(finger: number, step: number, point: Point): void; } /** * The static builder for building {@link By}object conveniently,usage example:BY.text('txt').enabled(true). * @syscap SystemCapability.Test.UiTest * @since 8 + * @deprecated since 9 + * @useinstead ohos.uitest.ON + * @test + */ +declare const BY: By; +/** + * The static builder for building {@link On}object conveniently,usage example:ON.text('txt').enabled(true). + * @syscap SystemCapability.Test.UiTest + * @since 9 * @test */ - declare const BY:By; +declare const ON: On; - export {UiComponent,UiDriver,UiWindow,BY,MatchPattern,DisplayRotation,ResizeDirection,WindowMode,PointerMatrix}; +export {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix};