This is a migrated thread and some comments may be shown as answers.

Select button when browser screen size changes

15 Answers 150 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 18 Apr 2011, 03:16 AM
I don't know if I'm missing something, or making the wrong assumption, but I'm having trouble getting my recorded test to click on a button if the screen zooming of the browser changes.

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

Sort by
0
Stoich
Telerik team
answered on 18 Apr 2011, 02:24 PM
Hello Simon,
    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,
Stoich
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Stoich
Telerik team
answered on 18 Apr 2011, 03:45 PM
Hi Simon,
   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,
Stoich
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Simon
Top achievements
Rank 1
answered on 19 Apr 2011, 03:05 AM

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.

0
Cody
Telerik team
answered on 19 Apr 2011, 04:22 PM
Hi Simon,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Simon
Top achievements
Rank 1
answered on 29 Apr 2011, 08:12 AM
We were concerned about this, so we created a different version of the home page of our application, and moved the buttons to different positions on the screen.

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.


0
Cody
Telerik team
answered on 29 Apr 2011, 09:37 PM
Hello Simon,

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.

Greetings,
Cody
the Telerik team
Do you think you know all the new features coming out in Test Studio R1 2011? Think again - we have some surprises and will share them with you in the What's New in Test Studio R1 2011 Webinar on May 12th.
Register Today!
0
Simon
Top achievements
Rank 1
answered on 03 May 2011, 05:18 AM
Chris,

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
0
Cody
Telerik team
answered on 03 May 2011, 04:11 PM
Hello 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.

Regards,
Cody
the Telerik team
Do you think you know all the new features coming out in Test Studio R1 2011? Think again - we have some surprises and will share them with you in the What's New in Test Studio R1 2011 Webinar on May 12th.
Register Today!
0
Simon
Top achievements
Rank 1
answered on 04 May 2011, 07:14 AM
Thanks, Chris.

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?)
0
Cody
Telerik team
answered on 04 May 2011, 04:52 PM
Hello Simon,

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.

Regards,
Cody
the Telerik team
Do you think you know all the new features coming out in Test Studio R1 2011? Think again - we have some surprises and will share them with you in the What's New in Test Studio R1 2011 Webinar on May 12th.
Register Today!
0
Simon
Top achievements
Rank 1
answered on 05 May 2011, 02:25 AM

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


0
Cody
Telerik team
answered on 05 May 2011, 06:56 PM
Hi 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
Do you think you know all the new features coming out in Test Studio R1 2011? Think again - we have some surprises and will share them with you in the What's New in Test Studio R1 2011 Webinar on May 12th.
Register Today!
0
Simon
Top achievements
Rank 1
answered on 09 May 2011, 02:40 AM
I don't see it: refer attached screenshot.
0
Cody
Telerik team
answered on 09 May 2011, 03:55 PM
Hi Simon,

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
Do you think you know all the new features coming out in Test Studio R1 2011? Think again - we have some surprises and will share them with you in the What's New in Test Studio R1 2011 Webinar on May 12th.
Register Today!
0
Simon
Top achievements
Rank 1
answered on 10 May 2011, 12:43 AM
Thanks for that, Chris.

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

Simon
Tags
General Discussions
Asked by
Simon
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Simon
Top achievements
Rank 1
Cody
Telerik team
Share this question
or