Skip to main content

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.

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
  7. You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
    iOS App Development Company
    iOS App Development Company

    ReplyDelete
  8. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    <Fitness SMS
    Fitness Text
    Salon SMS
    Salon Text
    Investor Relation SMS
    Investor Relation Text
    Mobile Marketing Services
    mobile marketing companies
    Sms API

    ReplyDelete
  9. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

    ReplyDelete
  10. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.

    Best Java Training Institute Chennai

    ReplyDelete
  11. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    Best Hadoop Training Institute In chennai

    amazon-web-services-training-institute-in-chennai

    ReplyDelete
  12. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    biztalk-training-in-chennai

    ReplyDelete
  13. The information which you have provided is very good. It is very useful who is looking for selenium Online Training

    ReplyDelete

Post a Comment

Popular posts from this blog

QTP - Object Identification - Prerequesties

While starting a new project or proof of concept or after new QTP installation, we would face the issue in identifying objects as QTP built objects like WinList, WebEdit, etc.; instead everything will be identified as WinObject.

Here are some steps to ensure you did the environment setup RIGHT before start automating.
Did you enabled required Add-ins only while launchingDid you selected "Record >> Record and Run Settings" - This should be based on what type of application you are working with
Windows app - Windows >> Record and run test on any windows applications. Web app - Web >> Record and run test on any open browser.
Did you tried to launch UFT/QTP and then AUT.If its web, ensure browser zoom level set to 100%Try disabling the protected mode in IE for web.Launch UFT and AUT using RUN AS ADMINISTRATORAlso see the Object Identification Methods if you are interested.

Run JavaScript from QTP

Yeah, You can run your pure JavaScript from QTP using RunScript method. Lot of times, we are in need of firing events or simulating actions on web page which is not supported by QTP. At that time, you can use your direct DOM methods and directly execute your script on the web page from QTP like,
Dim MyPage, SearchBox Set MyPage = Browser("title:=Google").Page("title:=Google") Set SearchBox = MyPage.RunScript("document.getElementsByName('q')(0);") SearchBox.Value="testing"
'if objects available in frames, Set SearchBox = MyPage.RunScript("document.frames(4).document.getElementsByName('q')(0);")
'OR
Set objFrame = Browser("title:=Google").Page("title:=Google").Frame("title:=something")
objFrame.RunScript("document.getElementsByName('q')(0);") Also, you can execute by obtaining actual browser window object if you have IE app like, Dim IEApp Set IEApp = CreateObject("Internet…