Setting the browser zoom value and how to validate its value

Ask general questions here.
Eamonn
Posts: 59
Joined: Wed Jul 16, 2014 9:30 am
Location: Dundalk, Ireland.

Setting the browser zoom value and how to validate its value

Post by Eamonn » Tue Mar 22, 2016 5:30 pm

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?

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

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

Post by odklizec » Wed Mar 23, 2016 11:00 am

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?
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

Eamonn
Posts: 59
Joined: Wed Jul 16, 2014 9:30 am
Location: Dundalk, Ireland.

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

Post by Eamonn » Thu Mar 24, 2016 3:43 pm

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?

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

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

Post by odklizec » Thu Mar 24, 2016 3:57 pm

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! ;)
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

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

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

Post by krstcs » Thu Mar 24, 2016 5:24 pm

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...
Shortcuts usually aren't...