Zum Inhalt

Coordinate Recording Mode

The Action Spot and its Different Settings

You might have already wondered. Ranorex does object-based recording, so a click action, for example, is always performed on a specific UI element, no matter how it looks or what screen coordinates it has. However, if you look closely on the action spot of a click action, you can still see that behind the word „Relative“ a strange value like 51;13 is hidden. So does this mean that Ranorex still records coordiante-based? And can I change this behavior? And what side-effects could this have? This small article should answer all those questions.

Coordinate Recording Mode

The setting that defines this behavior is the Coordinate Recording Mode that can be found in Settings -> Recorder Defaults. This setting has three possible values: Pixel, None, and Proportional. This setting defines how the exact action spot within a UI element is determined.
The default is Pixel. This settings records the exact location of a click within the UI element. For example, if you click on a button in recording mode near its top left corner, you will get small coordiante values like 5;8, since the top left corner always has the coordinates 0;0. These coordinates use integer values and will also be used for playback.
The setting None behaves differently: Here, it doesn’t matter where on the element you click in recording mode, Ranorex will use the action spot Center and in playback will always click on the middle part of the button.
The setting Proportional uses coordinates in the form of .5;.6, thus using floating point numbers instead of integers. This means that if you click on a pixel in recording mode that is 30% of the button size from the top, then in playback Ranorex will also click a pixel that is 30% from the top in playback mode.

Advantages and disadvantages

All three of these settings each have a set of disadvantages and advantages. In fact, None might seem to be the best setting, but Pixel is the default value in Ranorex. Did the people at Ranorex not know better, or is there a better reason why to have Pixel as the default?

Pixel

This setting is the default in Ranorex. It recognizes the exact (=pixel-perfect) action spot in the UI element in recording mode and also uses these coordinates for playback. This has one huge advantage: When running the test, Ranorex does exactly the same thing that you were doing when you recorded the test. At least as long as you stay on your same screen with the same screen resolution and the same screen scaling, that is.

In modern applications, especially web applications, responsive design has become increasingly more important, and a button or a text field might change its size drastically, depending on the size of the application window, the screen, the device orientation, etc.

For example, on the Amazon homepage, you might want to click into the search field, somewhere in the middle:

If we put our browser from maximized mode into a much smaller window size and try to run the test, this click suddenly doesn’t work anymore, because the coordinates that I have recorded (958;17 in my case) are suddenly outside of this element, since this text box has shrunk in size. This warning looks like this:

Suddenly, Pixel looks like a far from optimal default setting. Especially in modern, web-based applications that use responsive design, this setting is far from ideal. So why is it that it still is the default setting in Ranorex?

Consider this element in your application:

Unfortunately, Ranorex is recognizing this whole thing as just one element – the checkbox isn’t recognized separately from the text label. Especially in (older) desktop technologies, this is very common. You also often see the small triangles or plus-symbols that should expand a section of a list or tree – those are also often not recognized as separate buttons. However, they only work if you click exactly this element, not the text near it. This makes it necessary that a click is performed on the exact same spot within the control as it was recorded. Would the click just be performed on the Center location of that element, the checkbox in this example wouldn’t get ticked.

None

This setting works very differently, and it changes the behavior of the test run drastically compared to the recording. Every action spot is set to Center. This might sound as if it makes sense in many cases, especially when you have responsive design, but it has a few serious drawbacks. For example, consider you want to click on this head line on a web page:

When recording, you would click this text, and it would work. However, in the test run, the action spot would be Center, and therefore the click spot would not actually be on the text itself:

This means, that the click in this case would not work at all. Only the background would get clicked, not the link itself.

Although the value None might seem like a good setting on the first glance, you can run into these issues frequently. So, is there a better way to do it, if both Pixel and None have some big drawbacks?

Proportional

This setting tries to, similarly to Pixel, retain the action spot exactly where it was while recording, but in relation to the size of the element. This means that a click on a spot that is 30% from the left edge and 60% from the top edge will also be done 30% from the left and 60% from the top in the test run, no matter how big or small the element now is. This mitigates the problem that the Pixel setting had: if a button shrinks, the action spot is still inside of the button.

And some issues that None has are also solved, but still, Proportional suffers from similar issues. For example, a click here…

…would translate to a click here in the test run, if the screen size becomes a bit smaller:

Thus, the setting Proportional suffers from very similar issues to None.
This setting is represented by floating point numbers in Ranorex (where the 0 is often completely left out). For example the Center location could also be written as .5;.5 in proportional notation.

The Best Setting

So the question is: What is the best setting for me?

The answer is pretty unsatisfying: It depends on your application. Pixel is the default, because we think that if you record a test and then run it afterwards without changing anything in between, it should run. None does not have this property, and while None looks logical up to a certain degree, Proportional seems to do very unlogical things if you don’t know how the action spot is calculated. This is why we have decided to stick with Pixel as the default. This is often best for pure desktop applications, and also works fine if you don’t change the screen resolution. None and Proportional both have their uses in applications with responsive design (mostly in the web and on mobile devices), however, they can have strange side-effects. In all three cases, depending on your actual UI element, it might be necessary to change the action spot manually if it doesn’t do what you want. There is no one bullet serves them all type of setting. All of them have advantages and disadvantages. If you know what properties those settings have, you can easily pick the one that suits your project best.


Published inRanorex

Schreibe den ersten Kommentar

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

*