{"id":1031,"date":"2012-01-25T02:23:17","date_gmt":"2012-01-24T20:53:17","guid":{"rendered":"http:\/\/www.automationrepository.com\/?p=1031"},"modified":"2012-01-25T02:24:19","modified_gmt":"2012-01-24T20:54:19","slug":"different-ways-to-maximize-and-minimize-a-browser-using-qtp","status":"publish","type":"post","link":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/","title":{"rendered":"Different ways to Maximize and Minimize a Browser using QTP"},"content":{"rendered":"<div style=\"text-align: justify; font-family: Verdana;\">\n<p>Many a times you would have noticed that if you open a new browser window using QTP (or otherwise also) the browser is not in maximized mode by default. And in certain cases, you would really need the browser to be in maximized state (like for better readability). In this article, <!--more-->we&#8217;ll see how you can maximize and minimize your browser windows using QTP. Unfortunately, there is no direct method to achieve this task as the <strong>Browser object does not support Maximize\/Minimize actions.<\/strong> The only way to go about this task is to follow some workaround to achieve the desired results. This article is about these indirect methods.<br \/>\n<span><br \/>\n<\/span><br \/>\n<strong><span style=\"text-decoration: underline;\">Using Browser Handle with Window Object.<\/span><\/strong> Even though Browser object doesn&#8217;t provide any methods to maximize\/minimize browsers, <strong>you have the maximize\/minimize functions available with standard Windows object<\/strong>. Hence, you can retrieve the Handle from your Browser object &amp; use the same Handle with the Window object to maximize\/minimize your browser. Let&#8217;s see few examples for the same &#8211;<br \/>\n<em><\/em><br \/>\n<strong>Sample Script 1: Maximizing a Browser<\/strong> This example maximizes a browser if it is already not maximized and is maximizable.<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nDim hwnd, isMaximized, isMaximizable\r\n\r\n'Find the handle for the Browser window\r\nhwnd = Browser(&quot;CreationTime:=0&quot;).Object.HWND\r\n\r\n'Check if the Browser is already maximized or not\r\nIf Window(&quot;hwnd:=&quot; &amp; hwnd).GetROProperty(&quot;maximized&quot;) = True Then\r\n  isMaximized = True\r\nElse\r\n  isMaximized = False\r\nEnd If\r\n\r\n'Check if the Browser is maximizable or not\r\nIf Window(&quot;hwnd:=&quot; &amp; hwnd).GetROProperty(&quot;maximizable&quot;) = True Then\r\n  isMaximizable = True\r\nElse\r\n  isMaximizable = False\r\nEnd If\r\n\r\n'Maximize the browser window if it is not already maximized and is maximizable\r\nIf isMaximized = False and isMaximizable = True Then\r\n  Window(&quot;hwnd:=&quot; &amp; hwnd).Maximize\r\nEnd If\r\n<\/pre>\n<p><span style=\"color: #0000ff;\"><em>Please note that this example fetches the value of hwnd using<br \/>\n<strong>hwnd = Browser(&#8220;CreationTime:=0&#8221;).Object.HWND<\/strong><br \/>\nrather than using<br \/>\n<strong>hwnd = Browser(&#8220;CreationTime:=0&#8221;).GetROProperty(&#8220;hwnd&#8221;)<\/strong>.<br \/>\nThis is because you would find 2 hwnd values for the browser using Object Spy &#8211; One available in Identification Properties &amp; one in Native Properties, and both the hwnd properties would have different values. And we should be using the Native HWND Property. Refer the below image for hwnd values.<\/em><\/span><\/p>\n<div style=\"width: 331px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" title=\"Hwnd values from Native &amp; Identification Properties\" src=\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/hwnd.PNG\" alt=\"Hwnd values from Native &amp; Identification Properties\" width=\"321\" height=\"495\" \/><p class=\"wp-caption-text\">Hwnd values from Native &amp; Identification Properties<\/p><\/div>\n<p><em> <\/em><br \/>\n<strong>Sample Script 2: Minimizing a Browser<\/strong> This example minimizes a browser if it already not minimized and is minimizable.<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nDim hwnd, isMinimized, isMinimizable\r\n\r\n'Find the handle for the Browser window\r\nhwnd = Browser(&quot;CreationTime:=0&quot;).Object.HWND\r\n\r\n'Check if the Browser is already minimized or not\r\nIf Window(&quot;hwnd:=&quot; &amp; hwnd).GetROProperty(&quot;minimized&quot;) = True Then\r\n  isMinimized = True\r\nElse\r\n  isMinimized = False\r\nEnd If\r\n\r\n'Check if the Browser is minimizable or not\r\nIf Window(&quot;hwnd:=&quot; &amp; hwnd).GetROProperty(&quot;minimizable&quot;) = True Then\r\n  isMinimizable = True\r\nElse\r\n  isMinimizable = False\r\nEnd If\r\n\r\n'Minimize the browser window if it is not already minimized and is minimizable\r\nIf isMinimized = False and isMinimizable = True Then\r\n  Window(&quot;hwnd:=&quot; &amp; hwnd).Minimize\r\nEnd If\r\n<\/pre>\n<p><em> <\/em><br \/>\n<strong>Sample Script 3: Use HWND with Descriptive Programming for Maximizing\/Minimizing a Browser <\/strong>In this example, the browser properties are not stored in Object Repository, but are taken using Descriptive Programming.<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nDim oIE\r\n\r\n'Create an object of Internet Explorer type\r\nSet oIE= CreateObject(&quot;InternetExplorer.Application&quot;)\r\noIE.visible = True\r\noIE.navigate &quot;http:\/\/www.automationrepository.com&quot;\r\n\r\n'Maximize the Browser Window\r\nWindow(&quot;hwnd:=&quot; &amp; oIE.HWND).Maximize\r\n\r\n'Minimize the Browser Window\r\nWait(2)\r\nWindow(&quot;hwnd:=&quot; &amp; oIE.HWND).Minimize\r\n<\/pre>\n<p><span><br \/>\n<\/span><br \/>\n<strong><span style=\"text-decoration: underline;\">Maximizing\/Minimizing a Browser while Opening<\/span><\/strong>. Here you can make sure that whenever you open a browser using SystemUtil.Run method, it is always opened in Maximized\/Minimized mode. Let&#8217;s see how this can be done.<br \/>\n<em> <\/em><br \/>\n<strong>Sample Script 4: Use of SystemUtil.Run<\/strong> In this example, the browser will be opened in maximized\/minimized mode.<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nDim mode_Maximized, mode_Minimized\r\nmode_Maximized = 3 'Open in maximized mode\r\nmode_Minimized = 2 'Open in minimized mode\r\n\r\n'Open browser in maximized and minimized mode\r\nSystemUtil.Run &quot;iexplore.exe&quot;, &quot;http:\/\/www.automationrepository.com&quot;, , ,mode_Maximized\r\nSystemUtil.Run &quot;iexplore.exe&quot;, &quot;http:\/\/www.automationrepository.com&quot;, , ,mode_Minimized\r\n<\/pre>\n<p><em> <\/em><br \/>\n<strong>Sample Script 5: Use of WScript.Shell Run<\/strong>This example uses WScript.Shell to open a new browser in maximized\/minimized mode.<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nDim WshShell, mode_Maximized, mode_Minimized\r\nmode_Maximized = 3 'Open in maximized mode\r\nmode_Minimized = 2 'Open in minimized mode\r\n\r\nSet WshShell = CreateObject(&quot;WScript.Shell&quot;)\r\nWshShell.Run &quot;iexplore.exe http:\/\/www.automationrepository.com&quot;, mode_Maximized, False\r\nWshShell.Run &quot;iexplore.exe http:\/\/www.automationrepository.com&quot;, mode_Minimized, False\r\nSet WshShell = Nothing\r\n<\/pre>\n<p><em> <\/em><br \/>\nThis was all about this article where you saw various methods to minimize\/maximize a browser using QTP. Do you know of any other method that has not been mentioned here? Share your thoughts using the Comments section. Happy Reading.. :-&gt;<br \/>\n<em> <\/em><\/p>\n<\/div>\n<div style=\"font-family: Verdana,sans-serif; border: 1px solid #C8B560; padding: 3mm; background: #FFF8C6; text-align: center;\">\n<p>If you enjoyed this article, <strong>you can join our blog to get free email updates directly in your inbox.<\/strong><\/p>\n<form style=\"text-align: center;\" action=\"http:\/\/feedburner.google.com\/fb\/a\/mailverify\" method=\"post\" onsubmit=\"window.open('http:\/\/feedburner.google.com\/fb\/a\/mailverify?uri=automationrepository\/feeds', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true\" target=\"popupwindow\"><input style=\"width: 160px; height: 20px;\" onfocus=\"if (this.value == 'Enter Your Email Address') {this.value = '';}\" onblur=\"if (this.value == '') {this.value = 'Enter Your Email Address';}\" type=\"text\" value=\"Enter Your Email Address\" \/> <input type=\"hidden\" name=\"uri\" value=\"automationrepository\/feeds\" \/> <input type=\"hidden\" name=\"loc\" value=\"en_US\" \/> <input type=\"submit\" value=\"Join Us\" \/><\/p>\n<p style=\"text-align: justify;\">\n<\/form>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Many a times you would have noticed that if you open a new browser window using QTP (or otherwise also) the browser is not in maximized mode by default. And in certain cases, you would really need the browser to be in maximized state (like for better readability). In this article,<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,9],"tags":[61,62,63],"class_list":["post-1031","post","type-post","status-publish","format-standard","hentry","category-not-so-common-stuff","category-qtp-concepts","tag-browser","tag-maximize-browser","tag-minimize-browser"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Different ways to Maximize and Minimize a Browser using QTP - XX<\/title>\n<meta name=\"description\" content=\"See how to Maximize\/Minimize a browser using its hwnd property with Window object. Also see how to use SystemUtil.Run and WScript.Shell Run methods to always open a browser in maximized\/minimized mode.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anish Pillai\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/\",\"name\":\"Different ways to Maximize and Minimize a Browser using QTP - XX\",\"isPartOf\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/hwnd.PNG\",\"datePublished\":\"2012-01-24T20:53:17+00:00\",\"dateModified\":\"2012-01-24T20:54:19+00:00\",\"author\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20\"},\"description\":\"See how to Maximize\/Minimize a browser using its hwnd property with Window object. Also see how to use SystemUtil.Run and WScript.Shell Run methods to always open a browser in maximized\/minimized mode.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/#primaryimage\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/hwnd.PNG\",\"contentUrl\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/hwnd.PNG\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.automationrepository.com\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Different ways to Maximize and Minimize a Browser using QTP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#website\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/\",\"name\":\"XX\",\"description\":\"\\r\\nasas\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.automationrepository.com\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20\",\"name\":\"Anish Pillai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g\",\"caption\":\"Anish Pillai\"},\"description\":\"Find more about Anish Pillai on Google+\",\"sameAs\":[\"http:\/\/www.automationrepository.com\"],\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/author\/anish\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Different ways to Maximize and Minimize a Browser using QTP - XX","description":"See how to Maximize\/Minimize a browser using its hwnd property with Window object. Also see how to use SystemUtil.Run and WScript.Shell Run methods to always open a browser in maximized\/minimized mode.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/","twitter_misc":{"Written by":"Anish Pillai","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/","url":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/","name":"Different ways to Maximize and Minimize a Browser using QTP - XX","isPartOf":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/#primaryimage"},"image":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/hwnd.PNG","datePublished":"2012-01-24T20:53:17+00:00","dateModified":"2012-01-24T20:54:19+00:00","author":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20"},"description":"See how to Maximize\/Minimize a browser using its hwnd property with Window object. Also see how to use SystemUtil.Run and WScript.Shell Run methods to always open a browser in maximized\/minimized mode.","breadcrumb":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/#primaryimage","url":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/hwnd.PNG","contentUrl":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/hwnd.PNG"},{"@type":"BreadcrumbList","@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/different-ways-to-maximize-and-minimize-a-browser-using-qtp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.automationrepository.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Different ways to Maximize and Minimize a Browser using QTP"}]},{"@type":"WebSite","@id":"https:\/\/www.automationrepository.com\/wordpress\/#website","url":"https:\/\/www.automationrepository.com\/wordpress\/","name":"XX","description":"\r\nasas","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.automationrepository.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20","name":"Anish Pillai","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8aa984de2295c3c4078fa48f6ba5d91e7c849b1a27a11dca24c6f11dd673ba14?s=96&d=mm&r=g","caption":"Anish Pillai"},"description":"Find more about Anish Pillai on Google+","sameAs":["http:\/\/www.automationrepository.com"],"url":"https:\/\/www.automationrepository.com\/wordpress\/author\/anish\/"}]}},"_links":{"self":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/1031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1031"}],"version-history":[{"count":15,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/1031\/revisions"}],"predecessor-version":[{"id":1052,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/1031\/revisions\/1052"}],"wp:attachment":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}