{"id":1026,"date":"2012-01-20T22:27:13","date_gmt":"2012-01-20T16:57:13","guid":{"rendered":"http:\/\/www.automationrepository.com\/?p=1026"},"modified":"2012-01-20T22:28:10","modified_gmt":"2012-01-20T16:58:10","slug":"how-to-work-with-multiple-tabs-in-a-single-browser-window","status":"publish","type":"post","link":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/","title":{"rendered":"How to work with multiple tabs in a single browser window"},"content":{"rendered":"<div style=\"text-align: justify; font-family: Verdana;\">\n<p>You would have observed that nowadays, the modern web browsers support tabbed browsing. Tabbed browsing is a feature using which you can load multiple web pages in different tabs within the same browser window. Using this feature, it becomes very easy &amp; convenient to switch between different tabs and view the web pages. <!--more-->In this article, we would see how to work with a tabbed browser in Internet Explorer using QTP.<\/p>\n<p><strong>Support for omnipresent tabbed browsing was introduced in QTP with version 9.5<\/strong>. QTP treats each tab in the browser as a separate browser window. For example, 2 tabs in a single browser window will be treated as 2 separate browser windows, each having their distinct set of properties (including browser CreationTime). So, you don&#8217;t need to do anything extra than the usual stuff to work with multiple tabs. The code for handling multiple browsers would work perfectly fine for multiple tabs within sigle browser window. QTP also provides few built-in methods to work with multi-tabs. Let&#8217;s see some examples of working with multiple tabs in QTP.<br \/>\n<span><br \/>\n<\/span><br \/>\n<strong>Sample Script 1: Opening different web paged in multiple tabs. <\/strong>This example uses QTP&#8217;s in-built methods to load multiple web pages in different tabs within a single browser window.<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n'Open a new Browser\r\nSystemUtil.Run &quot;iexplore.exe&quot;, &quot;http:\/\/www.google.com&quot;\r\n'Browser Sync\r\nBrowser(&quot;CreationTime:=0&quot;).Sync\r\n\r\n'Find total number of tabs in the browser window\r\niTabs = Browser(&quot;CreationTime:=0&quot;).GetROProperty(&quot;number of tabs&quot;)\r\nmsgbox iTabs 'Displays the value 1\r\n\r\n'Open a new tab within the same browser\r\nBrowser(&quot;CreationTime:=0&quot;).OpenNewTab()\r\n'Sync for new tab\r\nBrowser(&quot;CreationTime:=1&quot;).Sync\r\n\r\n'Load some web page in the new tab\r\nBrowser(&quot;CreationTime:=1&quot;).Navigate &quot;http:\/\/www.yahoo.com&quot;\r\n\r\n'Find total number of tabs in the browser window\r\niTabs = Browser(&quot;CreationTime:=0&quot;).GetROProperty(&quot;number of tabs&quot;)\r\nmsgbox iTabs 'Displays the value 2\r\n\r\n'Close all the tabs in the browser window\r\nBrowser(&quot;CreationTime:=0&quot;).CloseAllTabs()\r\n'OR -&gt; Browser(&quot;CreationTime:=1&quot;).CloseAllTabs()\r\n<\/pre>\n<p><em> <\/em><br \/>\nAnother important point to be noted here is that if you are working on multiple web pages, you should really not be bothered about whether the web pages are opened in multiple tabs or in multiple browsers. This is because the same code would work in both the situations. Let&#8217;s see an example for the same.<br \/>\n<em><\/em><br \/>\n<strong>Sample Script 2 <\/strong>This example searches for a string in both Google and Yahoo! web pages. <em>As a pre-requisite, open Google and Yahoo! in separate browsers and then run the code. After this, open Google and Yahoo! in multiple tabs within the same browser and then run the code. The code should run successfully in both the cases.<\/em><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n'Search something in Google\r\nBrowser(&quot;title:=.*Google.*&quot;).Page(&quot;title:=.*Google.*&quot;).WebEdit(&quot;name:=q&quot;).Set &quot;google&quot;\r\nBrowser(&quot;title:=.*Google.*&quot;).Page(&quot;title:=.*Google.*&quot;).WebButton(&quot;name:=btnG&quot;).Click\r\nBrowser(&quot;title:=.*Google.*&quot;).Page(&quot;title:=.*Google.*&quot;).Sync\r\n\r\n'Search something in Yahoo!\r\nBrowser(&quot;title:=.*Yahoo!.*&quot;).Page(&quot;title:=.*Yahoo!.*&quot;).WebEdit(&quot;name:=p&quot;,&quot;class:=input-query input-long med-large  &quot;).Set &quot;yahoo&quot;\r\nBrowser(&quot;title:=.*Yahoo!.*&quot;).Page(&quot;title:=.*Yahoo!.*&quot;).WebButton(&quot;name:=Search&quot;,&quot;class:=searchsubmit med-large y-fp-pg-grad&quot;).Click\r\nBrowser(&quot;title:=.*Yahoo!.*&quot;).Page(&quot;title:=.*Yahoo!.*&quot;).Sync\r\n\r\n'Close both the browsers\r\nBrowser(&quot;title:=.*Google.*&quot;).Close()\r\nBrowser(&quot;title:=.*Yahoo!.*&quot;).Close()\r\n<\/pre>\n<p><em> <\/em><br \/>\nHope you&#8217;ll find this information useful. Please do share your comments about this article.<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, you can join our blog to get free email updates directly in your inbox.<\/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>You would have observed that nowadays, the modern web browsers support tabbed browsing. Tabbed browsing is a feature using which you can load multiple web pages in different tabs within the same browser window. Using this feature, it becomes very easy &amp; convenient to switch between different tabs and view the web pages.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-1026","post","type-post","status-publish","format-standard","hentry","category-qtp-concepts"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to work with multiple tabs in a single browser window - XX<\/title>\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\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/\" \/>\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=\"3 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\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/\",\"name\":\"How to work with multiple tabs in a single browser window - XX\",\"isPartOf\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#website\"},\"datePublished\":\"2012-01-20T16:57:13+00:00\",\"dateModified\":\"2012-01-20T16:58:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.automationrepository.com\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to work with multiple tabs in a single browser window\"}]},{\"@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":"How to work with multiple tabs in a single browser window - XX","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\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/","twitter_misc":{"Written by":"Anish Pillai","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/","url":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/","name":"How to work with multiple tabs in a single browser window - XX","isPartOf":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#website"},"datePublished":"2012-01-20T16:57:13+00:00","dateModified":"2012-01-20T16:58:10+00:00","author":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20"},"breadcrumb":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/01\/how-to-work-with-multiple-tabs-in-a-single-browser-window\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.automationrepository.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"How to work with multiple tabs in a single browser window"}]},{"@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\/1026","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=1026"}],"version-history":[{"count":9,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/1026\/revisions"}],"predecessor-version":[{"id":1037,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/1026\/revisions\/1037"}],"wp:attachment":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}