tapAndHold duration is calculated incorrectly

## Background

=====================

Per the documentation on Tap and Hold, the second parameter is a Number representing the duration in seconds to keep holding. The underlying Appium TouchAction takes a duration in milliseconds. There appears to be a miscalculation when converting to the underlying Appium TouchAction, with both Appium and Katalon multiplying by 1,000 to get milliseconds. This means that the resulting call to TouchAction for a 1 second duration is turned into a 1,000,000 ms duration, or 1,000 seconds (over 16 minutes!)

The workaround for this right now is to divide the duration parameter to tapAndHold() by 1,000 before calling (this works because it is a Number).

**## OS: **OSX High Sierra 10.13.6

## Katalon Studio Version: 5.6.0 build 1

## Appium Version: 1.8.0

## Katalon Studio logs:

[HTTP] --> POST /wd/hub/session/b76e9a67-57c1-419c-b1da-fb9a47523783/touch/perform[HTTP] {"actions":[{"action":"longPress","options":{"element":"53010000-0000-0000-8C84-010000000000","duration":1000000}},{"action":"release","options":{}}]}

## Steps to reproduce -

  • Create a new Test Case
  • Use findObject() to get an interactive TestObject, e.g. a button
  • Call:
MobileBuiltInKeywords.tapAndHold(myButton, 1, 0) 
  • where 1 is the duration in seconds and 0 is the timeout in seconds
  • Add some other interaction after the tapAndHold
  • Run the test case
  • Observe that the test seems to hang after tapping myButton
  • Observe that the console logs show the duration is 1,000,000:
[HTTP] --> POST /wd/hub/session/b76e9a67-57c1-419c-b1da-fb9a47523783/touch/perform[HTTP] {"actions":[{"action":"longPress","options":{"element":"53010000-0000-0000-8C84-010000000000","duration":1000000}},{"action":"release","options":{}}]}

**## Expected Behavior -
**
The duration should be 1,000ms, which is 1 second.

## Actual Behavior -

The duration of 1 second actually holds for over 16 minutes!

2 Likes

This issue can be still be reproduced in Katalon Studio 6.2.1 Build 2.
Any update on if this will be fixed in the near future?

1 Like

Hi @streamgroup.testing,

As a workaround, I’ve been able to just divide the timeout parameter by 1000:

MobileBuiltInKeywords.tapAndHold(myButton, 1/1000, 0) 

– Chris

1 Like

Hi @Chris_Trevarthen, @streamgroup.testing

We will add this issue to backlog of KS v6.4.0.

Many thanks for this found @Chris_Trevarthen

@Chris_Trevarthen I’d already implemented your workaround, which indeed did the trick.
So thanks for that valuable tip.

1 Like

Thank you @Chris_Trevarthen. The fix has been implemented in KS 7.0 RC2.

1 Like