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 16import type { Callback } from './@ohos.base'; 17 18/** 19 * Enumerates the string value match pattern. 20 * 21 * @enum {number} 22 * @syscap SystemCapability.Test.UiTest 23 * @since 8 24 */ 25/** 26 * Enumerates the string value match pattern. 27 * 28 * @enum {number} 29 * @syscap SystemCapability.Test.UiTest 30 * @crossplatform 31 * @since 10 32 */ 33declare enum MatchPattern { 34 /** 35 * Equals to a string. 36 * 37 * @syscap SystemCapability.Test.UiTest 38 * @since 8 39 * @test 40 */ 41 /** 42 * Equals to a string. 43 * 44 * @syscap SystemCapability.Test.UiTest 45 * @crossplatform 46 * @since 10 47 * @test 48 */ 49 EQUALS = 0, 50 /** 51 * Contains a substring. 52 * 53 * @syscap SystemCapability.Test.UiTest 54 * @since 8 55 * @test 56 */ 57 /** 58 * Equals to a string. 59 * 60 * @syscap SystemCapability.Test.UiTest 61 * @crossplatform 62 * @since 10 63 * @test 64 */ 65 CONTAINS = 1, 66 /** 67 * StartsWith a substring. 68 * 69 * @syscap SystemCapability.Test.UiTest 70 * @since 8 71 * @test 72 */ 73 /** 74 * StartsWith a substring. 75 * 76 * @syscap SystemCapability.Test.UiTest 77 * @crossplatform 78 * @since 10 79 * @test 80 */ 81 STARTS_WITH = 2, 82 /** 83 * EndsWith a substring. 84 * 85 * @syscap SystemCapability.Test.UiTest 86 * @since 8 87 * @test 88 */ 89 /** 90 * EndsWith a substring. 91 * 92 * @syscap SystemCapability.Test.UiTest 93 * @crossplatform 94 * @since 10 95 * @test 96 */ 97 ENDS_WITH = 3 98} 99 100/** 101 * Describes the attribute requirements for the target UiComponents. 102 * 103 * @syscap SystemCapability.Test.UiTest 104 * @since 8 105 * @deprecated since 9 106 * @useinstead ohos.UiTest.On 107 */ 108declare class By { 109 /** 110 * Specifies the text for the target UiComponent. 111 * 112 * @param { string } txt The text value. 113 * @param { MatchPattern } pattern The {@link MatchPattern} of the text value,default to {@link MatchPattern.EQUALS} 114 * @returns { By } this {@link By} object. 115 * @syscap SystemCapability.Test.UiTest 116 * @since 8 117 * @deprecated since 9 118 * @useinstead ohos.UiTest.On#text 119 * @test 120 */ 121 text(txt: string, pattern?: MatchPattern): By; 122 123 /** 124 * Specifies the inspector key of the target UiComponent. 125 * 126 * @param { string } key The inspectorKey value. 127 * @returns { By } this {@link By} object. 128 * @syscap SystemCapability.Test.UiTest 129 * @since 8 130 * @deprecated since 9 131 * @useinstead ohos.UiTest.On#id 132 * @test 133 */ 134 key(key: string): By; 135 136 /** 137 * Specifies the id of the target UiComponent. 138 * 139 * @param { number } id The id value. 140 * @returns { By } this {@link By} object. 141 * @syscap SystemCapability.Test.UiTest 142 * @since 8 143 * @deprecated since 9 144 * @test 145 */ 146 id(id: number): By; 147 148 /** 149 * Specifies the type of the target UiComponent. 150 * 151 * @param { string } tp The type value. 152 * @returns { By } this {@link By} object. 153 * @syscap SystemCapability.Test.UiTest 154 * @since 8 155 * @deprecated since 9 156 * @useinstead ohos.UiTest.On#type 157 * @test 158 */ 159 type(tp: string): By; 160 161 /** 162 * Specifies the clickable status of the target UiComponent. 163 * 164 * @param { boolean } b The clickable status,default to true. 165 * @returns { By } this {@link By} object. 166 * @syscap SystemCapability.Test.UiTest 167 * @since 8 168 * @deprecated since 9 169 * @useinstead ohos.UiTest.On#clickable 170 * @test 171 */ 172 clickable(b?: boolean): By; 173 174 /** 175 * Specifies the scrollable status of the target UiComponent. 176 * 177 * @param { boolean } b The scrollable status,default to true. 178 * @returns { By } this {@link By} object. 179 * @syscap SystemCapability.Test.UiTest 180 * @since 8 181 * @deprecated since 9 182 * @useinstead ohos.UiTest.On#scrollable 183 * @test 184 */ 185 scrollable(b?: boolean): By; 186 187 /** 188 * Specifies the enabled status of the target UiComponent. 189 * 190 * @param { boolean } b The enabled status,default to true. 191 * @returns { By } this {@link By} object. 192 * @syscap SystemCapability.Test.UiTest 193 * @since 8 194 * @deprecated since 9 195 * @useinstead ohos.UiTest.On#enabled 196 * @test 197 */ 198 enabled(b?: boolean): By; 199 200 /** 201 * Specifies the focused status of the target UiComponent. 202 * 203 * @param { boolean } b The focused status,default to true. 204 * @returns { By } this {@link By} object. 205 * @syscap SystemCapability.Test.UiTest 206 * @since 8 207 * @deprecated since 9 208 * @useinstead ohos.UiTest.On#focused 209 * @test 210 */ 211 focused(b?: boolean): By; 212 213 /** 214 * Specifies the selected status of the target UiComponent. 215 * 216 * @param { boolean } b The selected status,default to true. 217 * @returns { By } this {@link By} object. 218 * @syscap SystemCapability.Test.UiTest 219 * @since 8 220 * @deprecated since 9 221 * @useinstead ohos.UiTest.On#selected 222 * @test 223 */ 224 selected(b?: boolean): By; 225 226 /** 227 * Requires the target UiComponent which is before another UiComponent that specified by the given {@link By} 228 * object,used to locate UiComponent relatively. 229 * 230 * @param { By } by Describes the attribute requirements of UiComponent which the target one is in front of. 231 * @returns { By } this {@link By} object. 232 * @syscap SystemCapability.Test.UiTest 233 * @since 8 234 * @deprecated since 9 235 * @useinstead ohos.UiTest.On#isBefore 236 * @test 237 */ 238 isBefore(by: By): By; 239 240 /** 241 * Requires the target UiComponent which is after another UiComponent that specified by the given {@link By} 242 * object,used to locate UiComponent relatively. 243 * 244 * @param { By } by Describes the attribute requirements of UiComponent which the target one is in back of. 245 * @returns { By } this {@link By} object. 246 * @syscap SystemCapability.Test.UiTest 247 * @since 8 248 * @deprecated since 9 249 * @useinstead ohos.UiTest.On#isAfter 250 * @test 251 */ 252 isAfter(by: By): By; 253} 254 255/** 256 * Represents a UiComponent of the ohos application,user can perform operations or query attributes on it. 257 * 258 * @syscap SystemCapability.Test.UiTest 259 * @since 8 260 * @deprecated since 9 261 * @useinstead ohos.uitest.Component 262 * @test 263 */ 264declare class UiComponent { 265 /** 266 * Click this {@link UiComponent}. 267 * 268 * @returns { Promise<void> } 269 * @syscap SystemCapability.Test.UiTest 270 * @since 8 271 * @deprecated since 9 272 * @useinstead ohos.UiTest.Component#click 273 * @test 274 */ 275 click(): Promise<void>; 276 277 /** 278 * Double click this {@link UiComponent}. 279 * 280 * @returns { Promise<void> } 281 * @syscap SystemCapability.Test.UiTest 282 * @since 8 283 * @deprecated since 9 284 * @useinstead ohos.UiTest.Component#doubleClick 285 * @test 286 */ 287 doubleClick(): Promise<void>; 288 289 /** 290 * Long click this {@link UiComponent}. 291 * 292 * @returns { Promise<void> } 293 * @syscap SystemCapability.Test.UiTest 294 * @since 8 295 * @deprecated since 9 296 * @useinstead ohos.UiTest.Component#longClick 297 * @test 298 */ 299 longClick(): Promise<void>; 300 301 /** 302 * Get the id attribute value. 303 * 304 * @returns { Promise<number> } the id value. 305 * @syscap SystemCapability.Test.UiTest 306 * @since 8 307 * @deprecated since 9 308 * @test 309 */ 310 getId(): Promise<number>; 311 312 /** 313 * Get the inspectorKey attribute value. 314 * 315 * @returns { Promise<string> } the inspectorKey value. 316 * @syscap SystemCapability.Test.UiTest 317 * @since 8 318 * @deprecated since 9 319 * @useinstead ohos.UiTest.Component#getId 320 * @test 321 */ 322 getKey(): Promise<string>; 323 324 /** 325 * Get the text attribute value. 326 * 327 * @returns { Promise<string> } the text value. 328 * @syscap SystemCapability.Test.UiTest 329 * @since 8 330 * @deprecated since 9 331 * @useinstead ohos.UiTest.Component#getText 332 * @test 333 */ 334 getText(): Promise<string>; 335 336 /** 337 * Get the type name. 338 * 339 * @returns { Promise<string> } the type name. 340 * @syscap SystemCapability.Test.UiTest 341 * @since 8 342 * @deprecated since 9 343 * @useinstead ohos.UiTest.Component#getType 344 * @test 345 */ 346 getType(): Promise<string>; 347 348 /** 349 * Get the clickable status of this {@link UiComponent}. 350 * 351 * @returns { Promise<boolean> } the clickable status. 352 * @syscap SystemCapability.Test.UiTest 353 * @since 8 354 * @deprecated since 9 355 * @useinstead ohos.UiTest.Component#isClickable 356 * @test 357 */ 358 isClickable(): Promise<boolean>; 359 360 /** 361 * Get the scrollable status of this {@link UiComponent}. 362 * 363 * @returns { Promise<boolean> } the scrollable status. 364 * @syscap SystemCapability.Test.UiTest 365 * @since 8 366 * @deprecated since 9 367 * @useinstead ohos.UiTest.Component#isScrollable 368 * @test 369 */ 370 isScrollable(): Promise<boolean>; 371 372 /** 373 * Get the enabled status of this {@link UiComponent}. 374 * 375 * @returns { Promise<boolean> } the enabled status. 376 * @syscap SystemCapability.Test.UiTest 377 * @since 8 378 * @deprecated since 9 379 * @useinstead ohos.UiTest.Component#isEnabled 380 * @test 381 */ 382 isEnabled(): Promise<boolean>; 383 384 /** 385 * Get the focused status of this {@link UiComponent}. 386 * 387 * @returns { Promise<boolean> } the focused status. 388 * @syscap SystemCapability.Test.UiTest 389 * @since 8 390 * @deprecated since 9 391 * @useinstead ohos.UiTest.Component#isFocused 392 * @test 393 */ 394 isFocused(): Promise<boolean>; 395 396 /** 397 * Get the selected status of this {@link UiComponent}. 398 * 399 * @returns { Promise<boolean> } the selected status. 400 * @syscap SystemCapability.Test.UiTest 401 * @since 8 402 * @deprecated since 9 403 * @useinstead ohos.UiTest.Component#isSelected 404 * @test 405 */ 406 isSelected(): Promise<boolean>; 407 408 /** 409 * Inject text to this {@link UiComponent},applicable to TextInput. 410 * 411 * @param { string } text The text to inject. 412 * @returns { Promise<void> } 413 * @syscap SystemCapability.Test.UiTest 414 * @since 8 415 * @deprecated since 9 416 * @useinstead ohos.UiTest.Component#inputText 417 * @test 418 */ 419 inputText(text: string): Promise<void>; 420 421 /** 422 * Scroll on this {@link UiComponent}to find matched {@link UiComponent},applicable to scrollable one. 423 * 424 * @param { By } by The attribute requirements of the target {@link UiComponent}. 425 * @returns { Promise<UiComponent> } the found result,or undefined if not found. 426 * @syscap SystemCapability.Test.UiTest 427 * @since 8 428 * @deprecated since 9 429 * @useinstead ohos.UiTest.Component#scrollSearch 430 * @test 431 */ 432 scrollSearch(by: By): Promise<UiComponent>; 433} 434 435/** 436 * The unified facade of UiTest framework,can be used to find {@link UiComponent},trigger keyEvents,perform 437 * coordinates-based UI actions,capture screen and so on. 438 * 439 * @syscap SystemCapability.Test.UiTest 440 * @since 8 441 * @deprecated since 9 442 * @useinstead ohos.uitest.Driver 443 * @test 444 */ 445declare class UiDriver { 446 /** 447 * Create an {@link UiDriver} object. 448 * 449 * @returns { UiDriver } the {@link UiDriver} object. 450 * @syscap SystemCapability.Test.UiTest 451 * @since 8 452 * @deprecated since 9 453 * @useinstead ohos.UiTest.Driver#create 454 * @test 455 */ 456 static create(): UiDriver; 457 458 /** 459 * Delay with specified duration. 460 * 461 * @param { number } duration The delay duration in milliseconds. 462 * @returns { Promise<void> } 463 * @syscap SystemCapability.Test.UiTest 464 * @since 8 465 * @deprecated since 9 466 * @useinstead ohos.UiTest.Driver#delayMs 467 * @test 468 */ 469 delayMs(duration: number): Promise<void>; 470 471 /** 472 * Find the first matched {@link UiComponent} on current UI. 473 * 474 * @param { By } by The attribute requirements of the target {@link UiComponent}. 475 * @returns { Promise<UiComponent> } the first matched {@link UiComponent} or undefined. 476 * @syscap SystemCapability.Test.UiTest 477 * @since 8 478 * @deprecated since 9 479 * @useinstead ohos.UiTest.Driver#findComponent 480 * @test 481 */ 482 findComponent(by: By): Promise<UiComponent>; 483 484 /** 485 * Find all the matched {@link UiComponent}s on current UI. 486 * 487 * @param { By } by The attribute requirements of the target {@link UiComponent}. 488 * @returns { Promise<Array<UiComponent>> } the matched {@link UiComponent}s list. 489 * @syscap SystemCapability.Test.UiTest 490 * @since 8 491 * @deprecated since 9 492 * @useinstead ohos.UiTest.Driver#findComponents 493 * @test 494 */ 495 findComponents(by: By): Promise<Array<UiComponent>>; 496 497 /** 498 * Assert the matched {@link UiComponent}s exists on current UI;if not,assertError will be raised. 499 * 500 * @param { By } by The attribute requirements of the target {@link UiComponent}. 501 * @returns { Promise<void> } 502 * @throws {BusinessError} 401 - if the input parameters are invalid. 503 * @throws {BusinessError} 17000002 - if the async function was not called with await. 504 * @throws {BusinessError} 17000003 - if the assertion failed. 505 * @syscap SystemCapability.Test.UiTest 506 * @since 8 507 * @deprecated since 9 508 * @useinstead ohos.UiTest.Driver#assertComponentExist 509 * @test 510 */ 511 assertComponentExist(by: By): Promise<void>; 512 513 /** 514 * Press the BACK key. 515 * 516 * @returns { Promise<void> } 517 * @syscap SystemCapability.Test.UiTest 518 * @since 8 519 * @deprecated since 9 520 * @useinstead ohos.UiTest.Driver#pressBack 521 * @test 522 */ 523 pressBack(): Promise<void>; 524 525 /** 526 * Press the specified key. 527 * 528 * @param { number } keyCode the target keyCode. 529 * @returns { Promise<void> } 530 * @syscap SystemCapability.Test.UiTest 531 * @since 8 532 * @deprecated since 9 533 * @useinstead ohos.UiTest.Driver#triggerKey 534 * @test 535 */ 536 triggerKey(keyCode: number): Promise<void>; 537 538 /** 539 * Click on the specified location on the screen. 540 * 541 * @param { number } x The x-coordinate. 542 * @param { number } y The y-coordinate. 543 * @returns { Promise<void> } 544 * @syscap SystemCapability.Test.UiTest 545 * @since 8 546 * @deprecated since 9 547 * @useinstead ohos.UiTest.Driver#click 548 * @test 549 */ 550 click(x: number, y: number): Promise<void>; 551 552 /** 553 * DoubleClick on the specified location on the screen. 554 * 555 * @param { number } x The x-coordinate. 556 * @param { number } y The y-coordinate. 557 * @returns { Promise<void> } 558 * @syscap SystemCapability.Test.UiTest 559 * @since 8 560 * @deprecated since 9 561 * @useinstead ohos.UiTest.Driver#doubleClick 562 * @test 563 */ 564 doubleClick(x: number, y: number): Promise<void>; 565 566 /** 567 * LongClick on the specified location on the screen. 568 * 569 * @param { number } x The x-coordinate. 570 * @param { number } y The y-coordinate. 571 * @returns { Promise<void> } 572 * @syscap SystemCapability.Test.UiTest 573 * @since 8 574 * @deprecated since 9 575 * @useinstead ohos.UiTest.Driver#longClick 576 * @test 577 */ 578 longClick(x: number, y: number): Promise<void>; 579 580 /** 581 * Swipe on the screen between the specified points. 582 * 583 * @param { number } startx The x-coordinate of the starting point. 584 * @param { number } starty The y-coordinate of the starting point. 585 * @param { number } endx The x-coordinate of the ending point. 586 * @param { number } endy The y-coordinate of the ending point. 587 * @returns { Promise<void> } 588 * @syscap SystemCapability.Test.UiTest 589 * @since 8 590 * @deprecated since 9 591 * @useinstead ohos.UiTest.Driver#swipe 592 * @test 593 */ 594 swipe(startx: number, starty: number, endx: number, endy: number): Promise<void>; 595 596 /** 597 * Capture current screen and save as picture which PNG format. 598 * 599 * @param { string } savePath the path where to store the picture. 600 * @returns { Promise<boolean> } true if screen-capturing and file-storing are completed successfully,false otherwise. 601 * @syscap SystemCapability.Test.UiTest 602 * @since 8 603 * @deprecated since 9 604 * @useinstead ohos.uitest.Driver#screenCap 605 * @test 606 */ 607 screenCap(savePath: string): Promise<boolean>; 608} 609 610/** 611 * Enumerates the window mode of the tested window. 612 * 613 * @enum { number } 614 * @syscap SystemCapability.Test.UiTest 615 * @since 9 616 */ 617declare enum WindowMode { 618 /** 619 * The test window is a full screen window. 620 * 621 * @syscap SystemCapability.Test.UiTest 622 * @since 9 623 * @test 624 */ 625 FULLSCREEN = 0, 626 /** 627 * The test window is the first window in the split screen state. 628 * 629 * @syscap SystemCapability.Test.UiTest 630 * @since 9 631 * @test 632 */ 633 PRIMARY = 1, 634 /** 635 * The test window is the second window in the split screen state. 636 * 637 * @syscap SystemCapability.Test.UiTest 638 * @since 9 639 * @test 640 */ 641 SECONDARY = 2, 642 /** 643 * The test window is a floating window. 644 * 645 * @syscap SystemCapability.Test.UiTest 646 * @since 9 647 * @test 648 */ 649 FLOATING = 3 650} 651 652/** 653 * Enumerates the resize direction for the window. 654 * 655 * @enum { number } 656 * @syscap SystemCapability.Test.UiTest 657 * @since 9 658 */ 659declare enum ResizeDirection { 660 /** 661 * Left. 662 * 663 * @syscap SystemCapability.Test.UiTest 664 * @since 9 665 * @test 666 */ 667 LEFT = 0, 668 /** 669 * Right. 670 * 671 * @syscap SystemCapability.Test.UiTest 672 * @since 9 673 * @test 674 */ 675 RIGHT = 1, 676 /** 677 * Up. 678 * 679 * @syscap SystemCapability.Test.UiTest 680 * @since 9 681 * @test 682 */ 683 UP = 2, 684 /** 685 * Down. 686 * 687 * @syscap SystemCapability.Test.UiTest 688 * @since 9 689 * @test 690 */ 691 DOWN = 3, 692 /** 693 * Upper left. 694 * 695 * @syscap SystemCapability.Test.UiTest 696 * @since 9 697 * @test 698 */ 699 LEFT_UP = 4, 700 /** 701 * Lower left. 702 * 703 * @syscap SystemCapability.Test.UiTest 704 * @since 9 705 * @test 706 */ 707 LEFT_DOWN = 5, 708 /** 709 * Upper right. 710 * 711 * @syscap SystemCapability.Test.UiTest 712 * @since 9 713 * @test 714 */ 715 RIGHT_UP = 6, 716 /** 717 * Lower right. 718 * 719 * @syscap SystemCapability.Test.UiTest 720 * @since 9 721 * @test 722 */ 723 RIGHT_DOWN = 7 724} 725 726/** 727 * Enumerates the rotation of the device display. 728 * 729 * @enum { number } 730 * @syscap SystemCapability.Test.UiTest 731 * @since 9 732 */ 733declare enum DisplayRotation { 734 /** 735 * Device display does not rotate to display vertically. 736 * 737 * @syscap SystemCapability.Test.UiTest 738 * @since 9 739 * @test 740 */ 741 ROTATION_0 = 0, 742 /** 743 * Device display rotates 90 degrees clockwise to display horizontally. 744 * 745 * @syscap SystemCapability.Test.UiTest 746 * @since 9 747 * @test 748 */ 749 ROTATION_90 = 1, 750 /** 751 * Device display rotates clockwise 180 degrees to display vertically in reverse. 752 * 753 * @syscap SystemCapability.Test.UiTest 754 * @since 9 755 * @test 756 */ 757 ROTATION_180 = 2, 758 /** 759 * Device display rotates 270 degrees clockwise to display horizontally in reverse. 760 * 761 * @syscap SystemCapability.Test.UiTest 762 * @since 9 763 * @test 764 */ 765 ROTATION_270 = 3 766} 767 768/** 769 * Represents the point on the device screen. 770 * 771 * @typedef Point 772 * @syscap SystemCapability.Test.UiTest 773 * @since 9 774 */ 775/** 776 * Represents the point on the device screen. 777 * 778 * @typedef Point 779 * @syscap SystemCapability.Test.UiTest 780 * @crossplatform 781 * @since 10 782 */ 783declare interface Point { 784 /** 785 * The x-coordinate of the coordinate point. 786 * 787 * @type { number } 788 * @syscap SystemCapability.Test.UiTest 789 * @since 9 790 */ 791 /** 792 * The x-coordinate of the coordinate point. 793 * 794 * @type { number } 795 * @syscap SystemCapability.Test.UiTest 796 * @crossplatform 797 * @since 10 798 */ 799 readonly x: number; 800 /** 801 * The y-coordinate of the coordinate point. 802 * 803 * @type { number } 804 * @syscap SystemCapability.Test.UiTest 805 * @since 9 806 */ 807 /** 808 * The y-coordinate of the coordinate point. 809 * 810 * @type { number } 811 * @syscap SystemCapability.Test.UiTest 812 * @crossplatform 813 * @since 10 814 */ 815 readonly y: number; 816} 817 818/** 819 * Represents the rectangle area on the device screen. 820 * 821 * @typedef Rect 822 * @syscap SystemCapability.Test.UiTest 823 * @since 9 824 */ 825declare interface Rect { 826 /** 827 * The x-coordinate of the top left corner of the rectangle. 828 * 829 * @type { number } 830 * @syscap SystemCapability.Test.UiTest 831 * @since 9 832 */ 833 readonly left: number; 834 /** 835 * The y-coordinate of the top left corner of the rectangle. 836 * 837 * @type { number } 838 * @syscap SystemCapability.Test.UiTest 839 * @since 9 840 */ 841 readonly top: number; 842 /** 843 * The x-coordinate at the bottom right corner of the rectangle. 844 * 845 * @type { number } 846 * @syscap SystemCapability.Test.UiTest 847 * @since 9 848 */ 849 readonly right: number; 850 /** 851 * The y-coordinate at the bottom right corner of the rectangle. 852 * 853 * @type { number } 854 * @syscap SystemCapability.Test.UiTest 855 * @since 9 856 */ 857 readonly bottom: number; 858} 859 860/** 861 * Represents filer condition to get the window . 862 * 863 * @typedef WindowFilter 864 * @syscap SystemCapability.Test.UiTest 865 * @since 9 866 */ 867declare interface WindowFilter { 868 /** 869 * The package name of the application which the window belongs to. 870 * 871 * @type { ?string } 872 * @syscap SystemCapability.Test.UiTest 873 * @since 9 874 */ 875 bundleName?: string; 876 /** 877 * The title of the window. 878 * 879 * @type { ?string } 880 * @syscap SystemCapability.Test.UiTest 881 * @since 9 882 */ 883 title?: string; 884 /** 885 * The focal state of the window. 886 * 887 * @type { ?boolean } 888 * @syscap SystemCapability.Test.UiTest 889 * @since 9 890 */ 891 focused?: boolean; 892 /** 893 * The active state of the window. 894 * 895 * @type { ?boolean } 896 * @syscap SystemCapability.Test.UiTest 897 * @since 9 898 */ 899 actived?: boolean; 900} 901 902/** 903 * Represents the information of an UI element, can be a component or window. 904 * 905 * @typedef UIElementInfo 906 * @syscap SystemCapability.Test.UiTest 907 * @since 10 908 * @test 909 */ 910declare interface UIElementInfo { 911 /** 912 * The bundle name of the host application. 913 * @type { string } 914 * @syscap SystemCapability.Test.UiTest 915 * @since 10 916 * @test 917 */ 918 readonly bundleName: string; 919 /** 920 * The component type, set it as 'window' if it's a window. 921 * @type { string } 922 * @syscap SystemCapability.Test.UiTest 923 * @since 10 924 * @test 925 */ 926 readonly type: string; 927 /** 928 * The text of component, set it as window's title if it's a window. 929 * @type { string } 930 * @syscap SystemCapability.Test.UiTest 931 * @since 10 932 * @test 933 */ 934 readonly text: string; 935} 936 937/** 938 * Observer to monitor UI events. 939 * 940 * @typedef UIEventObserver 941 * @syscap SystemCapability.Test.UiTest 942 * @since 10 943 * @test 944 */ 945declare interface UIEventObserver { 946 /** 947 * Listen for toast show once 948 * 949 * @param { 'toastShow' } type 'toastShow'. 950 * @param { Callback<UIElementInfo> } callback function, returns the monitored UIElementInfo. 951 * @throws { BusinessError } 401 - if the input parameters are invalid. 952 * @syscap SystemCapability.Test.UiTest 953 * @since 10 954 * @test 955 */ 956 once(type: 'toastShow', callback: Callback<UIElementInfo>): void; 957 958 /** 959 * Listen for dialog show once 960 * 961 * @param { 'dialogShow' } type 'dialogShow'. 962 * @param { Callback<UIElementInfo> } callback function, returns the monitored UIElementInfo. 963 * @throws { BusinessError } 401 - if the input parameters are invalid. 964 * @syscap SystemCapability.Test.UiTest 965 * @since 10 966 * @test 967 */ 968 once(type: 'dialogShow', callback: Callback<UIElementInfo>): void; 969} 970 971/** 972 * Enumerates the direction for the UI operation . 973 * 974 * @enum { number } 975 * @syscap SystemCapability.Test.UiTest 976 * @since 10 977 */ 978declare enum UiDirection { 979 /** 980 * Left. 981 * 982 * @syscap SystemCapability.Test.UiTest 983 * @since 10 984 * @test 985 */ 986 LEFT = 0, 987 /** 988 * Right. 989 * 990 * @syscap SystemCapability.Test.UiTest 991 * @since 10 992 * @test 993 */ 994 RIGHT = 1, 995 /** 996 * Up. 997 * 998 * @syscap SystemCapability.Test.UiTest 999 * @since 10 1000 * @test 1001 */ 1002 UP = 2, 1003 /** 1004 * Down. 1005 * 1006 * @syscap SystemCapability.Test.UiTest 1007 * @since 10 1008 * @test 1009 */ 1010 DOWN = 3 1011} 1012 1013/** 1014 * Enumerates the id of the button on the mouse. 1015 * 1016 * @enum { number } 1017 * @syscap SystemCapability.Test.UiTest 1018 * @since 10 1019 */ 1020declare enum MouseButton { 1021 /** 1022 * Left button of the mouse. 1023 * 1024 * @syscap SystemCapability.Test.UiTest 1025 * @since 10 1026 * @test 1027 */ 1028 MOUSE_BUTTON_LEFT = 0, 1029 /** 1030 * Right button of the mouse.. 1031 * 1032 * @syscap SystemCapability.Test.UiTest 1033 * @since 10 1034 * @test 1035 */ 1036 MOUSE_BUTTON_RIGHT = 1, 1037 /** 1038 * MIDDLE button of the mouse. 1039 * 1040 * @syscap SystemCapability.Test.UiTest 1041 * @since 10 1042 * @test 1043 */ 1044 MOUSE_BUTTON_MIDDLE = 2 1045} 1046 1047/** 1048 * Describes the attribute requirements for the target Components. 1049 * 1050 * @syscap SystemCapability.Test.UiTest 1051 * @since 9 1052 */ 1053declare class On { 1054 /** 1055 * Specifies the text for the target Component. 1056 * 1057 * @param { string } txt The text value. 1058 * @param { MatchPattern } pattern The {@link MatchPattern} of the text value, default to {@link MatchPattern.EQUALS} 1059 * @returns { On } this {@link On} object. 1060 * @throws { BusinessError } 401 - if the input parameters are invalid. 1061 * @syscap SystemCapability.Test.UiTest 1062 * @since 9 1063 * @test 1064 */ 1065 /** 1066 * Specifies the text for the target Component. 1067 * 1068 * @param { string } txt The text value. 1069 * @param { MatchPattern } pattern The {@link MatchPattern} of the text value, default to {@link MatchPattern.EQUALS} 1070 * @returns { On } this {@link On} object. 1071 * @throws { BusinessError } 401 - if the input parameters are invalid. 1072 * @syscap SystemCapability.Test.UiTest 1073 * @crossplatform 1074 * @since 10 1075 * @test 1076 */ 1077 text(txt: string, pattern?: MatchPattern): On; 1078 1079 /** 1080 * Specifies the id of the target Component. 1081 * 1082 * @param { string } id The id value. 1083 * @returns { On } this {@link On} object. 1084 * @throws { BusinessError } 401 - if the input parameters are invalid. 1085 * @syscap SystemCapability.Test.UiTest 1086 * @since 9 1087 * @test 1088 */ 1089 /** 1090 * Specifies the id of the target Component. 1091 * 1092 * @param { string } id The id value. 1093 * @returns { On } this {@link On} object. 1094 * @throws { BusinessError } 401 - if the input parameters are invalid. 1095 * @syscap SystemCapability.Test.UiTest 1096 * @crossplatform 1097 * @since 10 1098 * @test 1099 */ 1100 id(id: string): On; 1101 1102 /** 1103 * Specifies the type of the target Component. 1104 * 1105 * @param { string } tp The type value. 1106 * @returns { On } this {@link On} object. 1107 * @throws { BusinessError } 401 - if the input parameters are invalid. 1108 * @syscap SystemCapability.Test.UiTest 1109 * @since 9 1110 * @test 1111 */ 1112 /** 1113 * Specifies the type of the target Component. 1114 * 1115 * @param { string } tp The type value. 1116 * @returns { On } this {@link On} object. 1117 * @throws { BusinessError } 401 - if the input parameters are invalid. 1118 * @syscap SystemCapability.Test.UiTest 1119 * @crossplatform 1120 * @since 10 1121 * @test 1122 */ 1123 type(tp: string): On; 1124 1125 /** 1126 * Specifies the clickable status of the target Component. 1127 * 1128 * @param { boolean } b The clickable status,default to true. 1129 * @returns { On } this {@link On} object. 1130 * @throws { BusinessError } 401 - if the input parameters are invalid. 1131 * @syscap SystemCapability.Test.UiTest 1132 * @since 9 1133 * @test 1134 */ 1135 /** 1136 * Specifies the clickable status of the target Component. 1137 * 1138 * @param { boolean } b The clickable status,default to true. 1139 * @returns { On } this {@link On} object. 1140 * @throws { BusinessError } 401 - if the input parameters are invalid. 1141 * @syscap SystemCapability.Test.UiTest 1142 * @crossplatform 1143 * @since 10 1144 * @test 1145 */ 1146 clickable(b?: boolean): On; 1147 1148 /** 1149 * Specifies the longClickable status of the target Component. 1150 * 1151 * @param { boolean } b The clickable status,default to true. 1152 * @returns { On } this {@link On} object. 1153 * @throws { BusinessError } 401 - if the input parameters are invalid. 1154 * @syscap SystemCapability.Test.UiTest 1155 * @since 9 1156 * @test 1157 */ 1158 /** 1159 * Specifies the longClickable status of the target Component. 1160 * 1161 * @param { boolean } b The clickable status,default to true. 1162 * @returns { On } this {@link On} object. 1163 * @throws { BusinessError } 401 - if the input parameters are invalid. 1164 * @syscap SystemCapability.Test.UiTest 1165 * @crossplatform 1166 * @since 10 1167 * @test 1168 */ 1169 longClickable(b?: boolean): On; 1170 1171 /** 1172 * Specifies the scrollable status of the target Component. 1173 * 1174 * @param { boolean } b The scrollable status,default to true. 1175 * @returns { On } this {@link On} object. 1176 * @throws { BusinessError } 401 - if the input parameters are invalid. 1177 * @syscap SystemCapability.Test.UiTest 1178 * @since 9 1179 * @test 1180 */ 1181 /** 1182 * Specifies the scrollable status of the target Component. 1183 * 1184 * @param { boolean } b The scrollable status,default to true. 1185 * @returns { On } this {@link On} object. 1186 * @throws { BusinessError } 401 - if the input parameters are invalid. 1187 * @syscap SystemCapability.Test.UiTest 1188 * @crossplatform 1189 * @since 10 1190 * @test 1191 */ 1192 scrollable(b?: boolean): On; 1193 1194 /** 1195 * Specifies the enabled status of the target Component. 1196 * 1197 * @param { boolean } b The enabled status,default to true. 1198 * @returns { On } this {@link On} object. 1199 * @throws { BusinessError } 401 - if the input parameters are invalid. 1200 * @syscap SystemCapability.Test.UiTest 1201 * @since 9 1202 * @test 1203 */ 1204 /** 1205 * Specifies the enabled status of the target Component. 1206 * 1207 * @param { boolean } b The enabled status,default to true. 1208 * @returns { On } this {@link On} object. 1209 * @throws { BusinessError } 401 - if the input parameters are invalid. 1210 * @syscap SystemCapability.Test.UiTest 1211 * @crossplatform 1212 * @since 10 1213 * @test 1214 */ 1215 enabled(b?: boolean): On; 1216 1217 /** 1218 * Specifies the focused status of the target Component. 1219 * 1220 * @param { boolean } b The focused status,default to true. 1221 * @returns { On } this {@link On} object. 1222 * @throws { BusinessError } 401 - if the input parameters are invalid. 1223 * @syscap SystemCapability.Test.UiTest 1224 * @since 9 1225 * @test 1226 */ 1227 /** 1228 * Specifies the focused status of the target Component. 1229 * 1230 * @param { boolean } b The focused status,default to true. 1231 * @returns { On } this {@link On} object. 1232 * @throws { BusinessError } 401 - if the input parameters are invalid. 1233 * @syscap SystemCapability.Test.UiTest 1234 * @crossplatform 1235 * @since 10 1236 * @test 1237 */ 1238 focused(b?: boolean): On; 1239 1240 /** 1241 * Specifies the selected status of the target Component. 1242 * 1243 * @param { boolean } b The selected status,default to true. 1244 * @returns { On } this {@link On} object. 1245 * @throws { BusinessError } 401 - if the input parameters are invalid. 1246 * @syscap SystemCapability.Test.UiTest 1247 * @since 9 1248 * @test 1249 */ 1250 /** 1251 * Specifies the selected status of the target Component. 1252 * 1253 * @param { boolean } b The selected status,default to true. 1254 * @returns { On } this {@link On} object. 1255 * @throws { BusinessError } 401 - if the input parameters are invalid. 1256 * @syscap SystemCapability.Test.UiTest 1257 * @crossplatform 1258 * @since 10 1259 * @test 1260 */ 1261 selected(b?: boolean): On; 1262 1263 /** 1264 * Specifies the checked status of the target Component. 1265 * 1266 * @param { boolean } b The checked status,default to false. 1267 * @returns { On } this {@link On} object. 1268 * @throws { BusinessError } 401 - if the input parameters are invalid. 1269 * @syscap SystemCapability.Test.UiTest 1270 * @since 9 1271 * @test 1272 */ 1273 /** 1274 * Specifies the checked status of the target Component. 1275 * 1276 * @param { boolean } b The checked status,default to false. 1277 * @returns { On } this {@link On} object. 1278 * @throws { BusinessError } 401 - if the input parameters are invalid. 1279 * @syscap SystemCapability.Test.UiTest 1280 * @crossplatform 1281 * @since 10 1282 * @test 1283 */ 1284 checked(b?: boolean): On; 1285 1286 /** 1287 * Specifies the checkable status of the target Component. 1288 * 1289 * @param { boolean } b The checkable status,default to false. 1290 * @returns { On } this {@link On} object. 1291 * @throws { BusinessError } 401 - if the input parameters are invalid. 1292 * @syscap SystemCapability.Test.UiTest 1293 * @since 9 1294 * @test 1295 */ 1296 /** 1297 * Specifies the checkable status of the target Component. 1298 * 1299 * @param { boolean } b The checkable status,default to false. 1300 * @returns { On } this {@link On} object. 1301 * @throws { BusinessError } 401 - if the input parameters are invalid. 1302 * @syscap SystemCapability.Test.UiTest 1303 * @crossplatform 1304 * @since 10 1305 * @test 1306 */ 1307 checkable(b?: boolean): On; 1308 1309 /** 1310 * Requires that the target Component which is before another Component that specified by the given {@link On} 1311 * object,used to locate Component relatively. 1312 * 1313 * @param { On } on Describes the attribute requirements of Component which the target one is in front of. 1314 * @returns { On } this {@link On} object. 1315 * @throws { BusinessError } 401 - if the input parameters are invalid. 1316 * @syscap SystemCapability.Test.UiTest 1317 * @since 9 1318 * @test 1319 */ 1320 isBefore(on: On): On; 1321 1322 /** 1323 * Requires that the target Component which is after another Component that specified by the given {@link On} 1324 * object,used to locate Component relatively. 1325 * 1326 * @param { On } on Describes the attribute requirements of Component which the target one is in back of. 1327 * @returns { On } this {@link On} object. 1328 * @throws { BusinessError } 401 - if the input parameters are invalid. 1329 * @syscap SystemCapability.Test.UiTest 1330 * @since 9 1331 * @test 1332 */ 1333 isAfter(on: On): On; 1334 1335 /** 1336 * Requires that the target Component which is inside of another Component that specified by the given {@link On} 1337 * object,used to locate Component relatively. 1338 * 1339 * @param { On } on Describes the attribute requirements of Component which the target one is inside of. 1340 * @returns { On } this {@link On} object. 1341 * @throws { BusinessError } 401 - if the input parameters are invalid. 1342 * @syscap SystemCapability.Test.UiTest 1343 * @since 10 1344 * @test 1345 */ 1346 within(on: On): On; 1347 1348 /** 1349 * Specifies the bundleName of the application which the window that the target Component is located belongs. 1350 * 1351 * @param { string } bundleName The bundleName of the specified window. 1352 * @returns { On } this {@link On} object. 1353 * @throws { BusinessError } 401 - if the input parameters are invalid. 1354 * @syscap SystemCapability.Test.UiTest 1355 * @since 10 1356 * @test 1357 */ 1358 inWindow(bundleName: string): On; 1359} 1360 1361/** 1362 * Represents an Component of the ohos application,user can perform operations or query attributes on it. 1363 * 1364 * @syscap SystemCapability.Test.UiTest 1365 * @since 9 1366 * @test 1367 */ 1368declare class Component { 1369 /** 1370 * Click this {@link Component}. 1371 * 1372 * @returns { Promise<void> } 1373 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1374 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1375 * @syscap SystemCapability.Test.UiTest 1376 * @since 9 1377 * @test 1378 */ 1379 /** 1380 * Click this {@link Component}. 1381 * 1382 * @returns { Promise<void> } 1383 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1384 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1385 * @syscap SystemCapability.Test.UiTest 1386 * @crossplatform 1387 * @since 10 1388 * @test 1389 */ 1390 click(): Promise<void>; 1391 1392 /** 1393 * Double click this {@link Component}. 1394 * 1395 * @returns { Promise<void> } 1396 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1397 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1398 * @syscap SystemCapability.Test.UiTest 1399 * @since 9 1400 * @test 1401 */ 1402 /** 1403 * Double click this {@link Component}. 1404 * 1405 * @returns { Promise<void> } 1406 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1407 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1408 * @syscap SystemCapability.Test.UiTest 1409 * @crossplatform 1410 * @since 10 1411 * @test 1412 */ 1413 doubleClick(): Promise<void>; 1414 1415 /** 1416 * Long click this {@link Component}. 1417 * 1418 * @returns { Promise<void> } 1419 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1420 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1421 * @syscap SystemCapability.Test.UiTest 1422 * @since 9 1423 * @test 1424 */ 1425 /** 1426 * Long click this {@link Component}. 1427 * 1428 * @returns { Promise<void> } 1429 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1430 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1431 * @syscap SystemCapability.Test.UiTest 1432 * @crossplatform 1433 * @since 10 1434 * @test 1435 */ 1436 longClick(): Promise<void>; 1437 1438 /** 1439 * Get the id attribute value. 1440 * 1441 * @returns { Promise<string> } the id value. 1442 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1443 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1444 * @syscap SystemCapability.Test.UiTest 1445 * @since 9 1446 * @test 1447 */ 1448 /** 1449 * Get the id attribute value. 1450 * 1451 * @returns { Promise<string> } the id value. 1452 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1453 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1454 * @syscap SystemCapability.Test.UiTest 1455 * @crossplatform 1456 * @since 10 1457 * @test 1458 */ 1459 getId(): Promise<string>; 1460 1461 /** 1462 * Get the text attribute value. 1463 * 1464 * @returns { Promise<string> } the text value. 1465 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1466 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1467 * @syscap SystemCapability.Test.UiTest 1468 * @since 9 1469 * @test 1470 */ 1471 /** 1472 * Get the text attribute value. 1473 * 1474 * @returns { Promise<string> } the text value. 1475 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1476 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1477 * @syscap SystemCapability.Test.UiTest 1478 * @crossplatform 1479 * @since 10 1480 * @test 1481 */ 1482 getText(): Promise<string>; 1483 1484 /** 1485 * Get the type name. 1486 * 1487 * @returns { Promise<string> } the type name. 1488 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1489 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1490 * @syscap SystemCapability.Test.UiTest 1491 * @since 9 1492 * @test 1493 */ 1494 /** 1495 * Get the type name. 1496 * 1497 * @returns { Promise<string> } the type name. 1498 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1499 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1500 * @syscap SystemCapability.Test.UiTest 1501 * @crossplatform 1502 * @since 10 1503 * @test 1504 */ 1505 getType(): Promise<string>; 1506 1507 /** 1508 * Get the clickable status of this {@link Component}. 1509 * 1510 * @returns { Promise<boolean> } the clickable status. 1511 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1512 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1513 * @syscap SystemCapability.Test.UiTest 1514 * @since 9 1515 * @test 1516 */ 1517 /** 1518 * Get the clickable status of this {@link Component}. 1519 * 1520 * @returns { Promise<boolean> } the clickable status. 1521 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1522 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1523 * @syscap SystemCapability.Test.UiTest 1524 * @crossplatform 1525 * @since 10 1526 * @test 1527 */ 1528 isClickable(): Promise<boolean>; 1529 1530 /** 1531 * Get the longClickable status of this {@link Component}. 1532 * 1533 * @returns { Promise<boolean> } the longClickable status. 1534 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1535 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1536 * @syscap SystemCapability.Test.UiTest 1537 * @since 9 1538 * @test 1539 */ 1540 /** 1541 * Get the longClickable status of this {@link Component}. 1542 * 1543 * @returns { Promise<boolean> } the longClickable status. 1544 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1545 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1546 * @syscap SystemCapability.Test.UiTest 1547 * @crossplatform 1548 * @since 10 1549 * @test 1550 */ 1551 isLongClickable(): Promise<boolean>; 1552 1553 /** 1554 * Get the scrollable status of this {@link Component}. 1555 * 1556 * @returns { Promise<boolean> } the scrollable status. 1557 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1558 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1559 * @syscap SystemCapability.Test.UiTest 1560 * @since 9 1561 * @test 1562 */ 1563 /** 1564 * Get the scrollable status of this {@link Component}. 1565 * 1566 * @returns { Promise<boolean> } the scrollable status. 1567 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1568 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1569 * @syscap SystemCapability.Test.UiTest 1570 * @crossplatform 1571 * @since 10 1572 * @test 1573 */ 1574 isScrollable(): Promise<boolean>; 1575 1576 /** 1577 * Get the enabled status of this {@link Component}. 1578 * 1579 * @returns { Promise<boolean> } the enabled status. 1580 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1581 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1582 * @syscap SystemCapability.Test.UiTest 1583 * @since 9 1584 * @test 1585 */ 1586 /** 1587 * Get the enabled status of this {@link Component}. 1588 * 1589 * @returns { Promise<boolean> } the enabled status. 1590 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1591 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1592 * @syscap SystemCapability.Test.UiTest 1593 * @crossplatform 1594 * @since 10 1595 * @test 1596 */ 1597 isEnabled(): Promise<boolean>; 1598 1599 /** 1600 * Get the focused status of this {@link Component}. 1601 * 1602 * @returns { Promise<boolean> } the focused status. 1603 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1604 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1605 * @syscap SystemCapability.Test.UiTest 1606 * @since 9 1607 * @test 1608 */ 1609 /** 1610 * Get the focused status of this {@link Component}. 1611 * 1612 * @returns { Promise<boolean> } the focused status. 1613 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1614 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1615 * @syscap SystemCapability.Test.UiTest 1616 * @crossplatform 1617 * @since 10 1618 * @test 1619 */ 1620 isFocused(): Promise<boolean>; 1621 1622 /** 1623 * Get the selected status of this {@link Component}. 1624 * 1625 * @returns { Promise<boolean> } the selected status. 1626 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1627 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1628 * @syscap SystemCapability.Test.UiTest 1629 * @since 9 1630 * @test 1631 */ 1632 /** 1633 * Get the selected status of this {@link Component}. 1634 * 1635 * @returns { Promise<boolean> } the selected status. 1636 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1637 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1638 * @syscap SystemCapability.Test.UiTest 1639 * @crossplatform 1640 * @since 10 1641 * @test 1642 */ 1643 isSelected(): Promise<boolean>; 1644 1645 /** 1646 * Get the checked status of this {@link Component}. 1647 * 1648 * @returns { Promise<boolean> } the checked status. 1649 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1650 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1651 * @syscap SystemCapability.Test.UiTest 1652 * @since 9 1653 * @test 1654 */ 1655 /** 1656 * Get the checked status of this {@link Component}. 1657 * 1658 * @returns { Promise<boolean> } the checked status. 1659 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1660 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1661 * @syscap SystemCapability.Test.UiTest 1662 * @crossplatform 1663 * @since 10 1664 * @test 1665 */ 1666 isChecked(): Promise<boolean>; 1667 1668 /** 1669 * Get the checkable status of this {@link Component}. 1670 * 1671 * @returns { Promise<boolean> } the checkable status. 1672 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1673 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1674 * @syscap SystemCapability.Test.UiTest 1675 * @since 9 1676 * @test 1677 */ 1678 /** 1679 * Get the checkable status of this {@link Component}. 1680 * 1681 * @returns { Promise<boolean> } the checkable status. 1682 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1683 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1684 * @syscap SystemCapability.Test.UiTest 1685 * @crossplatform 1686 * @since 10 1687 * @test 1688 */ 1689 isCheckable(): Promise<boolean>; 1690 1691 /** 1692 * Inject text to this {@link Component},applicable to TextInput. 1693 * 1694 * @param { string } text The text to inject. 1695 * @returns { Promise<void> } 1696 * @throws { BusinessError } 401 - if the input parameters are invalid. 1697 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1698 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1699 * @syscap SystemCapability.Test.UiTest 1700 * @since 9 1701 * @test 1702 */ 1703 /** 1704 * Inject text to this {@link Component},applicable to TextInput. 1705 * 1706 * @param { string } text The text to inject. 1707 * @returns { Promise<void> } 1708 * @throws { BusinessError } 401 - if the input parameters are invalid. 1709 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1710 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1711 * @syscap SystemCapability.Test.UiTest 1712 * @crossplatform 1713 * @since 10 1714 * @test 1715 */ 1716 inputText(text: string): Promise<void>; 1717 1718 /** 1719 * Clear text of this {@link Component},applicable to TextInput. 1720 * 1721 * @returns { Promise<void> } 1722 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1723 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1724 * @syscap SystemCapability.Test.UiTest 1725 * @since 9 1726 * @test 1727 */ 1728 /** 1729 * Clear text of this {@link Component},applicable to TextInput. 1730 * 1731 * @returns { Promise<void> } 1732 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1733 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1734 * @syscap SystemCapability.Test.UiTest 1735 * @crossplatform 1736 * @since 10 1737 * @test 1738 */ 1739 clearText(): Promise<void>; 1740 1741 /** 1742 * Scroll on this {@link Component} to the top,applicable to scrollable one. 1743 * 1744 * @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. 1745 * @returns { Promise<void> } 1746 * @throws { BusinessError } 401 - if the input parameters are invalid. 1747 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1748 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1749 * @syscap SystemCapability.Test.UiTest 1750 * @since 9 1751 * @test 1752 */ 1753 /** 1754 * Scroll on this {@link Component} to the top,applicable to scrollable one. 1755 * 1756 * @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. 1757 * @returns { Promise<void> } 1758 * @throws { BusinessError } 401 - if the input parameters are invalid. 1759 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1760 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1761 * @syscap SystemCapability.Test.UiTest 1762 * @crossplatform 1763 * @since 10 1764 * @test 1765 */ 1766 scrollToTop(speed?: number): Promise<void>; 1767 1768 /** 1769 * Scroll on this {@link Component} to the bottom,applicable to scrollable one. 1770 * 1771 * @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. 1772 * @returns { Promise<void> } 1773 * @throws { BusinessError } 401 - if the input parameters are invalid. 1774 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1775 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1776 * @syscap SystemCapability.Test.UiTest 1777 * @since 9 1778 * @test 1779 */ 1780 /** 1781 * Scroll on this {@link Component} to the bottom,applicable to scrollable one. 1782 * 1783 * @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. 1784 * @returns { Promise<void> } 1785 * @throws { BusinessError } 401 - if the input parameters are invalid. 1786 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1787 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1788 * @syscap SystemCapability.Test.UiTest 1789 * @crossplatform 1790 * @since 10 1791 * @test 1792 */ 1793 scrollToBottom(speed?: number): Promise<void>; 1794 1795 /** 1796 * Scroll on this {@link Component}to find matched {@link Component},applicable to scrollable one. 1797 * 1798 * @param { On } on The attribute requirements of the target {@link Component}. 1799 * @returns { Promise<Component> } the found result,or undefined if not found. 1800 * @throws { BusinessError } 401 - if the input parameters are invalid. 1801 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1802 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1803 * @syscap SystemCapability.Test.UiTest 1804 * @since 9 1805 * @test 1806 */ 1807 /** 1808 * Scroll on this {@link Component}to find matched {@link Component},applicable to scrollable one. 1809 * 1810 * @param { On } on The attribute requirements of the target {@link Component}. 1811 * @returns { Promise<Component> } the found result,or undefined if not found. 1812 * @throws { BusinessError } 401 - if the input parameters are invalid. 1813 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1814 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1815 * @syscap SystemCapability.Test.UiTest 1816 * @crossplatform 1817 * @since 10 1818 * @test 1819 */ 1820 scrollSearch(on: On): Promise<Component>; 1821 1822 /** 1823 * Get the bounds rect of this {@link Component}. 1824 * 1825 * @returns { Promise<Rect> } the bounds rect object. 1826 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1827 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1828 * @syscap SystemCapability.Test.UiTest 1829 * @since 9 1830 * @test 1831 */ 1832 getBounds(): Promise<Rect>; 1833 1834 /** 1835 * Get the boundsCenter of this {@link Component}. 1836 * 1837 * @returns { Promise<Point> } the boundsCenter object. 1838 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1839 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1840 * @syscap SystemCapability.Test.UiTest 1841 * @since 9 1842 * @test 1843 */ 1844 /** 1845 * Get the boundsCenter of this {@link Component}. 1846 * 1847 * @returns { Promise<Point> } the boundsCenter object. 1848 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1849 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1850 * @syscap SystemCapability.Test.UiTest 1851 * @crossplatform 1852 * @since 10 1853 * @test 1854 */ 1855 getBoundsCenter(): Promise<Point>; 1856 1857 /** 1858 * Drag this {@link Component} to the bounds rect of target Component. 1859 * 1860 * @param { Component } target The target {@link Component}. 1861 * @returns { Promise<void> } 1862 * @throws { BusinessError } 401 - if the input parameters are invalid. 1863 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1864 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1865 * @syscap SystemCapability.Test.UiTest 1866 * @since 9 1867 * @test 1868 */ 1869 dragTo(target: Component): Promise<void>; 1870 1871 /** 1872 * Pinch enlarge this {@link Component} to the target scale. 1873 * 1874 * @param { number } scale The scale of the pinch enlarge this {@link Component}'s size. 1875 * @returns { Promise<void> } 1876 * @throws { BusinessError } 401 - if the input parameters are invalid. 1877 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1878 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1879 * @syscap SystemCapability.Test.UiTest 1880 * @since 9 1881 * @test 1882 */ 1883 pinchOut(scale: number): Promise<void>; 1884 1885 /** 1886 * Pinch shrink this {@link Component} to the target scale. 1887 * 1888 * @param { number } scale The scale of the pinch shrink this {@link Component}'s size. 1889 * @returns { Promise<void> } 1890 * @throws { BusinessError } 401 - if the input parameters are invalid. 1891 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1892 * @throws { BusinessError } 17000004 - if the component is invisible or destroyed. 1893 * @syscap SystemCapability.Test.UiTest 1894 * @since 9 1895 * @test 1896 */ 1897 pinchIn(scale: number): Promise<void>; 1898} 1899 1900/** 1901 * The unified facade of UiTest framework,can be used to find {@link Component},trigger keyEvents,perform 1902 * coordinates-based UI actions,capture screen and so on. 1903 * 1904 * @syscap SystemCapability.Test.UiTest 1905 * @since 9 1906 * @test 1907 */ 1908declare class Driver { 1909 /** 1910 * Create an {@link Driver} object. 1911 * 1912 * @returns { Driver } the {@link Driver} object. 1913 * @throws { BusinessError } 17000001 - if the test framework failed to initialize. 1914 * @syscap SystemCapability.Test.UiTest 1915 * @since 9 1916 * @test 1917 */ 1918 /** 1919 * Create an {@link Driver} object. 1920 * 1921 * @returns { Driver } the {@link Driver} object. 1922 * @throws { BusinessError } 17000001 - if the test framework failed to initialize. 1923 * @syscap SystemCapability.Test.UiTest 1924 * @crossplatform 1925 * @since 10 1926 * @test 1927 */ 1928 static create(): Driver; 1929 1930 /** 1931 * Delay with specified duration. 1932 * 1933 * @param { number } duration The delay duration in milliseconds. 1934 * @returns { Promise<void> } 1935 * @throws { BusinessError } 401 - if the input parameters are invalid. 1936 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1937 * @syscap SystemCapability.Test.UiTest 1938 * @since 9 1939 * @test 1940 */ 1941 /** 1942 * Delay with specified duration. 1943 * 1944 * @param { number } duration The delay duration in milliseconds. 1945 * @returns { Promise<void> } 1946 * @throws { BusinessError } 401 - if the input parameters are invalid. 1947 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1948 * @syscap SystemCapability.Test.UiTest 1949 * @crossplatform 1950 * @since 10 1951 * @test 1952 */ 1953 delayMs(duration: number): Promise<void>; 1954 1955 /** 1956 * Find the first matched {@link Component} on current UI. 1957 * 1958 * @param { On } on The attribute requirements of the target {@link Component}. 1959 * @returns { Promise<Component> } the first matched {@link Component} or undefined. 1960 * @throws { BusinessError } 401 - if the input parameters are invalid. 1961 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1962 * @syscap SystemCapability.Test.UiTest 1963 * @since 9 1964 * @test 1965 */ 1966 /** 1967 * Find the first matched {@link Component} on current UI. 1968 * 1969 * @param { On } on The attribute requirements of the target {@link Component}. 1970 * @returns { Promise<Component> } the first matched {@link Component} or undefined. 1971 * @throws { BusinessError } 401 - if the input parameters are invalid. 1972 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1973 * @syscap SystemCapability.Test.UiTest 1974 * @crossplatform 1975 * @since 10 1976 * @test 1977 */ 1978 findComponent(on: On): Promise<Component>; 1979 1980 /** 1981 * Find the first matched {@link UiWindow} window. 1982 * 1983 * @param { WindowFilter } filter The filer condition of the target {@link UiWindow}. 1984 * @returns { Promise<UiWindow> } the first matched {@link UiWindow} or undefined. 1985 * @throws { BusinessError } 401 - if the input parameters are invalid. 1986 * @throws { BusinessError } 17000002 - if the async function was not called with await. 1987 * @syscap SystemCapability.Test.UiTest 1988 * @since 9 1989 * @test 1990 */ 1991 findWindow(filter: WindowFilter): Promise<UiWindow>; 1992 1993 /** 1994 * Find the first matched {@link Component} on current UI during the time given. 1995 * 1996 * @param { On } on The attribute requirements of the target {@link Component}. 1997 * @param { number } time Duration of finding in milliseconds 1998 * @returns { Promise<Component> } the first matched {@link Component} or undefined. 1999 * @throws { BusinessError } 401 - if the input parameters are invalid. 2000 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2001 * @syscap SystemCapability.Test.UiTest 2002 * @since 9 2003 * @test 2004 */ 2005 waitForComponent(on: On, time: number): Promise<Component>; 2006 2007 /** 2008 * Find all the matched {@link Component}s on current UI. 2009 * 2010 * @param { On } on The attribute requirements of the target {@link Component}. 2011 * @returns { Promise<Array<Component>> } the matched {@link Component}s list. 2012 * @throws { BusinessError } 401 - if the input parameters are invalid. 2013 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2014 * @syscap SystemCapability.Test.UiTest 2015 * @since 9 2016 * @test 2017 */ 2018 /** 2019 * Find all the matched {@link Component}s on current UI. 2020 * 2021 * @param { On } on The attribute requirements of the target {@link Component}. 2022 * @returns { Promise<Array<Component>> } the matched {@link Component}s list. 2023 * @throws { BusinessError } 401 - if the input parameters are invalid. 2024 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2025 * @syscap SystemCapability.Test.UiTest 2026 * @crossplatform 2027 * @since 10 2028 * @test 2029 */ 2030 findComponents(on: On): Promise<Array<Component>>; 2031 2032 /** 2033 * Assert t the matched {@link Component}s exists on current UI;if not,assertError will be raised. 2034 * 2035 * @param { On } on The attribute requirements of the target {@link Component}. 2036 * @returns { Promise<void> } 2037 * @throws { BusinessError } 401 - if the input parameters are invalid. 2038 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2039 * @throws { BusinessError } 17000003 - if the assertion failed. 2040 * @syscap SystemCapability.Test.UiTest 2041 * @since 9 2042 * @test 2043 */ 2044 /** 2045 * Assert t the matched {@link Component}s exists on current UI;if not,assertError will be raised. 2046 * 2047 * @param { On } on The attribute requirements of the target {@link Component}. 2048 * @returns { Promise<void> } 2049 * @throws { BusinessError } 401 - if the input parameters are invalid. 2050 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2051 * @throws { BusinessError } 17000003 - if the assertion failed. 2052 * @syscap SystemCapability.Test.UiTest 2053 * @crossplatform 2054 * @since 10 2055 * @test 2056 */ 2057 assertComponentExist(on: On): Promise<void>; 2058 2059 /** 2060 * Press the BACK key. 2061 * 2062 * @returns { Promise<void> } 2063 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2064 * @syscap SystemCapability.Test.UiTest 2065 * @since 9 2066 * @test 2067 */ 2068 /** 2069 * Press the BACK key. 2070 * 2071 * @returns { Promise<void> } 2072 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2073 * @syscap SystemCapability.Test.UiTest 2074 * @crossplatform 2075 * @since 10 2076 * @test 2077 */ 2078 pressBack(): Promise<void>; 2079 2080 /** 2081 * Press the specified key. 2082 * 2083 * @param { number } keyCode the target keyCode. 2084 * @returns { Promise<void> } 2085 * @throws { BusinessError } 401 - if the input parameters are invalid. 2086 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2087 * @syscap SystemCapability.Test.UiTest 2088 * @since 9 2089 * @test 2090 */ 2091 triggerKey(keyCode: number): Promise<void>; 2092 2093 /** 2094 * Press two or three key combinations 2095 * 2096 * @param { number } key0 the first keyCode. 2097 * @param { number } key1 the second keyCode. 2098 * @param { number } key2 the third keyCode. 2099 * @returns { Promise<void> } 2100 * @throws { BusinessError } 401 - if the input parameters are invalid. 2101 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2102 * @syscap SystemCapability.Test.UiTest 2103 * @since 9 2104 * @test 2105 */ 2106 triggerCombineKeys(key0: number, key1: number, key2?: number): Promise<void>; 2107 2108 /** 2109 * Click on the specified location on the screen. 2110 * 2111 * @param { number } x The x-coordinate. 2112 * @param { number } y The y-coordinate. 2113 * @returns { Promise<void> } 2114 * @throws { BusinessError } 401 - if the input parameters are invalid. 2115 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2116 * @syscap SystemCapability.Test.UiTest 2117 * @since 9 2118 * @test 2119 */ 2120 /** 2121 * Click on the specified location on the screen. 2122 * 2123 * @param { number } x The x-coordinate. 2124 * @param { number } y The y-coordinate. 2125 * @returns { Promise<void> } 2126 * @throws { BusinessError } 401 - if the input parameters are invalid. 2127 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2128 * @syscap SystemCapability.Test.UiTest 2129 * @crossplatform 2130 * @since 10 2131 * @test 2132 */ 2133 click(x: number, y: number): Promise<void>; 2134 2135 /** 2136 * DoubleClick on the specified location on the screen. 2137 * 2138 * @param { number } x The x-coordinate. 2139 * @param { number } y The y-coordinate. 2140 * @returns { Promise<void> } 2141 * @throws { BusinessError } 401 - if the input parameters are invalid. 2142 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2143 * @syscap SystemCapability.Test.UiTest 2144 * @since 9 2145 * @test 2146 */ 2147 /** 2148 * DoubleClick on the specified location on the screen. 2149 * 2150 * @param { number } x The x-coordinate. 2151 * @param { number } y The y-coordinate. 2152 * @returns { Promise<void> } 2153 * @throws { BusinessError } 401 - if the input parameters are invalid. 2154 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2155 * @syscap SystemCapability.Test.UiTest 2156 * @crossplatform 2157 * @since 10 2158 * @test 2159 */ 2160 doubleClick(x: number, y: number): Promise<void>; 2161 2162 /** 2163 * LongClick on the specified location on the screen. 2164 * 2165 * @param { number } x The x-coordinate. 2166 * @param { number } y The y-coordinate. 2167 * @returns { Promise<void> } 2168 * @throws { BusinessError } 401 - if the input parameters are invalid. 2169 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2170 * @syscap SystemCapability.Test.UiTest 2171 * @since 9 2172 * @test 2173 */ 2174 /** 2175 * LongClick on the specified location on the screen. 2176 * 2177 * @param { number } x The x-coordinate. 2178 * @param { number } y The y-coordinate. 2179 * @returns { Promise<void> } 2180 * @throws { BusinessError } 401 - if the input parameters are invalid. 2181 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2182 * @syscap SystemCapability.Test.UiTest 2183 * @crossplatform 2184 * @since 10 2185 * @test 2186 */ 2187 longClick(x: number, y: number): Promise<void>; 2188 2189 /** 2190 * Swipe on the screen between the specified points. 2191 * 2192 * @param { number } startx The x-coordinate of the starting point. 2193 * @param { number } starty The y-coordinate of the starting point. 2194 * @param { number } endx The x-coordinate of the ending point. 2195 * @param { number } endy The y-coordinate of the ending point. 2196 * @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. 2197 * @returns { Promise<void> } 2198 * @throws { BusinessError } 401 - if the input parameters are invalid. 2199 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2200 * @syscap SystemCapability.Test.UiTest 2201 * @since 9 2202 * @test 2203 */ 2204 /** 2205 * Swipe on the screen between the specified points. 2206 * 2207 * @param { number } startx The x-coordinate of the starting point. 2208 * @param { number } starty The y-coordinate of the starting point. 2209 * @param { number } endx The x-coordinate of the ending point. 2210 * @param { number } endy The y-coordinate of the ending point. 2211 * @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. 2212 * @returns { Promise<void> } 2213 * @throws { BusinessError } 401 - if the input parameters are invalid. 2214 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2215 * @syscap SystemCapability.Test.UiTest 2216 * @crossplatform 2217 * @since 10 2218 * @test 2219 */ 2220 swipe(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise<void>; 2221 2222 /** 2223 * Drag on the screen between the specified points. 2224 * 2225 * @param { number } startx The x-coordinate of the starting point. 2226 * @param { number } starty The y-coordinate of the starting point. 2227 * @param { number } endx The x-coordinate of the ending point. 2228 * @param { number } endy The y-coordinate of the ending point. 2229 * @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. 2230 * @returns { Promise<void> } 2231 * @throws { BusinessError } 401 - if the input parameters are invalid. 2232 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2233 * @syscap SystemCapability.Test.UiTest 2234 * @since 9 2235 * @test 2236 */ 2237 drag(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise<void>; 2238 2239 /** 2240 * Capture current screen and save as picture which PNG format. 2241 * 2242 * @param { string } savePath the path where to store the picture. 2243 * @returns { Promise<boolean> } true if screen-capturing and file-storing are completed successfully,false otherwise. 2244 * @throws { BusinessError } 401 - if the input parameters are invalid. 2245 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2246 * @syscap SystemCapability.Test.UiTest 2247 * @since 9 2248 * @test 2249 */ 2250 screenCap(savePath: string): Promise<boolean>; 2251 2252 /** 2253 * Set the rotation of the device display. 2254 * 2255 * @param { DisplayRotation } rotation The target rotation to set. 2256 * @returns { Promise<void> } 2257 * @throws { BusinessError } 401 - if the input parameters are invalid. 2258 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2259 * @syscap SystemCapability.Test.UiTest 2260 * @since 9 2261 * @test 2262 */ 2263 setDisplayRotation(rotation: DisplayRotation): Promise<void>; 2264 2265 /** 2266 * Get the rotation of the device display. 2267 * 2268 * @returns { Promise<DisplayRotation> } the current display rotation. 2269 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2270 * @syscap SystemCapability.Test.UiTest 2271 * @since 9 2272 * @test 2273 */ 2274 getDisplayRotation(): Promise<DisplayRotation>; 2275 2276 /** 2277 * Enable/disable the rotation of device display. 2278 * 2279 * @param { boolean } enabled Enable the rotation or not. 2280 * @returns { Promise<void> } 2281 * @throws { BusinessError } 401 - if the input parameters are invalid. 2282 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2283 * @syscap SystemCapability.Test.UiTest 2284 * @since 9 2285 * @test 2286 */ 2287 setDisplayRotationEnabled(enabled: boolean): Promise<void>; 2288 2289 /** 2290 * Get the size of the device display. 2291 * 2292 * @returns { Promise<Point> } the size of the device display. 2293 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2294 * @syscap SystemCapability.Test.UiTest 2295 * @since 9 2296 * @test 2297 */ 2298 getDisplaySize(): Promise<Point>; 2299 2300 /** 2301 * Get the density of the device display. 2302 * 2303 * @returns { Promise<Point> } the density of the device display. 2304 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2305 * @syscap SystemCapability.Test.UiTest 2306 * @since 9 2307 * @test 2308 */ 2309 getDisplayDensity(): Promise<Point>; 2310 2311 /** 2312 * Wake up the device display. 2313 * 2314 * @returns { Promise<void> } 2315 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2316 * @syscap SystemCapability.Test.UiTest 2317 * @since 9 2318 * @test 2319 */ 2320 wakeUpDisplay(): Promise<void>; 2321 2322 /** 2323 * Press the home key. 2324 * 2325 * @returns { Promise<void> } 2326 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2327 * @syscap SystemCapability.Test.UiTest 2328 * @since 9 2329 * @test 2330 */ 2331 pressHome(): Promise<void>; 2332 2333 /** 2334 * Wait for the UI become idle. 2335 * 2336 * @param { number } idleTime the threshold of UI idle time, in millisecond. 2337 * @param { number } timeout The maximum time to wait for idle, in millisecond. 2338 * @returns { Promise<boolean> } true if wait for idle succeed in the timeout, false otherwise. 2339 * @throws { BusinessError } 401 - if the input parameters are invalid. 2340 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2341 * @syscap SystemCapability.Test.UiTest 2342 * @since 9 2343 * @test 2344 */ 2345 waitForIdle(idleTime: number, timeout: number): Promise<boolean>; 2346 2347 /** 2348 * Inject fling on the device display. 2349 * 2350 * @param { Point } from The coordinate point where the finger touches the screen. 2351 * @param { Point } to The coordinate point where the finger leaves the screen. 2352 * @param { number } stepLen the length of each step, in pixels. 2353 * @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. 2354 * @returns { Promise<void> } 2355 * @throws { BusinessError } 401 - if the input parameters are invalid. 2356 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2357 * @syscap SystemCapability.Test.UiTest 2358 * @since 9 2359 * @test 2360 */ 2361 /** 2362 * Inject fling on the device display. 2363 * 2364 * @param { Point } from The coordinate point where the finger touches the screen. 2365 * @param { Point } to The coordinate point where the finger leaves the screen. 2366 * @param { number } stepLen the length of each step, in pixels. 2367 * @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. 2368 * @returns { Promise<void> } 2369 * @throws { BusinessError } 401 - if the input parameters are invalid. 2370 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2371 * @syscap SystemCapability.Test.UiTest 2372 * @crossplatform 2373 * @since 10 2374 * @test 2375 */ 2376 fling(from: Point, to: Point, stepLen: number, speed: number): Promise<void>; 2377 2378 /** 2379 * Inject multi-pointer action on the device display. 2380 * 2381 * @param { PointerMatrix } pointers The two-dimensional array of pointers to inject. 2382 * @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. 2383 * @returns { Promise<boolean> } true if the operation finished, false 2384 * @throws { BusinessError } 401 - if the input parameters are invalid. 2385 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2386 * @syscap SystemCapability.Test.UiTest 2387 * @since 9 2388 * @test 2389 */ 2390 injectMultiPointerAction(pointers: PointerMatrix, speed?: number): Promise<boolean>; 2391 2392 /** 2393 * Inject fling on the device display. 2394 * 2395 * @param { UiDirection } direction The direction of this action. 2396 * @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. 2397 * @returns { Promise<void> } 2398 * @throws { BusinessError } 401 - if the input parameters are invalid. 2399 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2400 * @syscap SystemCapability.Test.UiTest 2401 * @since 10 2402 * @test 2403 */ 2404 fling(direction: UiDirection, speed: number): Promise<void>; 2405 2406 /** 2407 * Click on the specified location on the screen with the specified mouse button, and press the specified key simultaneously if necessary. 2408 * 2409 * @param { Point } p The coordinate of the specified location. 2410 * @param { MouseButton } btnId The button of Mouse. 2411 * @param { number } key1 the first keyCode. 2412 * @param { number } key2 the second keyCode. 2413 * @returns { Promise<void> } 2414 * @throws { BusinessError } 401 - if the input parameters are invalid. 2415 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2416 * @syscap SystemCapability.Test.UiTest 2417 * @since 10 2418 * @test 2419 */ 2420 mouseClick(p: Point, btnId: MouseButton, key1?: number, key2?: number): Promise<void>; 2421 2422 /** 2423 * Move the mouse cursor to the specified location. 2424 * 2425 * @param { Point } p The coordinate of the specified location. 2426 * @returns { Promise<void> } 2427 * @throws { BusinessError } 401 - if the input parameters are invalid. 2428 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2429 * @syscap SystemCapability.Test.UiTest 2430 * @since 10 2431 * @test 2432 */ 2433 mouseMoveTo(p: Point): Promise<void>; 2434 2435 /** 2436 * The mouse wheel scrolls the specified cell at the specified position, and press the specified key simultaneously if necessary. 2437 * 2438 * @param { Point } p The coordinate of the specified location. 2439 * @param { boolean } down Whether the mouse wheel rolls down. 2440 * @param { number } d The number of cells that the mouse wheel scrolls, each cell will make the target point shift 120 pixels. 2441 * @param { number } key1 the first keyCode. 2442 * @param { number } key2 the second keyCode. 2443 * @returns { Promise<void> } 2444 * @throws { BusinessError } 401 - if the input parameters are invalid. 2445 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2446 * @syscap SystemCapability.Test.UiTest 2447 * @since 10 2448 * @test 2449 */ 2450 mouseScroll(p: Point, down: boolean, d: number, key1?: number, key2?: number): Promise<void>; 2451 2452 /** 2453 * Capture the specified area of current screen and save as picture which PNG format. 2454 * 2455 * @param { string } savePath the path where to store the picture. 2456 * @param { Rect } rect The specified area of current screen, default full screen. 2457 * @returns { Promise<boolean> } true if screen-capturing and file-storing are completed successfully,false otherwise. 2458 * @throws { BusinessError } 401 - if the input parameters are invalid. 2459 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2460 * @syscap SystemCapability.Test.UiTest 2461 * @since 10 2462 * @test 2463 */ 2464 screenCapture(savePath: string, rect?: Rect): Promise<boolean>; 2465 2466 /** 2467 * Create an {@link UIEventObserver} object. 2468 * 2469 * @returns { UIEventObserver } the {@link UIEventObserver} object. 2470 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2471 * @syscap SystemCapability.Test.UiTest 2472 * @since 10 2473 * @test 2474 */ 2475 createUIEventObserver(): UIEventObserver; 2476} 2477 2478/** 2479 * @syscap SystemCapability.Test.UiTest 2480 * @since 9 2481 * @test 2482 */ 2483declare class UiWindow { 2484 /** 2485 * Get the bundle name of this {@link UiWindow}. 2486 * 2487 * @returns { Promise<string> } the bundle name. 2488 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2489 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2490 * @syscap SystemCapability.Test.UiTest 2491 * @since 9 2492 * @test 2493 */ 2494 getBundleName(): Promise<string>; 2495 2496 /** 2497 * Get the bounds rect of this {@link UiWindow}. 2498 * 2499 * @returns { Promise<Rect> } the bounds rect object. 2500 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2501 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2502 * @syscap SystemCapability.Test.UiTest 2503 * @since 9 2504 * @test 2505 */ 2506 getBounds(): Promise<Rect>; 2507 2508 /** 2509 * Get the title of this {@link UiWindow}. 2510 * 2511 * @returns { Promise<string> } the title value. 2512 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2513 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2514 * @syscap SystemCapability.Test.UiTest 2515 * @since 9 2516 * @test 2517 */ 2518 getTitle(): Promise<string>; 2519 2520 /** 2521 * Get the window mode of this {@link UiWindow}. 2522 * 2523 * @returns { Promise<WindowMode> } the {@link WindowMode} object 2524 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2525 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2526 * @syscap SystemCapability.Test.UiTest 2527 * @since 9 2528 * @test 2529 */ 2530 getWindowMode(): Promise<WindowMode>; 2531 2532 /** 2533 * Get the focused status of this {@link UiWindow}. 2534 * 2535 * @returns { Promise<boolean> } the focused status 2536 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2537 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2538 * @syscap SystemCapability.Test.UiTest 2539 * @since 9 2540 * @test 2541 */ 2542 isFocused(): Promise<boolean>; 2543 2544 /** 2545 * Get the active status of this {@link UiWindow}. 2546 * 2547 * @returns { Promise<boolean> } the actived status 2548 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2549 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2550 * @syscap SystemCapability.Test.UiTest 2551 * @since 9 2552 * @test 2553 */ 2554 isActived(): Promise<boolean>; 2555 2556 /** 2557 * Set the focused status of this {@link UiWindow}. 2558 * 2559 * @returns { Promise<void> } 2560 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2561 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2562 * @syscap SystemCapability.Test.UiTest 2563 * @since 9 2564 * @test 2565 */ 2566 focus(): Promise<void>; 2567 2568 /** 2569 * Move this {@link UiWindow} to the specified points. 2570 * 2571 * @param { number } x The x coordinate of destination. 2572 * @param { number } y The y coordinate of destination. 2573 * @returns { Promise<void> } 2574 * @throws { BusinessError } 401 - if the input parameters are invalid. 2575 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2576 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2577 * @throws { BusinessError } 17000005 - if the action is not supported on this window. 2578 * @syscap SystemCapability.Test.UiTest 2579 * @since 9 2580 * @test 2581 */ 2582 moveTo(x: number, y: number): Promise<void>; 2583 2584 /** 2585 * Resize this {@link UiWindow} to the specified size for the specified direction. 2586 * 2587 * @param { number } wide The expected wide of the window after resizing. 2588 * @param { number } height The expected height of the window after resizing. 2589 * @param { ResizeDirection } direction The expected direction of the window after resizing. 2590 * @returns { Promise<void> } 2591 * @throws { BusinessError } 401 - if the input parameters are invalid. 2592 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2593 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2594 * @throws { BusinessError } 17000005 - if the action is not supported on this window. 2595 * @syscap SystemCapability.Test.UiTest 2596 * @since 9 2597 * @test 2598 */ 2599 resize(wide: number, height: number, direction: ResizeDirection): Promise<void>; 2600 2601 /** 2602 * Change this {@link UiWindow} into split screen mode. 2603 * 2604 * @returns { Promise<void> } 2605 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2606 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2607 * @throws { BusinessError } 17000005 - if the action is not supported on this window. 2608 * @syscap SystemCapability.Test.UiTest 2609 * @since 9 2610 * @test 2611 */ 2612 split(): Promise<void>; 2613 2614 /** 2615 * Maximize this {@link UiWindow}. 2616 * 2617 * @returns { Promise<void> } 2618 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2619 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2620 * @throws { BusinessError } 17000005 - if the action is not supported on this window. 2621 * @syscap SystemCapability.Test.UiTest 2622 * @since 9 2623 * @test 2624 */ 2625 maximize(): Promise<void>; 2626 2627 /** 2628 * Minimize this {@link UiWindow}. 2629 * 2630 * @returns { Promise<void> } 2631 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2632 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2633 * @throws { BusinessError } 17000005 - if the action is not supported on this window. 2634 * @syscap SystemCapability.Test.UiTest 2635 * @since 9 2636 * @test 2637 */ 2638 minimize(): Promise<void>; 2639 2640 /** 2641 * Resume this {@link UiWindow}. 2642 * 2643 * @returns { Promise<void> } 2644 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2645 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2646 * @throws { BusinessError } 17000005 - if the action is not supported on this window. 2647 * @syscap SystemCapability.Test.UiTest 2648 * @since 9 2649 * @test 2650 */ 2651 resume(): Promise<void>; 2652 2653 /** 2654 * Close this {@link UiWindow}. 2655 * 2656 * @returns { Promise<void> } 2657 * @throws { BusinessError } 17000002 - if the async function was not called with await. 2658 * @throws { BusinessError } 17000004 - if the window is invisible or destroyed. 2659 * @throws { BusinessError } 17000005 - if the action is not supported on this window. 2660 * @syscap SystemCapability.Test.UiTest 2661 * @since 9 2662 * @test 2663 */ 2664 close(): Promise<void>; 2665} 2666 2667/** 2668 * Represents a two-dimensional array of pointers on the device display, it's used to build a 2669 * multi-finger trace which can be injected with UiDriver. 2670 * 2671 * @syscap SystemCapability.Test.UiTest 2672 * @since 9 2673 * @test 2674 */ 2675declare class PointerMatrix { 2676 /** 2677 * Create an {@link PointerMatrix} object. 2678 * 2679 * @param { number } fingers The number of fingers. 2680 * @param { number } steps The number of steps of each finger trace. 2681 * @returns { PointerMatrix } the {@link PointerMatrix} object. 2682 * @throws { BusinessError } 401 - if the input parameters are invalid. 2683 * @syscap SystemCapability.Test.UiTest 2684 * @since 9 2685 * @test 2686 */ 2687 static create(fingers: number, steps: number): PointerMatrix; 2688 2689 /** 2690 * Set the point value of an element in the PointerMatrix. 2691 * 2692 * @param { number } finger The index of target finger to set. 2693 * @param { number } step The index of target step to set. 2694 * @param { Point } point The coordinate of target step to set. 2695 * @throws { BusinessError } 401 - if the input parameters are invalid. 2696 * @syscap SystemCapability.Test.UiTest 2697 * @since 9 2698 * @test 2699 */ 2700 setPoint(finger: number, step: number, point: Point): void; 2701} 2702 2703/** 2704 * The static builder for building {@link By}object conveniently,usage example:BY.text('txt').enabled(true). 2705 * 2706 * @syscap SystemCapability.Test.UiTest 2707 * @since 8 2708 * @deprecated since 9 2709 * @useinstead ohos.uitest.ON 2710 * @test 2711 */ 2712declare const BY: By; 2713/** 2714 * The static builder for building {@link On}object conveniently,usage example:ON.text('txt').enabled(true). 2715 * 2716 * @syscap SystemCapability.Test.UiTest 2717 * @since 9 2718 * @test 2719 */ 2720declare const ON: On; 2721 2722export { 2723 UiComponent, 2724 UiDriver, 2725 Component, 2726 Driver, 2727 UiWindow, 2728 ON, 2729 On, 2730 BY, 2731 By, 2732 MatchPattern, 2733 DisplayRotation, 2734 ResizeDirection, 2735 WindowMode, 2736 PointerMatrix, 2737 UiDirection, 2738 MouseButton, 2739 UIElementInfo, 2740 UIEventObserver 2741}; 2742