@@ -67,14 +67,22 @@ export class UIElement {
6767 * @experimental
6868 * Double tap on element
6969 */
70- public async doubleTap ( ) {
70+ public async doubleTap ( offset : { x : number , y : number } = { x : 0 , y : 0 } ) {
7171 if ( this . _args . isAndroid ) {
7272 // hack double tap for android
73- let action = new this . _wd . TouchAction ( this . _driver ) ;
7473 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+ }
7886 } else {
7987 // this works only for ios, otherwise it throws error
8088 return await this . _driver . execute ( 'mobile: doubleTap' , { element : this . _element . value } ) ;
@@ -518,18 +526,19 @@ export class UIElement {
518526 /**
519527 *@experimental
520528 * Pan element with specific offset
521- * @param points where the finger should move to.
529+ * @param offsets where the finger should move to.
522530 * @param initPointOffset element.getRectangle() is used as start point. In case some additional offset should be provided use this param.
523531 */
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 } ) {
525533 logInfo ( "Start pan gesture!" ) ;
526534 const rect = await this . getRectangle ( ) ;
527535 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 } ) ;
533542 }
534543 }
535544
0 commit comments