1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License,Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing,software 10 * distributed under the License is distributed on an "ASIS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * Enumerates the string value match pattern. 18 * @enum {number} 19 * @syscap SystemCapability.Test.UiTest 20 * @since 8 21 */ 22declare enum MatchPattern { 23 /** 24 * Equals to a string. 25 * @syscap SystemCapability.Test.UiTest 26 * @since 8 27 * @test 28 */ 29 EQUALS = 0, 30 /** 31 * Contains a substring. 32 * @syscap SystemCapability.Test.UiTest 33 * @since 8 34 * @test 35 */ 36 CONTAINS = 1, 37 /** 38 * StartsWith a substring. 39 * @syscap SystemCapability.Test.UiTest 40 * @since 8 41 * @test 42 */ 43 STARTS_WITH = 2, 44 /** 45 * EndsWith a substring. 46 * @syscap SystemCapability.Test.UiTest 47 * @since 8 48 * @test 49 */ 50 ENDS_WITH = 3 51} 52 53/** 54 * Describes the attribute requirements for the target UiComponents. 55 * 56 * @since 8 57 * @deprecated since 9 58 * @useinstead ohos.uitest.On 59 * @syscap SystemCapability.Test.UiTest 60 */ 61declare class By { 62 /** 63 * Specifies the text for the target UiComponent. 64 * @syscap SystemCapability.Test.UiTest 65 * @param {string} text The text value. 66 * @param {MatchPattern} pattern The {@link MatchPattern} of the text value,default to {@link MatchPattern.EQUALS} 67 * @returns {By} this {@link By} object. 68 * @since 8 69 * @deprecated since 9 70 * @useinstead ohos.uitest.On#text 71 * @test 72 */ 73 text(txt: string, pattern?: MatchPattern): By; 74 75 /** 76 * Specifies the inspector key of the target UiComponent. 77 * @syscap SystemCapability.Test.UiTest 78 * @param {string} key The inspectorKey value. 79 * @returns {By} this {@link By} object. 80 * @since 8 81 * @deprecated since 9 82 * @useinstead ohos.uitest.On#id 83 * @test 84 */ 85 key(key: string): By; 86 87 /** 88 * Specifies the id of the target UiComponent. 89 * @syscap SystemCapability.Test.UiTest 90 * @param {number} id The id value. 91 * @returns {By} this {@link By} object. 92 * @since 8 93 * @deprecated since 9 94 * @test 95 */ 96 id(id: number): By; 97 98 /** 99 * Specifies the type of the target UiComponent. 100 * @syscap SystemCapability.Test.UiTest 101 * @param {string} tp The type value. 102 * @returns {By} this {@link By} object. 103 * @since 8 104 * @deprecated since 9 105 * @useinstead ohos.uitest.On#type 106 * @test 107 */ 108 type(tp: string): By; 109 110 /** 111 * Specifies the clickable status of the target UiComponent. 112 * @syscap SystemCapability.Test.UiTest 113 * @param {boolean} b The clickable status,default to true. 114 * @returns {By} this {@link By} object. 115 * @since 8 116 * @deprecated since 9 117 * @useinstead ohos.uitest.On#clickable 118 * @test 119 */ 120 clickable(b?: boolean): By; 121 122 /** 123 * Specifies the scrollable status of the target UiComponent. 124 * @syscap SystemCapability.Test.UiTest 125 * @param {boolean} b The scrollable status,default to true. 126 * @returns {By} this {@link By} object. 127 * @since 8 128 * @deprecated since 9 129 * @useinstead ohos.uitest.On#scrollable 130 * @test 131 */ 132 scrollable(b?: boolean): By; 133 134 /** 135 * Specifies the enabled status of the target UiComponent. 136 * @syscap SystemCapability.Test.UiTest 137 * @param {boolean} b The enabled status,default to true. 138 * @returns {By} this {@link By} object. 139 * @since 8 140 * @deprecated since 9 141 * @useinstead ohos.uitest.On#enabled 142 * @test 143 */ 144 enabled(b?: boolean): By; 145 146 /** 147 * Specifies the focused status of the target UiComponent. 148 * @syscap SystemCapability.Test.UiTest 149 * @param {boolean} b The focused status,default to true. 150 * @returns {By} this {@link By} object. 151 * @since 8 152 * @deprecated since 9 153 * @useinstead ohos.uitest.On#focused 154 * @test 155 */ 156 focused(b?: boolean): By; 157 158 /** 159 * Specifies the selected status of the target UiComponent. 160 * @syscap SystemCapability.Test.UiTest 161 * @param {boolean} b The selected status,default to true. 162 * @returns {By} this {@link By} object. 163 * @since 8 164 * @deprecated since 9 165 * @useinstead ohos.uitest.On#selected 166 * @test 167 */ 168 selected(b?: boolean): By; 169 170 /** 171 * Requires the target UiComponent which is before another UiComponent that specified by the given {@link By} 172 * object,used to locate UiComponent relatively. 173 * @syscap SystemCapability.Test.UiTest 174 * @param {By} by Describes the attribute requirements of UiComponent which the target one is in front of. 175 * @returns {By} this {@link By} object. 176 * @since 8 177 * @deprecated since 9 178 * @useinstead {@link On.isBefore} 179 * @test 180 */ 181 isBefore(by: By): By; 182 183 /** 184 * Requires the target UiComponent which is after another UiComponent that specified by the given {@link By} 185 * object,used to locate UiComponent relatively. 186 * @syscap SystemCapability.Test.UiTest 187 * @param {By} by Describes the attribute requirements of UiComponent which the target one is in back of. 188 * @returns {By} this {@link By} object. 189 * @since 8 190 * @deprecated since 9 191 * @useinstead {@link On.isAfter} 192 * @test 193 */ 194 isAfter(by: By): By; 195} 196 197/** 198 * Represents a UiComponent of the ohos application,user can perform operations or query attributes on it. 199 * 200 * @since 8 201 * @deprecated since 9 202 * @useinstead ohos.uitest.Component 203 * @test 204 * @syscap SystemCapability.Test.UiTest 205 */ 206declare class UiComponent { 207 /** 208 * Click this {@link UiComponent}. 209 * @syscap SystemCapability.Test.UiTest 210 * @since 8 211 * @deprecated since 9 212 * @useinstead ohos.uitest.Component#click 213 * @test 214 */ 215 click(): Promise<void>; 216 217 /** 218 * Double click this {@link UiComponent}. 219 * @syscap SystemCapability.Test.UiTest 220 * @since 8 221 * @deprecated since 9 222 * @useinstead {@link Component.doubleClick} 223 * @test 224 */ 225 doubleClick(): Promise<void>; 226 227 /** 228 * Long click this {@link UiComponent}. 229 * @syscap SystemCapability.Test.UiTest 230 * @since 8 231 * @deprecated since 9 232 * @useinstead {@link Component.longClick} 233 * @test 234 */ 235 longClick(): Promise<void>; 236 237 /** 238 * Get the id attribute value. 239 * @syscap SystemCapability.Test.UiTest 240 * @returns {number} the id value. 241 * @since 8 242 * @deprecated since 9 243 * @test 244 */ 245 getId(): Promise<number>; 246 247 /** 248 * Get the inspectorKey attribute value. 249 * @syscap SystemCapability.Test.UiTest 250 * @returns {string} the inspectorKey value. 251 * @since 8 252 * @deprecated since 9 253 * @useinstead {@link Component.getId} 254 * @test 255 */ 256 getKey(): Promise<string>; 257 258 /** 259 * Get the text attribute value. 260 * @syscap SystemCapability.Test.UiTest 261 * @returns {string} the text value. 262 * @since 8 263 * @deprecated since 9 264 * @useinstead {@link Component.getText} 265 * @test 266 */ 267 getText(): Promise<string>; 268 269 /** 270 * Get the type name. 271 * @syscap SystemCapability.Test.UiTest 272 * @returns {string} the type name. 273 * @since 8 274 * @deprecated since 9 275 * @useinstead {@link Component.getType} 276 * @test 277 */ 278 getType(): Promise<string>; 279 280 /** 281 * Get the clickable status of this {@link UiComponent}. 282 * @syscap SystemCapability.Test.UiTest 283 * @returns {boolean} the clickable status. 284 * @since 8 285 * @deprecated since 9 286 * @useinstead {@link Component.isClickable} 287 * @test 288 */ 289 isClickable(): Promise<boolean>; 290 291 /** 292 * Get the scrollable status of this {@link UiComponent}. 293 * @syscap SystemCapability.Test.UiTest 294 * @returns {boolean} the scrollable status. 295 * @since 8 296 * @deprecated since 9 297 * @useinstead {@link Component.isScrollable} 298 * @test 299 */ 300 isScrollable(): Promise<boolean>; 301 302 /** 303 * Get the enabled status of this {@link UiComponent}. 304 * @syscap SystemCapability.Test.UiTest 305 * @returns {boolean} the enabled status. 306 * @since 8 307 * @deprecated since 9 308 * @useinstead {@link Component.isEnabled} 309 * @test 310 */ 311 isEnabled(): Promise<boolean>; 312 313 /** 314 * Get the focused status of this {@link UiComponent}. 315 * @syscap SystemCapability.Test.UiTest 316 * @returns {boolean} the focused status. 317 * @since 8 318 * @deprecated since 9 319 * @useinstead {@link Component.isFocused} 320 * @test 321 */ 322 isFocused(): Promise<boolean>; 323 324 /** 325 * Get the selected status of this {@link UiComponent}. 326 * @syscap SystemCapability.Test.UiTest 327 * @returns {boolean} the selected status. 328 * @since 8 329 * @deprecated since 9 330 * @useinstead {@link Component.isSelected} 331 * @test 332 */ 333 isSelected(): Promise<boolean>; 334 335 /** 336 * Inject text to this {@link UiComponent},applicable to TextInput. 337 * @syscap SystemCapability.Test.UiTest 338 * @param {string} text The text to inject. 339 * @since 8 340 * @deprecated since 9 341 * @useinstead {@link Component.inputText} 342 * @test 343 */ 344 inputText(text: string): Promise<void>; 345 346 /** 347 * Scroll on this {@link UiComponent}to find matched {@link UiComponent},applicable to scrollable one. 348 * @syscap SystemCapability.Test.UiTest 349 * @param {By} by The attribute requirements of the target {@link UiComponent}. 350 * @returns {UiComponent} the found result,or undefined if not found. 351 * @since 8 352 * @deprecated since 9 353 * @useinstead {@link Component.scrollSearch} 354 * @test 355 */ 356 scrollSearch(by: By): Promise<UiComponent>; 357} 358 359/** 360 * The unified facade of UiTest framework,can be used to find {@link UiComponent},trigger keyEvents,perform 361 * coordinates-based UI actions,capture screen and so on. 362 * 363 * @since 8 364 * @deprecated since 9 365 * @useinstead ohos.uitest.Driver 366 * @test 367 * @syscap SystemCapability.Test.UiTest 368 */ 369declare class UiDriver { 370 /** 371 * Create an {@link UiDriver} object. 372 * @syscap SystemCapability.Test.UiTest 373 * @returns {UiDriver} the {@link UiDriver} object. 374 * @since 8 375 * @deprecated since 9 376 * @useinstead ohos.uitest.Driver#create 377 * @test 378 */ 379 static create(): UiDriver; 380 381 /** 382 * Delay with specified duration. 383 * @syscap SystemCapability.Test.UiTest 384 * @param {number} duration The delay duration in milliseconds. 385 * @since 8 386 * @deprecated since 9 387 * @useinstead {@link Driver.delayMs} 388 * @test 389 */ 390 delayMs(duration: number): Promise<void>; 391 392 /** 393 * Find the first matched {@link UiComponent} on current UI. 394 * @syscap SystemCapability.Test.UiTest 395 * @param {By} by The attribute requirements of the target {@link UiComponent}. 396 * @returns {UiComponent} the first matched {@link UiComponent} or undefined. 397 * @since 8 398 * @deprecated since 9 399 * @useinstead {@link Driver.findComponent} 400 * @test 401 */ 402 findComponent(by: By): Promise<UiComponent>; 403 404 /** 405 * Find all the matched {@link UiComponent}s on current UI. 406 * @syscap SystemCapability.Test.UiTest 407 * @param {By} by The attribute requirements of the target {@link UiComponent}. 408 * @returns {Array<UiComponent>} the matched {@link UiComponent}s list. 409 * @since 8 410 * @deprecated since 9 411 * @useinstead {@link Driver.findComponents} 412 * @test 413 */ 414 findComponents(by: By): Promise<Array<UiComponent>>; 415 416 /** 417 * Assert the matched {@link UiComponent}s exists on current UI;if not,assertError will be raised. 418 * @syscap SystemCapability.Test.UiTest 419 * @param {By} by The attribute requirements of the target {@link UiComponent}. 420 * @throws Throws this exception if following error occurs:{@code ComponentExistAssertion Failure}. 421 * @since 8 422 * @deprecated since 9 423 * @useinstead {@link Driver.assertComponentExist} 424 * @test 425 */ 426 assertComponentExist(by: By): Promise<void>; 427 428 /** 429 * Press the BACK key. 430 * @syscap SystemCapability.Test.UiTest 431 * @since 8 432 * @deprecated since 9 433 * @useinstead {@link Driver.pressBack} 434 * @test 435 */ 436 pressBack(): Promise<void>; 437 438 /** 439 * Press the specified key. 440 * @syscap SystemCapability.Test.UiTest 441 * @param {number} keyCode the target keyCode. 442 * @since 8 443 * @deprecated since 9 444 * @useinstead {@link Driver.pressHome} 445 * @test 446 */ 447 triggerKey(keyCode: number): Promise<void>; 448 449 /** 450 * Click on the specified location on the screen. 451 * @syscap SystemCapability.Test.UiTest 452 * @param {number} x The x-coordinate. 453 * @param {number} y The y-coordinate. 454 * @since 8 455 * @deprecated since 9 456 * @useinstead ohos.uitest.Driver#click 457 * @test 458 */ 459 click(x: number, y: number): Promise<void>; 460 461 /** 462 * DoubleClick on the specified location on the screen. 463 * @syscap SystemCapability.Test.UiTest 464 * @param {number} x The x-coordinate. 465 * @param {number} y The y-coordinate. 466 * @since 8 467 * @deprecated since 9 468 * @useinstead {@link Driver.doubleClick} 469 * @test 470 */ 471 doubleClick(x: number, y: number): Promise<void>; 472 473 /** 474 * LongClick on the specified location on the screen. 475 * @syscap SystemCapability.Test.UiTest 476 * @param {number} x The x-coordinate. 477 * @param {number} y The y-coordinate. 478 * @since 8 479 * @deprecated since 9 480 * @useinstead {@link Driver.longClick} 481 * @test 482 */ 483 longClick(x: number, y: number): Promise<void>; 484 485 /** 486 * Swipe on the screen between the specified points. 487 * @syscap SystemCapability.Test.UiTest 488 * @param {number} startx The x-coordinate of the starting point. 489 * @param {number} starty The y-coordinate of the starting point. 490 * @param {number} endx The x-coordinate of the ending point. 491 * @param {number} endy The y-coordinate of the ending point. 492 * @since 8 493 * @deprecated since 9 494 * @useinstead ohos.uitest.Driver#swipe 495 * @test 496 */ 497 swipe(startx: number, starty: number, endx: number, endy: number): Promise<void>; 498 499 /** 500 * Capture current screen and save as picture which PNG format. 501 * @syscap SystemCapability.Test.UiTest 502 * @param {string} savePath the path where to store the picture. 503 * @returns {boolean} true if screen-capturing and file-storing are completed successfully,false otherwise. 504 * @since 8 505 * @deprecated since 9 506 * @useinstead {@link Driver.screenCap} 507 * @test 508 */ 509 screenCap(savePath: string): Promise<boolean>; 510} 511 512 513/** 514 * Enumerates the window mode of the tested window. 515 * @enum {number} 516 * @syscap SystemCapability.Test.UiTest 517 * @since 9 518 */ 519declare enum WindowMode { 520 /** 521 * The test window is a full screen window. 522 * @syscap SystemCapability.Test.UiTest 523 * @since 9 524 * @test 525 */ 526 FULLSCREEN = 0, 527 /** 528 * The test window is the first window in the split screen state. 529 * @syscap SystemCapability.Test.UiTest 530 * @since 9 531 * @test 532 */ 533 PRIMARY = 1, 534 /** 535 * The test window is the second window in the split screen state. 536 * @syscap SystemCapability.Test.UiTest 537 * @since 9 538 * @test 539 */ 540 SECONDARY = 2, 541 /** 542 * The test window is a floating window. 543 * @syscap SystemCapability.Test.UiTest 544 * @since 9 545 * @test 546 */ 547 FLOATING = 3 548} 549 550/** 551 * Enumerates the resize direction for the window. 552 * @enum {number} 553 * @syscap SystemCapability.Test.UiTest 554 * @since 9 555 */ 556declare enum ResizeDirection { 557 /** 558 * Left. 559 * @syscap SystemCapability.Test.UiTest 560 * @since 9 561 * @test 562 */ 563 LEFT = 0, 564 /** 565 * Right. 566 * @syscap SystemCapability.Test.UiTest 567 * @since 9 568 * @test 569 */ 570 RIGHT = 1, 571 /** 572 * Up. 573 * @syscap SystemCapability.Test.UiTest 574 * @since 9 575 * @test 576 */ 577 UP = 2, 578 /** 579 * Down. 580 * @syscap SystemCapability.Test.UiTest 581 * @since 9 582 * @test 583 */ 584 DOWN = 3, 585 /** 586 * Upper left. 587 * @syscap SystemCapability.Test.UiTest 588 * @since 9 589 * @test 590 */ 591 LEFT_UP = 4, 592 /** 593 * Lower left. 594 * @syscap SystemCapability.Test.UiTest 595 * @since 9 596 * @test 597 */ 598 LEFT_DOWN = 5, 599 /** 600 * Upper right. 601 * @syscap SystemCapability.Test.UiTest 602 * @since 9 603 * @test 604 */ 605 RIGHT_UP = 6, 606 /** 607 * Lower right. 608 * @syscap SystemCapability.Test.UiTest 609 * @since 9 610 * @test 611 */ 612 RIGHT_DOWN = 7 613} 614 615/** 616 * Enumerates the rotation of the device display. 617 * @enum {number} 618 * @syscap SystemCapability.Test.UiTest 619 * @since 9 620 */ 621declare enum DisplayRotation { 622 /** 623 * Device display does not rotate to display vertically. 624 * @syscap SystemCapability.Test.UiTest 625 * @since 9 626 * @test 627 */ 628 ROTATION_0 = 0, 629 /** 630 * Device display rotates 90 degrees clockwise to display horizontally. 631 * @syscap SystemCapability.Test.UiTest 632 * @since 9 633 * @test 634 */ 635 ROTATION_90 = 1, 636 /** 637 * Device display rotates clockwise 180 degrees to display vertically in reverse. 638 * @syscap SystemCapability.Test.UiTest 639 * @since 9 640 * @test 641 */ 642 ROTATION_180 = 2, 643 /** 644 * Device display rotates 270 degrees clockwise to display horizontally in reverse. 645 * @syscap SystemCapability.Test.UiTest 646 * @since 9 647 * @test 648 */ 649 ROTATION_270 = 3 650} 651 652/** 653 * Represents the point on the device screen. 654 * @typedef Point 655 * @syscap SystemCapability.Test.UiTest 656 * @since 9 657 */ 658declare interface Point { 659 /** 660 * The x-coordinate of the coordinate point. 661 * @type number 662 * @since 9 663 */ 664 readonly x: number; 665 /** 666 * The y-coordinate of the coordinate point. 667 * @type number 668 * @since 9 669 */ 670 readonly y: number; 671} 672 673/** 674 * Represents the rectangle area on the device screen. 675 * @typedef Rect 676 * @syscap SystemCapability.Test.UiTest 677 * @since 9 678 */ 679declare interface Rect { 680 /** 681 * The x-coordinate of the top left corner of the rectangle. 682 * @type number 683 * @since 9 684 */ 685 readonly left: number; 686 /** 687 * The y-coordinate of the top left corner of the rectangle. 688 * @type number 689 * @since 9 690 */ 691 readonly top: number; 692 /** 693 * The x-coordinate at the bottom right corner of the rectangle. 694 * @type number 695 * @since 9 696 */ 697 readonly right: number; 698 /** 699 * The y-coordinate at the bottom right corner of the rectangle. 700 * @type number 701 * @since 9 702 */ 703 readonly bottom: number; 704} 705 706/** 707 * Represents filer condition to get the window . 708 * @typedef WindowFilter 709 * @syscap SystemCapability.Test.UiTest 710 * @since 9 711 */ 712declare interface WindowFilter { 713 /** 714 * The package name of the application which the window belongs to. 715 * @type string 716 * @since 9 717 */ 718 bundleName?: string; 719 /** 720 * The title of the window. 721 * @type string 722 * @since 9 723 */ 724 title?: string; 725 /** 726 * The focal state of the window. 727 * @type boolean 728 * @since 9 729 */ 730 focused?: boolean; 731 /** 732 * The active state of the window. 733 * @type boolean 734 * @since 9 735 */ 736 actived?: boolean; 737} 738 739/** 740 * Describes the attribute requirements for the target Components. 741 * 742 * @since 9 743 * @syscap SystemCapability.Test.UiTest 744 */ 745declare class On { 746 /** 747 * Specifies the text for the target Component. 748 * @syscap SystemCapability.Test.UiTest 749 * @param {string} txt The text value. 750 * @param {MatchPattern} pattern The {@link MatchPattern} of the text value, default to {@link MatchPattern.EQUALS} 751 * @returns {On} this {@link On} object. 752 * @throws {BusinessError} 401 - if the input parameters are invalid. 753 * @since 9 754 * @test 755 */ 756 text(txt: string, pattern?: MatchPattern): On; 757 758 /** 759 * Specifies the id of the target Component. 760 * @syscap SystemCapability.Test.UiTest 761 * @param {string} id The id value. 762 * @returns {On} this {@link On} object. 763 * @throws {BusinessError} 401 - if the input parameters are invalid. 764 * @since 9 765 * @test 766 */ 767 id(id: string): On; 768 769 /** 770 * Specifies the type of the target Component. 771 * @syscap SystemCapability.Test.UiTest 772 * @param {string} tp The type value. 773 * @returns {On} this {@link On} object. 774 * @throws {BusinessError} 401 - if the input parameters are invalid. 775 * @since 9 776 * @test 777 */ 778 type(tp: string): On; 779 780 /** 781 * Specifies the clickable status of the target Component. 782 * @syscap SystemCapability.Test.UiTest 783 * @param {boolean} b The clickable status,default to true. 784 * @returns {On} this {@link On} object. 785 * @throws {BusinessError} 401 - if the input parameters are invalid. 786 * @since 9 787 * @test 788 */ 789 clickable(b?: boolean): On; 790 791 /** 792 * Specifies the longClickable status of the target Component. 793 * @syscap SystemCapability.Test.UiTest 794 * @param {boolean} b The clickable status,default to true. 795 * @returns {On} this {@link On} object. 796 * @throws {BusinessError} 401 - if the input parameters are invalid. 797 * @since 9 798 * @test 799 */ 800 longClickable(b?: boolean): On; 801 802 /** 803 * Specifies the scrollable status of the target Component. 804 * @syscap SystemCapability.Test.UiTest 805 * @param {boolean} b The scrollable status,default to true. 806 * @returns {On} this {@link On} object. 807 * @throws {BusinessError} 401 - if the input parameters are invalid. 808 * @since 9 809 * @test 810 */ 811 scrollable(b?: boolean): On; 812 813 /** 814 * Specifies the enabled status of the target Component. 815 * @syscap SystemCapability.Test.UiTest 816 * @param {boolean} b The enabled status,default to true. 817 * @returns {On} this {@link On} object. 818 * @throws {BusinessError} 401 - if the input parameters are invalid. 819 * @since 9 820 * @test 821 */ 822 enabled(b?: boolean): On; 823 824 /** 825 * Specifies the focused status of the target Component. 826 * @syscap SystemCapability.Test.UiTest 827 * @param {boolean} b The focused status,default to true. 828 * @returns {On} this {@link On} object. 829 * @throws {BusinessError} 401 - if the input parameters are invalid. 830 * @since 9 831 * @test 832 */ 833 focused(b?: boolean): On; 834 835 /** 836 * Specifies the selected status of the target Component. 837 * @syscap SystemCapability.Test.UiTest 838 * @param {boolean} b The selected status,default to true. 839 * @returns {On} this {@link On} object. 840 * @throws {BusinessError} 401 - if the input parameters are invalid. 841 * @since 9 842 * @test 843 */ 844 selected(b?: boolean): On; 845 846 /** 847 * Specifies the checked status of the target Component. 848 * @syscap SystemCapability.Test.UiTest 849 * @param {boolean} b The checked status,default to false. 850 * @returns {On} this {@link On} object. 851 * @throws {BusinessError} 401 - if the input parameters are invalid. 852 * @since 9 853 * @test 854 */ 855 checked(b?: boolean): On; 856 857 /** 858 * Specifies the checkable status of the target Component. 859 * @syscap SystemCapability.Test.UiTest 860 * @param {boolean} b The checkable status,default to false. 861 * @returns {On} this {@link On} object. 862 * @throws {BusinessError} 401 - if the input parameters are invalid. 863 * @since 9 864 * @test 865 */ 866 checkable(b?: boolean): On; 867 868 /** 869 * Requires that the target Component which is before another Component that specified by the given {@link On} 870 * object,used to locate Component relatively. 871 * @syscap SystemCapability.Test.UiTest 872 * @param {On} on Describes the attribute requirements of Component which the target one is in front of. 873 * @returns {On} this {@link On} object. 874 * @throws {BusinessError} 401 - if the input parameters are invalid. 875 * @since 9 876 * @test 877 */ 878 isBefore(on: On): On; 879 880 /** 881 * Requires that the target Component which is after another Component that specified by the given {@link On} 882 * object,used to locate Component relatively. 883 * @syscap SystemCapability.Test.UiTest 884 * @param {On} on Describes the attribute requirements of Component which the target one is in back of. 885 * @returns {On} this {@link On} object. 886 * @throws {BusinessError} 401 - if the input parameters are invalid. 887 * @since 9 888 * @test 889 */ 890 isAfter(on: On): On; 891} 892 893/** 894 * Represents an Component of the ohos application,user can perform operations or query attributes on it. 895 * 896 * @since 9 897 * @test 898 * @syscap SystemCapability.Test.UiTest 899 */ 900declare class Component { 901 /** 902 * Click this {@link Component}. 903 * @syscap SystemCapability.Test.UiTest 904 * @since 9 905 * @throws {BusinessError} 17000002 - if the async function was not called with await. 906 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 907 * @test 908 */ 909 click(): Promise<void>; 910 911 /** 912 * Double click this {@link Component}. 913 * @syscap SystemCapability.Test.UiTest 914 * @since 9 915 * @throws {BusinessError} 17000002 - if the async function was not called with await. 916 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 917 * @test 918 */ 919 doubleClick(): Promise<void>; 920 921 /** 922 * Long click this {@link Component}. 923 * @syscap SystemCapability.Test.UiTest 924 * @since 9 925 * @throws {BusinessError} 17000002 - if the async function was not called with await. 926 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 927 * @test 928 */ 929 longClick(): Promise<void>; 930 931 /** 932 * Get the id attribute value. 933 * @syscap SystemCapability.Test.UiTest 934 * @returns {string} the id value. 935 * @throws {BusinessError} 17000002 - if the async function was not called with await. 936 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 937 * @since 9 938 * @test 939 */ 940 getId(): Promise<string>; 941 942 /** 943 * Get the text attribute value. 944 * @syscap SystemCapability.Test.UiTest 945 * @returns {string} the text value. 946 * @throws {BusinessError} 17000002 - if the async function was not called with await. 947 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 948 * @since 9 949 * @test 950 */ 951 getText(): Promise<string>; 952 953 /** 954 * Get the type name. 955 * @syscap SystemCapability.Test.UiTest 956 * @returns {string} the type name. 957 * @throws {BusinessError} 17000002 - if the async function was not called with await. 958 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 959 * @since 9 960 * @test 961 */ 962 getType(): Promise<string>; 963 964 /** 965 * Get the clickable status of this {@link Component}. 966 * @syscap SystemCapability.Test.UiTest 967 * @returns {boolean} the clickable status. 968 * @throws {BusinessError} 17000002 - if the async function was not called with await. 969 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 970 * @since 9 971 * @test 972 */ 973 isClickable(): Promise<boolean>; 974 975 /** 976 * Get the longClickable status of this {@link Component}. 977 * @syscap SystemCapability.Test.UiTest 978 * @returns {boolean} the longClickable status. 979 * @throws {BusinessError} 17000002 - if the async function was not called with await. 980 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 981 * @since 9 982 * @test 983 */ 984 isLongClickable(): Promise<boolean>; 985 986 /** 987 * Get the scrollable status of this {@link Component}. 988 * @syscap SystemCapability.Test.UiTest 989 * @returns {boolean} the scrollable status. 990 * @throws {BusinessError} 17000002 - if the async function was not called with await. 991 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 992 * @since 9 993 * @test 994 */ 995 isScrollable(): Promise<boolean>; 996 997 /** 998 * Get the enabled status of this {@link Component}. 999 * @syscap SystemCapability.Test.UiTest 1000 * @returns {boolean} the enabled status. 1001 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1002 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1003 * @since 9 1004 * @test 1005 */ 1006 isEnabled(): Promise<boolean>; 1007 1008 /** 1009 * Get the focused status of this {@link Component}. 1010 * @syscap SystemCapability.Test.UiTest 1011 * @returns {boolean} the focused status. 1012 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1013 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1014 * @since 9 1015 * @test 1016 */ 1017 isFocused(): Promise<boolean>; 1018 1019 /** 1020 * Get the selected status of this {@link Component}. 1021 * @syscap SystemCapability.Test.UiTest 1022 * @returns {boolean} the selected status. 1023 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1024 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1025 * @since 9 1026 * @test 1027 */ 1028 isSelected(): Promise<boolean>; 1029 1030 /** 1031 * Get the checked status of this {@link Component}. 1032 * @syscap SystemCapability.Test.UiTest 1033 * @returns {boolean} the checked status. 1034 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1035 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1036 * @since 9 1037 * @test 1038 */ 1039 isChecked(): Promise<boolean>; 1040 1041 /** 1042 * Get the checkable status of this {@link Component}. 1043 * @syscap SystemCapability.Test.UiTest 1044 * @returns {boolean} the checkable status. 1045 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1046 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1047 * @since 9 1048 * @test 1049 */ 1050 isCheckable(): Promise<boolean>; 1051 1052 /** 1053 * Inject text to this {@link Component},applicable to TextInput. 1054 * @syscap SystemCapability.Test.UiTest 1055 * @param {string} text The text to inject. 1056 * @throws {BusinessError} 401 - if the input parameters are invalid. 1057 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1058 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1059 * @since 9 1060 * @test 1061 */ 1062 inputText(text: string): Promise<void>; 1063 1064 /** 1065 * Clear text of this {@link Component},applicable to TextInput. 1066 * @syscap SystemCapability.Test.UiTest 1067 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1068 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1069 * @since 9 1070 * @test 1071 */ 1072 clearText(): Promise<void>; 1073 1074 /** 1075 * Scroll on this {@link Component} to the top,applicable to scrollable one. 1076 * @syscap SystemCapability.Test.UiTest 1077 * @param {number} speed The speed of swipe (pixels per second),default is 600,the value ranges from 200 to 40000,set it 600 if out of range. 1078 * @throws {BusinessError} 401 - if the input parameters are invalid. 1079 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1080 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1081 * @since 9 1082 * @test 1083 */ 1084 scrollToTop(speed?: number): Promise<void>; 1085 1086 /** 1087 * Scroll on this {@link Component} to the bottom,applicable to scrollable one. 1088 * @syscap SystemCapability.Test.UiTest 1089 * @param {number} speed The speed of swipe (pixels per second),default is 600,the value ranges from 200 to 40000,set it 600 if out of range. 1090 * @throws {BusinessError} 401 - if the input parameters are invalid. 1091 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1092 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1093 * @since 9 1094 * @test 1095 */ 1096 scrollToBottom(speed?: number): Promise<void>; 1097 1098 /** 1099 * Scroll on this {@link Component}to find matched {@link Component},applicable to scrollable one. 1100 * @syscap SystemCapability.Test.UiTest 1101 * @param {On} on The attribute requirements of the target {@link Component}. 1102 * @returns {Component} the found result,or undefined if not found. 1103 * @throws {BusinessError} 401 - if the input parameters are invalid. 1104 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1105 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1106 * @since 9 1107 * @test 1108 */ 1109 scrollSearch(on: On): Promise<Component>; 1110 1111 /** 1112 * Get the bounds rect of this {@link Component}. 1113 * @syscap SystemCapability.Test.UiTest 1114 * @returns {Rect} the bounds rect object. 1115 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1116 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1117 * @since 9 1118 * @test 1119 */ 1120 getBounds(): Promise<Rect>; 1121 1122 /** 1123 * Get the boundsCenter of this {@link Component}. 1124 * @syscap SystemCapability.Test.UiTest 1125 * @returns {Point} the boundsCenter object. 1126 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1127 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1128 * @since 9 1129 * @test 1130 */ 1131 getBoundsCenter(): Promise<Point>; 1132 1133 /** 1134 * Drag this {@link Component} to the bounds rect of target Component. 1135 * @syscap SystemCapability.Test.UiTest 1136 * @param {Component} target The target {@link Component}. 1137 * @throws {BusinessError} 401 - if the input parameters are invalid. 1138 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1139 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1140 * @since 9 1141 * @test 1142 */ 1143 dragTo(target: Component): Promise<void>; 1144 1145 /** 1146 * Pinch enlarge this {@link Component} to the target scale. 1147 * @syscap SystemCapability.Test.UiTest 1148 * @param {number} scale The scale of the pinch enlarge this {@link Component}'s size. 1149 * @throws {BusinessError} 401 - if the input parameters are invalid. 1150 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1151 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1152 * @since 9 1153 * @test 1154 */ 1155 pinchOut(scale: number): Promise<void>; 1156 1157 /** 1158 * Pinch shrink this {@link Component} to the target scale. 1159 * @syscap SystemCapability.Test.UiTest 1160 * @param {number} scale The scale of the pinch shrink this {@link Component}'s size. 1161 * @throws {BusinessError} 401 - if the input parameters are invalid. 1162 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1163 * @throws {BusinessError} 17000004 - if the component is invisible or destroyed. 1164 * @since 9 1165 * @test 1166 */ 1167 pinchIn(scale: number): Promise<void>; 1168} 1169 1170/** 1171 * The unified facade of UiTest framework,can be used to find {@link Component},trigger keyEvents,perform 1172 * coordinates-based UI actions,capture screen and so on. 1173 * 1174 * @since 9 1175 * @test 1176 * @syscap SystemCapability.Test.UiTest 1177 */ 1178declare class Driver { 1179 /** 1180 * Create an {@link Driver} object. 1181 * @syscap SystemCapability.Test.UiTest 1182 * @returns {Driver} the {@link Driver} object. 1183 * @throws {BusinessError} 17000001 - if the test framework failed to initialize. 1184 * @since 9 1185 * @test 1186 */ 1187 static create(): Driver; 1188 1189 /** 1190 * Delay with specified duration. 1191 * @syscap SystemCapability.Test.UiTest 1192 * @param {number} duration The delay duration in milliseconds. 1193 * @throws {BusinessError} 401 - if the input parameters are invalid. 1194 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1195 * @since 9 1196 * @test 1197 */ 1198 delayMs(duration: number): Promise<void>; 1199 1200 /** 1201 * Find the first matched {@link Component} on current UI. 1202 * @syscap SystemCapability.Test.UiTest 1203 * @param {On} on The attribute requirements of the target {@link Component}. 1204 * @returns {On} the first matched {@link Component} or undefined. 1205 * @throws {BusinessError} 401 - if the input parameters are invalid. 1206 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1207 * @since 9 1208 * @test 1209 */ 1210 findComponent(on: On): Promise<Component>; 1211 1212 /** 1213 * Find the first matched {@link UiWindow} window. 1214 * @syscap SystemCapability.Test.UiTest 1215 * @param {WindowFilter} filter The filer condition of the target {@link UiWindow}. 1216 * @returns {UiWindow} the first matched {@link UiWindow} or undefined. 1217 * @throws {BusinessError} 401 - if the input parameters are invalid. 1218 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1219 * @since 9 1220 * @test 1221 */ 1222 findWindow(filter: WindowFilter): Promise<UiWindow>; 1223 1224 /** 1225 * Find the first matched {@link Component} on current UI during the time given. 1226 * @syscap SystemCapability.Test.UiTest 1227 * @param {On} on The attribute requirements of the target {@link Component}. 1228 * @param {number} time Duration of finding in milliseconds 1229 * @returns {Component} the first matched {@link Component} or undefined. 1230 * @throws {BusinessError} 401 - if the input parameters are invalid. 1231 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1232 * @since 9 1233 * @test 1234 */ 1235 waitForComponent(on: On, time: number): Promise<Component>; 1236 1237 /** 1238 * Find all the matched {@link Component}s on current UI. 1239 * @syscap SystemCapability.Test.UiTest 1240 * @param {On} on The attribute requirements of the target {@link Component}. 1241 * @returns {Array<Component>} the matched {@link Component}s list. 1242 * @throws {BusinessError} 401 - if the input parameters are invalid. 1243 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1244 * @since 9 1245 * @test 1246 */ 1247 findComponents(on: On): Promise<Array<Component>>; 1248 1249 /** 1250 * Assert t the matched {@link Component}s exists on current UI;if not,assertError will be raised. 1251 * @syscap SystemCapability.Test.UiTest 1252 * @param {On} on The attribute requirements of the target {@link Component}. 1253 * @throws {BusinessError} 401 - if the input parameters are invalid. 1254 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1255 * @throws {BusinessError} 17000003 - if the assertion failed. 1256 * @since 9 1257 * @test 1258 */ 1259 assertComponentExist(on: On): Promise<void>; 1260 1261 /** 1262 * Press the BACK key. 1263 * @syscap SystemCapability.Test.UiTest 1264 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1265 * @since 9 1266 * @test 1267 */ 1268 pressBack(): Promise<void>; 1269 1270 /** 1271 * Press the specified key. 1272 * @syscap SystemCapability.Test.UiTest 1273 * @param {number} keyCode the target keyCode. 1274 * @throws {BusinessError} 401 - if the input parameters are invalid. 1275 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1276 * @since 9 1277 * @test 1278 */ 1279 triggerKey(keyCode: number): Promise<void>; 1280 1281 /** 1282 * Press two or three key combinations 1283 * @syscap SystemCapability.Test.UiTest 1284 * @param {number} key0 the first keyCode. 1285 * @param {number} key1 the second keyCode. 1286 * @param {number} key2 the third keyCode. 1287 * @throws {BusinessError} 401 - if the input parameters are invalid. 1288 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1289 * @since 9 1290 * @test 1291 */ 1292 triggerCombineKeys(key0: number, key1: number, key2?: number): Promise<void>; 1293 1294 /** 1295 * Click on the specified location on the screen. 1296 * @syscap SystemCapability.Test.UiTest 1297 * @param {number} x The x-coordinate. 1298 * @param {number} y The y-coordinate. 1299 * @throws {BusinessError} 401 - if the input parameters are invalid. 1300 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1301 * @since 9 1302 * @test 1303 */ 1304 click(x: number, y: number): Promise<void>; 1305 1306 /** 1307 * DoubleClick on the specified location on the screen. 1308 * @syscap SystemCapability.Test.UiTest 1309 * @param {number} x The x-coordinate. 1310 * @param {number} y The y-coordinate. 1311 * @throws {BusinessError} 401 - if the input parameters are invalid. 1312 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1313 * @since 9 1314 * @test 1315 */ 1316 doubleClick(x: number, y: number): Promise<void>; 1317 1318 /** 1319 * LongClick on the specified location on the screen. 1320 * @syscap SystemCapability.Test.UiTest 1321 * @param {number} x The x-coordinate. 1322 * @param {number} y The y-coordinate. 1323 * @throws {BusinessError} 401 - if the input parameters are invalid. 1324 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1325 * @since 9 1326 * @test 1327 */ 1328 longClick(x: number, y: number): Promise<void>; 1329 1330 /** 1331 * Swipe on the screen between the specified points. 1332 * @syscap SystemCapability.Test.UiTest 1333 * @param {number} startx The x-coordinate of the starting point. 1334 * @param {number} starty The y-coordinate of the starting point. 1335 * @param {number} endx The x-coordinate of the ending point. 1336 * @param {number} endy The y-coordinate of the ending point. 1337 * @param {number} speed The speed of swipe (pixels per second),default is 600,the value ranges from 200 to 40000,set it 600 if out of range. 1338 * @throws {BusinessError} 401 - if the input parameters are invalid. 1339 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1340 * @since 9 1341 * @test 1342 */ 1343 swipe(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise<void>; 1344 1345 /** 1346 * Drag on the screen between the specified points. 1347 * @syscap SystemCapability.Test.UiTest 1348 * @param {number} startx The x-coordinate of the starting point. 1349 * @param {number} starty The y-coordinate of the starting point. 1350 * @param {number} endx The x-coordinate of the ending point. 1351 * @param {number} endy The y-coordinate of the ending point. 1352 * @param {number} speed The speed of swipe (pixels per second),default is 600,the value ranges from 200 to 40000,set it 600 if out of range. 1353 * @throws {BusinessError} 401 - if the input parameters are invalid. 1354 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1355 * @since 9 1356 * @test 1357 */ 1358 drag(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise<void>; 1359 1360 /** 1361 * Capture current screen and save as picture which PNG format. 1362 * @syscap SystemCapability.Test.UiTest 1363 * @param {string} savePath the path where to store the picture. 1364 * @returns {boolean} true if screen-capturing and file-storing are completed successfully,false otherwise. 1365 * @throws {BusinessError} 401 - if the input parameters are invalid. 1366 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1367 * @since 9 1368 * @test 1369 */ 1370 screenCap(savePath: string): Promise<boolean>; 1371 1372 /** 1373 * Set the rotation of the device display. 1374 * @syscap SystemCapability.Test.UiTest 1375 * @param {DisplayRotation} rotation The target rotation to set. 1376 * @throws {BusinessError} 401 - if the input parameters are invalid. 1377 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1378 * @since 9 1379 * @test 1380 */ 1381 setDisplayRotation(rotation: DisplayRotation): Promise<void>; 1382 1383 /** 1384 * Get the rotation of the device display. 1385 * @syscap SystemCapability.Test.UiTest 1386 * @returns {DisplayRotation} the current display rotation. 1387 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1388 * @since 9 1389 * @test 1390 */ 1391 getDisplayRotation(): Promise<DisplayRotation>; 1392 1393 /** 1394 * Enable/disable the rotation of device display. 1395 * @syscap SystemCapability.Test.UiTest 1396 * @param {boolean} enabled Enable the rotation or not. 1397 * @throws {BusinessError} 401 - if the input parameters are invalid. 1398 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1399 * @since 9 1400 * @test 1401 */ 1402 setDisplayRotationEnabled(enabled: boolean): Promise<void>; 1403 1404 /** 1405 * Get the size of the device display. 1406 * @syscap SystemCapability.Test.UiTest 1407 * @returns {Point} the size of the device display. 1408 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1409 * @since 9 1410 * @test 1411 */ 1412 getDisplaySize(): Promise<Point>; 1413 1414 /** 1415 * Get the density of the device display. 1416 * @syscap SystemCapability.Test.UiTest 1417 * @returns {Point} the density of the device display. 1418 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1419 * @since 9 1420 * @test 1421 */ 1422 getDisplayDensity(): Promise<Point>; 1423 1424 /** 1425 * Wake up the device display. 1426 * @syscap SystemCapability.Test.UiTest 1427 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1428 * @since 9 1429 * @test 1430 */ 1431 wakeUpDisplay(): Promise<void>; 1432 1433 /** 1434 * Press the home key. 1435 * @syscap SystemCapability.Test.UiTest 1436 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1437 * @since 9 1438 * @test 1439 */ 1440 pressHome(): Promise<void>; 1441 1442 /** 1443 * Wait for the UI become idle. 1444 * @syscap SystemCapability.Test.UiTest 1445 * @param {number} idleTime the threshold of UI idle time, in millisecond. 1446 * @param {number} timeout The maximum time to wait for idle, in millisecond. 1447 * @returns {boolean} true if wait for idle succeed in the timeout, false otherwise. 1448 * @throws {BusinessError} 401 - if the input parameters are invalid. 1449 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1450 * @since 9 1451 * @test 1452 */ 1453 waitForIdle(idleTime: number, timeout: number): Promise<boolean>; 1454 1455 /** 1456 * Inject fling on the device display. 1457 * @syscap SystemCapability.Test.UiTest 1458 * @param {Point} from The coordinate point where the finger touches the screen. 1459 * @param {Point} to The coordinate point where the finger leaves the screen. 1460 * @param {number} stepLen the length of each step, in pixels. 1461 * @param {number} speed The speed of fling (pixels per second),default is 600,the value ranges from 200 to 40000,set it 600 if out of range. 1462 * @throws {BusinessError} 401 - if the input parameters are invalid. 1463 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1464 * @since 9 1465 * @test 1466 */ 1467 fling(from: Point, to: Point, stepLen: number, speed: number): Promise<void>; 1468 1469 /** 1470 * Inject multi-pointer action on the device display. 1471 * @syscap SystemCapability.Test.UiTest 1472 * @param {PointerMatrix} pointers The two-dimensional array of pointers to inject. 1473 * @param {number} speed The speed of swipe (pixels per second),default is 600,the value ranges from 200 to 40000,set it 600 if out of range. 1474 * @returns {boolean} true if the operation finished, false 1475 * @throws {BusinessError} 401 - if the input parameters are invalid. 1476 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1477 * @since 9 1478 * @test 1479 */ 1480 injectMultiPointerAction(pointers: PointerMatrix, speed?: number): Promise<boolean>; 1481} 1482 1483/** 1484 * @since 9 1485 * @test 1486 * @syscap SystemCapability.Test.UiTest 1487 */ 1488declare class UiWindow { 1489 /** 1490 * Get the bundle name of this {@link UiWindow}. 1491 * @syscap SystemCapability.Test.UiTest 1492 * @returns {string} the bundle name. 1493 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1494 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1495 * @since 9 1496 * @test 1497 */ 1498 getBundleName(): Promise<string>; 1499 1500 /** 1501 * Get the bounds rect of this {@link UiWindow}. 1502 * @syscap SystemCapability.Test.UiTest 1503 * @returns {Rect} the bounds rect object. 1504 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1505 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1506 * @since 9 1507 * @test 1508 */ 1509 getBounds(): Promise<Rect>; 1510 1511 /** 1512 * Get the title of this {@link UiWindow}. 1513 * @syscap SystemCapability.Test.UiTest 1514 * @returns {string} the title value. 1515 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1516 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1517 * @since 9 1518 * @test 1519 */ 1520 getTitle(): Promise<string>; 1521 1522 /** 1523 * Get the window mode of this {@link UiWindow}. 1524 * @syscap SystemCapability.Test.UiTest 1525 * @returns {WindowMode} the {@link WindowMode} object 1526 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1527 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1528 * @since 9 1529 * @test 1530 */ 1531 getWindowMode(): Promise<WindowMode>; 1532 1533 /** 1534 * Get the focused status of this {@link UiWindow}. 1535 * @syscap SystemCapability.Test.UiTest 1536 * @returns {boolean} the focused status 1537 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1538 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1539 * @since 9 1540 * @test 1541 */ 1542 isFocused(): Promise<boolean>; 1543 1544 /** 1545 * Get the active status of this {@link UiWindow}. 1546 * @syscap SystemCapability.Test.UiTest 1547 * @returns {boolean} the actived status 1548 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1549 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1550 * @since 9 1551 * @test 1552 */ 1553 isActived(): Promise<boolean>; 1554 1555 /** 1556 * Set the focused status of this {@link UiWindow}. 1557 * @syscap SystemCapability.Test.UiTest 1558 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1559 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1560 * @since 9 1561 * @test 1562 */ 1563 focus(): Promise<void>; 1564 1565 /** 1566 * Move this {@link UiWindow} to the specified points. 1567 * @syscap SystemCapability.Test.UiTest 1568 * @param {number} x The x coordinate of destination. 1569 * @param {number} y The y coordinate of destination. 1570 * @throws {BusinessError} 401 - if the input parameters are invalid. 1571 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1572 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1573 * @throws {BusinessError} 17000005 - if the action is not supported on this window. 1574 * @since 9 1575 * @test 1576 */ 1577 moveTo(x: number, y: number): Promise<void>; 1578 1579 /** 1580 * Resize this {@link UiWindow} to the specified size for the specified direction. 1581 * @syscap SystemCapability.Test.UiTest 1582 * @param {number} wide The expected wide of the window after resizing. 1583 * @param {number} height The expected height of the window after resizing. 1584 * @param {ResizeDirection} direction The expected direction of the window after resizing. 1585 * @throws {BusinessError} 401 - if the input parameters are invalid. 1586 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1587 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1588 * @throws {BusinessError} 17000005 - if the action is not supported on this window. 1589 * @since 9 1590 * @test 1591 */ 1592 resize(wide: number, height: number, direction: ResizeDirection): Promise<void>; 1593 1594 /** 1595 * Change this {@link UiWindow} into split screen mode. 1596 * @syscap SystemCapability.Test.UiTest 1597 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1598 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1599 * @throws {BusinessError} 17000005 - if the action is not supported on this window. 1600 * @since 9 1601 * @test 1602 */ 1603 split(): Promise<void>; 1604 1605 /** 1606 * Maximize this {@link UiWindow}. 1607 * @syscap SystemCapability.Test.UiTest 1608 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1609 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1610 * @throws {BusinessError} 17000005 - if the action is not supported on this window. 1611 * @since 9 1612 * @test 1613 */ 1614 maximize(): Promise<void>; 1615 1616 /** 1617 * Minimize this {@link UiWindow}. 1618 * @syscap SystemCapability.Test.UiTest 1619 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1620 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1621 * @throws {BusinessError} 17000005 - if the action is not supported on this window. 1622 * @since 9 1623 * @test 1624 */ 1625 minimize(): Promise<void>; 1626 1627 /** 1628 * Resume this {@link UiWindow}. 1629 * @syscap SystemCapability.Test.UiTest 1630 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1631 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1632 * @throws {BusinessError} 17000005 - if the action is not supported on this window. 1633 * @since 9 1634 * @test 1635 */ 1636 resume(): Promise<void>; 1637 1638 /** 1639 * Close this {@link UiWindow}. 1640 * @syscap SystemCapability.Test.UiTest 1641 * @throws {BusinessError} 17000002 - if the async function was not called with await. 1642 * @throws {BusinessError} 17000004 - if the window is invisible or destroyed. 1643 * @throws {BusinessError} 17000005 - if the action is not supported on this window. 1644 * @since 9 1645 * @test 1646 */ 1647 close(): Promise<void>; 1648} 1649 1650/** 1651 * Represents a two-dimensional array of pointers on the device display, it's used to build a 1652 * multi-finger trace which can be injected with UiDriver. 1653 * 1654 * @since 9 1655 * @test 1656 * @syscap SystemCapability.Test.UiTest 1657 */ 1658declare class PointerMatrix { 1659 /** 1660 * Create an {@link PointerMatrix} object. 1661 * @syscap SystemCapability.Test.UiTest 1662 * @param {number} fingers The number of fingers. 1663 * @param {number} steps The number of steps of each finger trace. 1664 * @returns {PointerMatrix} the {@link PointerMatrix} object. 1665 * @throws {BusinessError} 401 - if the input parameters are invalid. 1666 * @since 9 1667 * @test 1668 */ 1669 static create(fingers: number, steps: number): PointerMatrix; 1670 1671 /** 1672 * Set the point value of an element in the PointerMatrix. 1673 * @syscap SystemCapability.Test.UiTest 1674 * @param {number} finger The index of target finger to set. 1675 * @param {number} step The index of target step to set. 1676 * @param {number} point The coordinate of target step to set. 1677 * @throws {BusinessError} 401 - if the input parameters are invalid. 1678 * @since 9 1679 * @test 1680 */ 1681 setPoint(finger: number, step: number, point: Point): void; 1682} 1683 1684/** 1685 * The static builder for building {@link By}object conveniently,usage example:BY.text('txt').enabled(true). 1686 * @syscap SystemCapability.Test.UiTest 1687 * @since 8 1688 * @deprecated since 9 1689 * @useinstead ohos.uitest.ON 1690 * @test 1691 */ 1692declare const BY: By; 1693/** 1694 * The static builder for building {@link On}object conveniently,usage example:ON.text('txt').enabled(true). 1695 * @syscap SystemCapability.Test.UiTest 1696 * @since 9 1697 * @test 1698 */ 1699declare const ON: On; 1700 1701export {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix}; 1702