@@ -67,14 +67,22 @@ export class UIElement {
67
67
* @experimental
68
68
* Double tap on element
69
69
*/
70
- public async doubleTap ( ) {
70
+ public async doubleTap ( offset : { x : number , y : number } = { x : 0 , y : 0 } ) {
71
71
if ( this . _args . isAndroid ) {
72
72
// hack double tap for android
73
- let action = new this . _wd . TouchAction ( this . _driver ) ;
74
73
const rect = await this . getRectangle ( ) ;
75
- action . press ( { x : rect . x , y : rect . y } ) . release ( ) . perform ( ) ;
76
- action . press ( { x : rect . x , y : rect . y } ) . release ( ) . perform ( ) ;
77
- await action . perform ( ) ;
74
+
75
+ if ( `${ this . _args . device . apiLevel } ` . startsWith ( "29" )
76
+ || `${ this . _args . device . apiLevel } ` . startsWith ( "9." ) ) {
77
+ const offsetPoint = { x : ( rect . x + offset . x ) , y : ( rect . y + offset . y ) } ;
78
+ await adbShellCommand ( this . _driver , "input" , [ "tap" , `${ offsetPoint . x } ${ offsetPoint . y } ` ] ) ;
79
+ await adbShellCommand ( this . _driver , "input" , [ "tap" , `${ offsetPoint . x } ${ offsetPoint . y } ` ] ) ;
80
+ } else {
81
+ let action = new this . _wd . TouchAction ( this . _driver ) ;
82
+ action . press ( { x : rect . x , y : rect . y } ) . release ( ) . perform ( ) ;
83
+ action . press ( { x : rect . x , y : rect . y } ) . release ( ) . perform ( ) ;
84
+ await action . perform ( ) ;
85
+ }
78
86
} else {
79
87
// this works only for ios, otherwise it throws error
80
88
return await this . _driver . execute ( 'mobile: doubleTap' , { element : this . _element . value } ) ;
@@ -518,18 +526,19 @@ export class UIElement {
518
526
/**
519
527
*@experimental
520
528
* Pan element with specific offset
521
- * @param points where the finger should move to.
529
+ * @param offsets where the finger should move to.
522
530
* @param initPointOffset element.getRectangle() is used as start point. In case some additional offset should be provided use this param.
523
531
*/
524
- public async pan ( points : { x : number , y : number } [ ] , initPointOffset : { x : number , y : number } = { x : 0 , y : 0 } ) {
532
+ public async pan ( offsets : { x : number , y : number } [ ] , initPointOffset : { x : number , y : number } = { x : 0 , y : 0 } ) {
525
533
logInfo ( "Start pan gesture!" ) ;
526
534
const rect = await this . getRectangle ( ) ;
527
535
const action = new this . _wd . TouchAction ( this . _driver ) ;
528
- await action . press ( { x : rect . x + initPointOffset . x , y : rect . y + initPointOffset . y } ) . wait ( 100 )
529
- if ( points . length > 1 ) {
530
- for ( let index = 1 ; index < points . length ; index ++ ) {
531
- const element = points [ index ] ;
532
- action . moveTo ( { x : element . x , y : element . y } ) ;
536
+ await action . press ( { x : rect . x + initPointOffset . x , y : rect . y + initPointOffset . y } ) ;
537
+ await this . doubleTap ( ) ;
538
+ if ( offsets . length > 1 ) {
539
+ for ( let index = 1 ; index < offsets . length ; index ++ ) {
540
+ const p = offsets [ index ] ;
541
+ action . moveTo ( { x : rect . x + p . x , y : rect . y + p . y } ) ;
533
542
}
534
543
}
535
544
0 commit comments