Recorded tests can not click on buttons.

Bug reports.
Posts: 1
Joined: Sun Dec 11, 2016 3:40 pm

Recorded tests can not click on buttons.

Post by sitheek » Sun Dec 11, 2016 5:03 pm

Hello !
I am trying to create some automated tests for my homework (I am studying software testing on Vistula University in Warsaw) - I am going to test MrBuggy3 - a software for students to learn testing.

I have created some tests and tried to play them - unfortunately Ranorex is not able to click on buttons, it points on a button and does not click it. When the pointer is on a button and you add a second click on that button to test - it works this way.

I am using Windows 2012 R2 Datacenter virtual machine in Aruba Cloud connected via RDP to old Samsung N130 netbook with Win Xp Professional SP3.

This is my zipped Ranorex Projects folder so you could recreate that issue : ... 1Radzd1em8

Many thanks !
Wojciech Siedlarz

User avatar
Ranorex Guru
Ranorex Guru
Posts: 6545
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Recorded tests can not click on buttons.

Post by odklizec » Tue Dec 13, 2016 2:23 pm

Hi Wojciech,

The GUI (its internal structure) of the tested app is quite messy and not very automation friendly. There are no unique IDs and most of the GUI elements are placed in the same container and just made invisible. Thanks to this, the recorded xpaths are unfortunately pretty slow to find and this is also probably why Ranorex fails to click them on the first try? Which means you will most probably have to manually optimize each recorded xpath (after each recording session) ;) Please find the optimized version of your solution attached to this post and check if it works better on target PC. Then compare the xpaths from optimized solution with xpaths from your original solution. This should give you an idea what I did and how you can make the xpaths more robust and faster to find. Hope this helps?
(170.57 KiB) Downloaded 39 times
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Recorded tests can not click on buttons.

Post by krstcs » Tue Dec 13, 2016 2:37 pm

First, welcome to Ranorex! It's a great tool for software test automation, and using it to learn is a great idea.

Second, the issue you are describing is usually caused by a timing problem. Ranorex tries to go as fast as possible. This is great for those times when the system-under-test (SUT) is faster than Ranorex, but when the SUT is slow, it can cause issues. A human will intuitively wait for the SUT to make the button avialable for use, but Ranorex won't unless you tell it to.

I would suggest adding a short (1 sec or so) Delay() action right before you attempt to click on the button and see if that helps. If it does, then this is definitely a timing issue and you should look for a way to handle that better, such as using a WaitFor->Exists action or a Validate action, right before the button click action.

A couple of things to consider:

1. Try to make your test modules as small as possible. This will aid in maintenance and reuse. I suggest making them atomic actions. For example, if you need to click a button, the module should just click that button (* and possible any pre-/post-validation that needs to happen for that button). If you need to enter text in a field (say a username), the module should just do the steps necessary to enter the text and validate that it's correct. In addition, you should name your modules according to what the do (i.e., "Click_OK" or "Enter_Username"). This will allow you (or anyone else) to know at a glance what the module is doing.

2. You can group modules together in a Module Group if they are used in the same order in multiple tests or locations. This will allow you to just drop the module group in the test cases instead of each individual test module.

3. In the test suite, the test cases are basically for-each loops that iterate over each row of data in the associated data connector. If there are no rows in the connector, the test case won't run. If there is no data connector, the test case will only run once.

4. When making recording modules, I've found that it is usually better to create them manually than to use record and play-back. However, I've been doing this for a while, so I've got Ranorex down pretty well. But, in the long run it is usually easier to create the module yourself than to have to clean up the recorded test module. My suggestion is to use the recording feature only long enough to get comfortable with how Ranorex works.

Hope that helps!

And good luck with university!
Shortcuts usually aren't...