How to do several taps to open hidden elements

In the mobile app i’m testing. there is hidden element to change environment. Not really available for user but made for programming and testing. Sometime we need to test in prod and sometime in Staging. So on the first page of the mobile application we tap about 10 time fast on the screen and element appears giving us the chance to change the environment. I have try repeat the taps 10 times but it is too slow the hidden element do not appears. Can someone help me please

Is this slow while switching environment or both environments do not work well?

The problem is not with the environment. The problem is When i use TAP it take 2 sec to do another TAP
Normally. when you hit the screen 10 times rapidly(very fast) a new section open. Because TAP is not fast enough the new section do not open
With Robot Framework i had found : (Tap With Number Of Taps ${DeerFace} 10 1). but it did not work with Katalon
i use a iPhone 13 pro Max version : 16.1.2

Please show us how the locator of the Test Object
"01-Landing Page/1-Landing Camera Page/TypImg_DeerFace"
is defined.
Show us the screenshot of the locator (XPath).


I guess, you generated that Test Object using Recorder tools. And the generated locator (XPath expression) is … poor.

A poorly-coded XPath could slow down any actions (tap etc).

A reading about XPath “XPaths Best Practices - TestProject” suggest the following 3 points.

  1. Use exact or relative XPaths as much as possible to capture elements
  2. Do not use * to capture the element
  3. Use XPath axes to locate elements

If you disclose your XPath locator and the DOM tree of the page, we might be able to review it with these 3 respects in mind.

I suppose that a few changes in the XPath would change the speed of tapping action quite drastically.

Capture d’écran, le 2023-01-19 à 02.24.10
As a locator i had choose NAME

My discussion about “Xpath and speed” is out of the point. I was wrong.

I am not experienced at mobile testing. So I would like to pass this to somebody more experienced for mobile.

@vu.tran

I found that the element is accesible=false. I wonder if you can “tap” it even if it is accessbile=false.

i had use that locator when i was using Robot Framework and it worked well I have try several different locator and none work with Katalon

@dgauthier1 can you show us your code?

From the screenshot posted, looks like, apparently, you have 10 tap statements in your code.

This will cause each statement to be evaluated as a test ‘step’ which, looks like takes ~ 2 sec every time. It may have something to do also with the ‘Log viewer’ view, we know this causes uneeded delays.
You can try to turn it off, there is a topic with research on this matter opened by @kazurayam … i will try to find it.

LE: here it is, you can take a look and try the proposed tricks.

You can try also do it using a for loop, hoping it will be faster.
If still out of luck, I am affraid you have to stick with the Robot approach for now, and rise a feature request so the tap keyword to have an ‘nclick’ option.

From the API docs:
https://api-docs.katalon.com/com/kms/katalon/core/mobile/keyword/MobileBuiltInKeywords.html

looks like only tap and doubleTap keywords are implemented, which are useless for your case.
@vu.tran
an additional ntap keyword will be needed for such cases.

Thanks for your help gang, i guess i have to wait for Katalon to implement a new function to TAP.:
the nTAP. :slight_smile:

@vu.tran note that, this is a legit request.

I saw such implemented on various mobile apps, in development stage, so the tester can switch between the ‘stagging’ and ‘production’ version easily.
It is sort of a ‘secret keycode’ and very handy.

On the other side, can be usefull for ‘negative’ test approaches even for apps not having such ‘secret’ implemented.

You have been need notified!

@dgauthier1 I have noticed a delay in some of the KS built in mobile commands that might cause you to run into issues here. There should be a way to quickly do this with the build in commands but I have worked around this by getting the current appium session and using appium commands to tap on objects when the delay causes problems. With this workaround execution usually takes anywhere from 0.5-1 second for each command, it may not be fast enough but is usually faster. Here is an example that should work on iOS (Note that you will need to get the mobile driver after starting the application):

AppiumDriver<?> driver
driver = MobileDriverFactory.getDriver()
for(int i = 0; i < 10; i++) {
	driver.findElementByXPath("//*[@name = 'WelcomeBackground']").click()
	}

I doubt this will be a solution, but worth to try.
Basically is what i suggested with a ‘for loop’
The main issue is how katalon keywords works, looks like the ‘unlock’ feature needs repetead taps less then … i dunno, but less than seconds definetly (looks like is a matter of milliseconds)

why i doubt? all the time will evaluate the xpath or whatever locator strategy and attempt to ‘tap’
so … a certain delay cannot be avoided under the hood of keywords implementation
therefore, a keyword which locates the element once and after that fires the tap/click events is what such cases need.

Anyway, worth to try the selenium/appium approach proposed, but i bet will flaky …
Combined with killing the Log Viewer, it may work or not
just my two cents …

@bionel Yeah that is true. This is definitely a flaky workaround when I did a quick test with the selenium/appium approach it cut the execution time of tapping an object 10 times almost in half on my iOS device. And whether it will work or not is dependent on how quick the taps need to happen.

@dgauthier1 Another flaky solution but one that will probably work better than the other one I suggested is to use TouchAction to complete the taps. You can find the top and left locations of the object you are trying to find and then inside the for loop add actions and perform them. This allows you to skip actually finding the object and tap in the same location.

AppiumDriver<?> driver
driver = MobileDriverFactory.getDriver()

int x = Mobile.getElementLeftPosition(findTestObject(''), 5)
int y = Mobile.getElementTopPosition(findTestObject(''), 5)

TouchAction tap = new TouchAction(driver)

for(int i = 0; i < 10; i++) {
	tap.press(point(x,y))
	tap.release()
	tap.perform()
}

Hi,

Let me discuss with team to define whether we can build this request. Thank you all for suggestion!