My Blog List

Wednesday, January 2, 2013

Change IE Browser ZOOM settings

Lot of UI automation testers could have faced this problem as we could change the zoom settings while operating manually for our convenience and forgot to reset to 100%.
But our QTP and some other related tools would operate the browser perfectly if browser zoom is 100%. So wee need to change the zoom before start to run the scripts. Its better to have a code snippet in our framework to change this zoom setting right?
Here we go...

1. We can simply change the Registry values before Invoking IE
  1. Function ChangeRegistry
  2.  Dim objShell
  3.  Set objShell = CreateObject("WScript.Shell")
  4.  objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom\ZoomFactor""100000""REG_DWORD"
  5.  Set objShell = Nothing
  6. End Function
This option is very useful. But in real time, lot of customers could have restricted write access to windows registry. So we can try other options.

2. Use IE COM object and Change Settings
  1. Function ChangeIEZoom
  2.  Dim intZoomLevel, objIE
  3.  intZoomLevel = 100
  4.  Const OLECMDID_OPTICAL_ZOOM = 63
  5.  Const OLECMDEXECOPT_DONTPROMPTUSER = 2
  6.  Set objIE = CreateObject("InternetExplorer.Application")
  7.  objIE.Visible = True
  8.  objIE.Navigate "http://www.google.com"
  9.  While objIE.Busy = True
  10.   WScript.Sleep 100
  11.  Wend
  12.  objIE.ExecWB OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, CLng(intZoomLevel), vbNull
  13. End Function
Warnings:
1. Don't use Top, Left, Width and Height properties
objIE.Left = 0
objIE.Top = 0
objIE.Width = 1304
objIE.Height = 768

These things will not change zoom settings but sets the IE window size. You can use to maximize the IE window.
2. Don't use zoom property of page
document.body.style.zoom=1
This will not change the IE browser zoom setting but changes the currently displayed page size by keeping the same IE zoom.

8 comments:

  1. Bellevue Locksmith oh this is a very informative
    post! i actually enjoyed reading
    this - very well explained too. thanks, this is very useful!
    Great information..

    ReplyDelete
  2. Your information about automation is really interesting. Also I want to know the latest new techniques which are implemented in automation. Can you update it in your website.
    LoadRunner training in Chennai

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Greens Technology's the leading software Training & placement centre Chennai & ( Adyar)
    informatica training in chennai

    ReplyDelete
  5. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete
  6. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    Android App Development Company

    ReplyDelete