Page 1 of 1

Setting the browser zoom value and how to validate its value

Posted: Tue Mar 22, 2016 5:30 pm
by Eamonn
I wish to change the browser zoom from 100% to 200% and validate that my webpage under test has changed and is displayed in the different zoom value. Has Ranorex got a method to set the zoom value and a method to validate that the zoom value has changed and is set to the desired value?

Re: Setting the browser zoom value and how to validate its value

Posted: Wed Mar 23, 2016 11:00 am
by odklizec
Hi,

I'm sure there is no built-in way to achieve what you want. Each browser has its own way to set the page zoom so I'm afraid, you will have to prepare separate steps per each browser. As for validating actual zoom, I'm not sure how to achieve this? Easiest, but maybe not so reliable, way to validate the actual page zoom could be using Image validation?

Re: Setting the browser zoom value and how to validate its value

Posted: Thu Mar 24, 2016 3:43 pm
by Eamonn
Odkizec, thank you very much for your reply. Maybe I should look at this issue from a different angle. The OpenBrowser method (Namespaces>Ranorex>Host>OpenBrowser()) allows for the opening of a browser for a specific url in maximum mode, icognitoMode or clearCache.
Is there any Ranorex methods to open a browser with the zoom set to a value or how would I do so using C# code?

Re: Setting the browser zoom value and how to validate its value

Posted: Thu Mar 24, 2016 3:57 pm
by odklizec
Hi,

I'm afraid, there is no such functionality in Ranorex. At least I'm not aware of such functionality. I think you will have to write some custom code for this? I would suggest to search the Internet for a C#/JavaScript code, that could be called to change/detect the actual zoom level.

Check for example this link:
http://stackoverflow.com/questions/1713 ... n-browsers

Then search this forum for examples how to call JavaScripts from Ranorex. I'm sure this topic was discussed number of times in the past. Good luck! ;)

Re: Setting the browser zoom value and how to validate its value

Posted: Thu Mar 24, 2016 5:24 pm
by krstcs
The easiest way to do this would be to use the browser's shortcut keys (Ctrl--, Ctrl-=, Ctrl-0 for FF, etc.). Figure out how many to do to get to 200% for each browser and just do that, aiming the key strokes at the DOM object. You will probably want to do it in Usercode and then make a switch-case block that has each browser's specific method.

And, I would caution against injecting JavaScript during a test. This can invalidate results in many ways that you might not catch easily.



In my opinion (take it for what it costs you... :D ) there is no need to test this though as it is purely browser functionality (unless you are creating a browser, in which case you would probably be building it based on one of the available renderers anyway). What you actually should be testing is whether your (or your client's) website renders and functions correctly under each of the required browsers. Browser zoom has nothing to do with that, not even with rendering. Once the pages is rendered at 100%, the only thing that changes when you zoom is that the viewport magnifies the pixels (the browser always renders the page at 100% and THEN magnifies or shrinks it). The rendering is already done and the functionality doesn't change with zoom level. This isn't even something I would have manual testers spend time on.

Try not to make more work for yourself than you have to. :D

But, again, it's just my opinion...