{"id":1360,"date":"2012-03-17T20:26:37","date_gmt":"2012-03-17T14:56:37","guid":{"rendered":"http:\/\/www.automationrepository.com\/?p=1360"},"modified":"2013-09-01T23:05:37","modified_gmt":"2013-09-01T17:35:37","slug":"descriptive-programming-in-qtp-the-complete-guide-part1","status":"publish","type":"post","link":"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/","title":{"rendered":"Descriptive Programming in QTP &#8211; The Complete Guide : Part1"},"content":{"rendered":"<p>This article covers the basics of Descriptive Programming in QTP with the main aim to help you get familiarized with its basic syntax. The article uses an illustrative approach to help you understand the difference between Object Repository and Descriptive Programming code. <!--more-->And also to guide you through the process of creating descriptive programming code.<br \/>\n<span><br \/>\n<\/span><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" alt=\"Descriptive Programming in QTP\" src=\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/descriptive-programming-in-qtp-basic-syntax.png\" width=\"602\" height=\"147\" \/><br \/>\n<span><br \/>\n<\/span><br \/>\nBefore you start looking into the details, the primary question that you have to answer is this &#8211; &#8220;What is Descriptive Programming in QTP?&#8221; In simple words, <strong>Descriptive Programming is the type of programming where you DON&#8217;T use Object Repository while writing your test scripts.<\/strong><br \/>\n<span><br \/>\n<\/span><br \/>\nSimple enough? Well, after reading the above definition of descriptive programming, there might be many queries that may come to your mind &#8211;<\/p>\n<p><strong>&gt;&gt;<\/strong> Why do we eliminate object repository while scripting?<\/p>\n<p><strong>&gt;&gt;<\/strong> How to skip Object Repository and write scripts using Descriptive Programming?<\/p>\n<p><strong>&gt;&gt;<\/strong> What are the advantages\/disadvantages of Descriptive Programming over Object Repository?<\/p>\n<p><strong>&gt;&gt;<\/strong> Are there any situations where using Descriptive Programming would be advantageous over Object Repository?<br \/>\n<span><br \/>\n<\/span><br \/>\nBefore we begin answering the above queries, let us first see the structure of a line of code in QTP and understand how Object Repository fits in there. Once you are clear with this concept, understanding and using Descriptive Programming in your script becomes very very easy.<br \/>\n<span><br \/>\n<\/span><\/p>\n<h3>Structure of a QTP Statement and Object Repository<\/h3>\n<p>Let&#8217;s take an example to understand the below concept. Consider that you have to write the code which enters some text in Google Search. The code that you would write with the use of object repository would look something like this &#8211;<br \/>\n<em> <\/em><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nBrowser(&quot;brGoogle&quot;).Page(&quot;pgGoogle&quot;).WebEdit(&quot;q&quot;).Set &quot;google&quot;\r\n<\/pre>\n<p><em> <\/em><br \/>\nYou can divide the above line of code into 2 parts &#8211;<\/p>\n<p><strong>a) <\/strong>The object hierarchy part (or simply the object part) denoted by Browser(&#8220;brGoogle&#8221;) .Page(&#8220;pgGoogle&#8221;) .WebEdit(&#8220;q&#8221;)<\/p>\n<p><strong>b) <\/strong>and the action part specified by Set &#8220;google&#8221;<\/p>\n<p>So we can safely say that a QTP statement usually consists of 2 things &#8211; the object and the action.<br \/>\n<span><br \/>\n<\/span><br \/>\nAlso, the object is something which is stored in the Object Repository. So when you run the above code, QTP will try to find out the object properties from Object Repository and then perform the action on that object.<br \/>\n<span><br \/>\n<\/span><br \/>\n<strong>So when you say that you want to write your script a such a manner that it doesn&#8217;t use object repository, it actually means that you have to write the <span style=\"text-decoration: underline;\">object part<\/span> of your statement in a different way such that it doesn&#8217;t go to Object Repository to find the object properties.<\/strong> Check the below diagram that illustrates the this concept.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"Descriptive Programming in QTP\" alt=\"Descriptive Programming in QTP\" src=\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/descriptive-programming-in-qtp-1.png\" width=\"599\" height=\"637\" \/><\/p>\n<p><span><br \/>\n<\/span><br \/>\nNow you know that in descriptive programming, you only need to modify the Object part of your code. But how do you do that? Well, the answer to this query also lies within the Object Repository.<br \/>\n<span><br \/>\n<\/span><br \/>\nWhy does QTP refer to Object Repository while running a statement? QTP does it so that it can find the properties associated with the object from the Object Repository. So what if you directly provide the properties of the object in the code itself? If you do this, QTP finds the object properties in the code itself and therefore, there is no need for it to go and refer the Object Repository. And this is the way, you write your Descriptive Programming Code.. :&#8211;)<br \/>\n<span><br \/>\n<\/span><\/p>\n<h3>Writing Descriptive Programming Code<\/h3>\n<p>The below code snippet shows the syntax and example of Descriptive Programming approach.<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n'Descriptive Programming Syntax\r\nControl(&quot;PropName1:=PropValue1&quot;,&quot;PropName2:=PropValue2&quot;, and so on..)\r\n\r\n'Let's assume we have a Search button with properties as: name=Search &amp; type=Submit.\r\n'This can be written as follows using descriptive programming approach\r\nWebButton(&quot;name:=Search&quot;,&quot;type:=Submit&quot;)\r\n<\/pre>\n<p><em> <\/em><br \/>\nThe below image depicts this concept more clearly.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"Descriptive Programming in QTP\" alt=\"Descriptive Programming in QTP\" src=\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/descriptive-programming-in-qtp-2.png\" width=\"644\" height=\"423\" \/><\/p>\n<p><span><br \/>\n<\/span><br \/>\nUsing this concept, you can now re-write each of the objects as follows &#8211;<\/p>\n<p><strong>Browser(&#8220;brGoogle&#8221;)<\/strong> becomes <strong>Browser(&#8220;title:=Google&#8221;)<\/strong><\/p>\n<p><strong>Page(&#8220;pgGoogle&#8221;)<\/strong> becomes <strong>Page(&#8220;title:=Google&#8221;)<\/strong><\/p>\n<p><strong>WebEdit(&#8220;q&#8221;)<\/strong> becomes <strong>WebEdit(&#8220;name:=q&#8221;,&#8221;type:=text&#8221;)<\/strong><\/p>\n<p><span><br \/>\n<\/span><br \/>\nCombining the above 3 objects, the complete statement can be written as &#8211;<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nBrowser(&quot;title:=Google&quot;).Page(&quot;title:=Google&quot;).WebEdit(&quot;name:=q&quot;,&quot;type:=text&quot;).Set &quot;google&quot;\r\n<\/pre>\n<p><span><br \/>\n<\/span><br \/>\n<strong>Descriptive Programming Example: <\/strong>As an example, let us see the descriptive programming code that searches for a string in google.com and then displays the total number of results found in a message box.<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n'Open Google.com\r\nSystemUtil.Run &quot;iexplore.exe&quot;, &quot;http:\/\/www.google.com&quot;\r\n\r\n'Set value in Google Search Box\r\nBrowser(&quot;title:=Google&quot;).Page(&quot;title:=Google&quot;).WebEdit(&quot;name:=q&quot;,&quot;type:=text&quot;).Set &quot;automation repository&quot;\r\n\r\n'Click on Search button\r\nBrowser(&quot;title:=Google&quot;).Page(&quot;title:=Google&quot;).WebButton(&quot;name:=Google Search&quot;,&quot;type:=submit&quot;).Click\r\n\r\n'Find out the number of search results displayed\r\nsResults = Browser(&quot;title:=.*Google Search&quot;).Page(&quot;title:=.*Google Search&quot;).WebElement(&quot;html id:=resultStats&quot;).GetROProperty(&quot;innertext&quot;)\r\n\r\n'Display the Result in a message box\r\nMsgbox sResults\r\n<\/pre>\n<p><span><br \/>\n<\/span><\/p>\n<h3>Over to you<\/h3>\n<p>This was all about the very basics of Descriptive Programming and its Syntax in QTP. In the next article, we will see some more important concepts that you can use with descriptive programming. Did you find this article useful? Let us know your thoughts about this using the comments section.<br \/>\n<span><br \/>\n<\/span><\/p>\n<p style=\"border: 1px solid #C38EC7; padding: 3mm; background: #EBDDE2;\"><strong>UPDATE: <\/strong>More on Descriptive Programming !!!\u00a0 Read how to use regular expressions, description object, ordinal identifiers and more in the next article on DP &#8211; <a href=\"http:\/\/www.automationrepository.com\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part-2\/\">Descriptive Programming in QTP &#8211; Part 2<\/a><\/p>\n<div style=\"font-family: Verdana,sans-serif; border: 1px solid #C8B560; padding: 3mm; background: #FFF8C6; text-align: center;\">\n<p><strong>If you enjoyed this article, you can join our blog to get new articles delivered directly in your inbox.<\/strong><\/p>\n<form style=\"text-align: center;\" action=\"http:\/\/feedburner.google.com\/fb\/a\/mailverify\" method=\"post\" target=\"popupwindow\" onsubmit=\"window.open('http:\/\/feedburner.google.com\/fb\/a\/mailverify?uri=automationrepository\/feeds', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true\"><input style=\"width: 160px; height: 20px;\" type=\"text\" value=\"Enter Your Email Address\" onfocus=\"if (this.value == 'Enter Your Email Address') {this.value = '';}\" onblur=\"if (this.value == '') {this.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>This article covers the basics of Descriptive Programming in QTP with the main aim to help you get familiarized with its basic syntax. The article uses an illustrative approach to help you understand the difference between Object Repository and Descriptive Programming code.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,37],"tags":[94],"class_list":["post-1360","post","type-post","status-publish","format-standard","hentry","category-qtp-concepts","category-qtp-tutorials-for-beginners","tag-descriptive-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Descriptive Programming in QTP with Syntax : Part 1<\/title>\n<meta name=\"description\" content=\"This articles describes what is Descriptive Programming in QTP and explains how you can write Descriptive Programming code on your own\" \/>\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\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/\" \/>\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=\"5 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\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/\",\"name\":\"Descriptive Programming in QTP with Syntax : Part 1\",\"isPartOf\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/descriptive-programming-in-qtp-basic-syntax.png\",\"datePublished\":\"2012-03-17T14:56:37+00:00\",\"dateModified\":\"2013-09-01T17:35:37+00:00\",\"author\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20\"},\"description\":\"This articles describes what is Descriptive Programming in QTP and explains how you can write Descriptive Programming code on your own\",\"breadcrumb\":{\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/#primaryimage\",\"url\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/descriptive-programming-in-qtp-basic-syntax.png\",\"contentUrl\":\"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/descriptive-programming-in-qtp-basic-syntax.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.automationrepository.com\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Descriptive Programming in QTP &#8211; The Complete Guide : Part1\"}]},{\"@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":"Descriptive Programming in QTP with Syntax : Part 1","description":"This articles describes what is Descriptive Programming in QTP and explains how you can write Descriptive Programming code on your own","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\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/","twitter_misc":{"Written by":"Anish Pillai","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/","url":"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/","name":"Descriptive Programming in QTP with Syntax : Part 1","isPartOf":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/#primaryimage"},"image":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/#primaryimage"},"thumbnailUrl":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/descriptive-programming-in-qtp-basic-syntax.png","datePublished":"2012-03-17T14:56:37+00:00","dateModified":"2013-09-01T17:35:37+00:00","author":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/#\/schema\/person\/7a35710e1ce89e5fb481be88fcd6cd20"},"description":"This articles describes what is Descriptive Programming in QTP and explains how you can write Descriptive Programming code on your own","breadcrumb":{"@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/#primaryimage","url":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/descriptive-programming-in-qtp-basic-syntax.png","contentUrl":"https:\/\/www.automationrepository.com\/wordpress\/wp-content\/uploads\/ar\/descriptive-programming-in-qtp-basic-syntax.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.automationrepository.com\/wordpress\/2012\/03\/descriptive-programming-in-qtp-the-complete-guide-part1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.automationrepository.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Descriptive Programming in QTP &#8211; The Complete Guide : Part1"}]},{"@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\/1360","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=1360"}],"version-history":[{"count":30,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/1360\/revisions"}],"predecessor-version":[{"id":2203,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/posts\/1360\/revisions\/2203"}],"wp:attachment":[{"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.automationrepository.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}