@@ -452,26 +452,17 @@ export class UIElement {
452452 * Swipe element left/right
453453 * @param direction
454454 */
455- public async swipe ( direction : "up" | "down" | "left" | "right" ) {
456- logInfo ( `Swipe direction: ` , direction ) ;
455+ public async swipe ( direction : Direction ) {
456+ logInfo ( `Swipe direction: ` , Direction [ direction ] ) ;
457457 if ( this . _args . isIOS ) {
458458 await this . _driver
459459 . execute ( 'mobile: scroll' , {
460460 element : < any > this . _element . value ,
461- direction : direction
461+ direction : Direction [ direction ]
462462 } ) ;
463463 } else {
464464 try {
465- let scrollDirection = Direction . up ;
466- switch ( direction ) {
467- case "down" : scrollDirection = Direction . down ;
468- break ;
469- case "left" : scrollDirection = Direction . left ;
470- break ;
471- case "right" : scrollDirection = Direction . right ;
472- break ;
473- }
474- await this . scroll ( scrollDirection ) ;
465+ await this . scroll ( direction ) ;
475466 } catch ( error ) {
476467 console . log ( "" , error ) ;
477468 }
@@ -486,13 +477,16 @@ export class UIElement {
486477 * @param yOffset
487478 * @param xOffset - default value 0
488479 */
489- public async drag ( direction : Direction , yOffset : number , xOffset : number = 0 ) {
480+ public async drag ( direction : Direction , yOffset : number , xOffset : number = 0 , duration ?: number ) {
481+ direction = direction === Direction . up ? Direction . down : Direction . up ;
482+
490483 const location = await this . location ( ) ;
491484
492485 const x = location . x === 0 ? 10 : location . x ;
493486 const y = location . y === 0 ? 10 : location . y ;
494487
495488 const endPoint = calculateOffset ( direction , y , yOffset , x , xOffset , this . _args . isIOS ) ;
489+ duration = duration || endPoint . duration ;
496490
497491 if ( this . _args . isAndroid ) {
498492 let action = new this . _wd . TouchAction ( this . _driver ) ;
0 commit comments