Let's say I record a test with the browser set to 100% zoom. I record the step "Click on THIS button."
Now I'll run my test with the same browser, but set to 75% zoom. The button to be tested is now in a different place on the screen. My test actually selects a DIFFERENT button - and then fails.
Is there a way to get the test to select a particular button no matter where it is on the screen? I don't think that my test should fail simply because I changed the zoom on my browser.
15 Answers, 1 is accepted
Test Studio doesn't use coordinates to find elements and perform clicks by default. By default the SimulateRealClick property is set to false. This means that click will be executed directly on the DOM of the page. This eliminates any possibility that the Zoom level on a page will affect the click in any way. Check whether SimulateRealClick is set to true (screenshot 1). If it's not - set it and re-run the test.
If it is "true" and the test still fails then the Find Logic for the button might be incorrect and might be pointing to the wrong button. In this case click on the click step. A yellow arrow will highlight the element corresponding to it. Bring up the Find Logic for this element and make sure it's correct (screenshot 2).
Let me know how it goes
Kind regards,
I forgot to mention that the below info is only true for non-Silverlight applications. If your test a Silverlight app than your only choice is to have the browser set to 100% while testing.
Regards,

We're developing and testing a 100% Silverlight application, with Telerik controls. This is one reason we chose your Telerik testing tool - we're familiar with Telerik, and we assumed your testing tool would work well with your controls.
To require the browser to be at exactly the same zoom setting, and for the screen to be exactly the same size, and for every button to be in exactly the same place, every time a test is run is very restrictive when running the tests. This means that there will be a high overhead cost to maintaining these tests any time there is a change to the UI - even resizing a control would require us to change these tests.
Do you have any suggestions about how we can get these tests to act on Silverlight controls regardless of their position or size? If we can't do this, it would greatly restrict the usefulness of this tool.
Permit me to interject here and clear up some confusion.
The problem isn't quite that serious as you fear. The bad news is yes we do require the browser to be at 100% zoom level and the DPI setting to be at 96 DPI as discussed in this KB article.
The good news is that we are pretty much immune to different screen sizes, resolution and browser sizes and position. Here's the sequence of events for a simple button click:
1) The tool asks the browser for the rectangular coordinates of the target element (a button in this example)
2) The browser gives us a rectangle which is relative to the document window contained within the browser window (0, 0 is the upper left corner of the browsers document window) and assumes the browser is at 100% zoom level i.e. the browser doesn't give us coordinates based on the zoom level.
3) The tool converts those coordinates into screen coordinates, taking into account the location of the browsers outer window position on the screen, the width of the border, etc. and assumes the zoom level is at 100% and the DPI setting is at 96.
4) The tool calculates the absolute center of this rectangle
5) The tool creates and sends a Mouse Click event to the main Windows message handler with the calculated X, Y coordinates
6) Windows takes that message, determines which Window process covers that point and passes the event to that process, which should be the IE process
Actions on the other types of controls (dropdowns, textboxes, etc.) act pretty much the same way. Thus your test automation should work reliably no matter where the button gets moved to in the UI, no matter the size of the button, no matter where the browser appears on the screen. I hope this explanation allays your concerns about test execution and maintenance with regards to browser size, location, and even UI changes etc. If you have other questions about this, I'll be happy to answer them.
Kind regards,
Cody
the Telerik team

When I record a test on the original version, and then run that same test on the different version, it does not click on the moved buttons. It can verify some properties of those buttons, regardless of their position - but it can not click on the buttons in their new position.
This means a high cost of maintaining our tests when we change the UI layout.
Can you please suggest some better way of doing this? This automated testing system would not be very useful to us if we have to change multiple tests every time we change the position of a button on a screen.
That is very interesting behavior you have noticed! I cannot explain why it cannot find and click on the button that has been moved. To fully understand this I need to see it in action. First can you send me the recorded test? I'd like to start by studying the Find Expression being used to locate your button. One possibility that may be happening is that the hierarchical structure of the UI is changing after you moved the button such that it's not actually finding the right element to click on any longer.
Does your button have a unique Automation ID applied to it? When present we will record this ID and locate the correct button by locating the element, no matter where it is on the page, then perform actions on it.
Cody
the Telerik team
Register Today!

Thanks for your help. The developers here have confirmed that the Automation ID was not being applied consistently to all UI items. They've enabled this, and now the tests work: when I play back my test, it can find the button even if the button has been moved.
However, the test has a problem if the button is of a different SIZE at runtime than when the test was recorded. If a button has been changed to be less than half its original width, the test will click OUTSIDE the smaller button. It looks like it has "remembered" the size of the original button, and is clicking in the centre of that remembered size, rather than observing the actual size of the button at run time.
This is not a show-stopper. But, it would be nice to have confidence that, if we did change the size of a UI item, the test could still work with it.
Thanks again,
Simon
My developer has corrected me about one item pertaining to our default click recording. We actually do record the offset you clicked at and use that offset relative to the upper left corner of the control during playback You can actually change this behavior so it does always click in the absolute center of the button, no matter what size the button gets changed to. Reference the attached screen shot. There are two ways of accomplishing this:
1) Change "Use Offset" from true to false. This should cause it to simply find and click the absolute center
2) Change the offset parameters to "AbsoluteCenter" and X, Y of 0, 0.
Cody
the Telerik team
Register Today!

How do I get that "Properties" box? Where is it? How do I find it?
Simon
(By the way, this is a very inefficient way for me to learn how to use your software. Each question-and-answer cycle takes one full day. Where's the documentation that explains all these things, so I can learn quickly, without wasting your time?)
Are you using our standalone QA Edition? The properties pane is on the same screen as the test steps as shown in the attached screenshot.
If you're using our plug-in/Dev edition, it's a Visual Studio window (not a Test Studio specific window). You'll find it on the View Menu.
We are hard at work improving our new online User's Guide.
Cody
the Telerik team
Register Today!

I'm using the QA edition.
I've seen that Properties you describe, but it contains nothing about "UseOffset" or the offset parameters (refer attached screenshot), so I thought I was looking at the wrong thing.
Where do I find the "UseOffset" property?
Simon
When you select a Click step for a Silverlight based test the properties pane should show the UseOffset property and the offset coordinates properties.
Greetings,Cody
the Telerik team
Register Today!

Just click on the + symbol next to "Offset" to expand it. Then you'll see all the properties associated with Offset.
Regards,Cody
the Telerik team
Register Today!

How embarrassing that I missed that. Sorry to waste your time.
Simon