Skip to content

Iptv Assist

Learn More from us

Menu
  • HOW TO
  • Firestick
  • Chromecast
  • PC Apps
  • Lg Smart TV
  • IPTV Services
  • Automation Testing
  • Smart TV
  • Software Testing Tools
  • Contact Us
Menu

Descriptive Programming in QTP and Database Connection in QTP – Tutorial #25

Posted on March 19, 2023

Best Iptv Service Provider 2023 With 40k+ Channels And 100k+ VOD . 24/7 Suppport . Paypal Supported

In this tutorial, you will learn what Descriptive Programming and Database connection in QTP i.e. how to connect to external data sources like databases and MS Excel sheets using QTP. 

Best Iptv Service Provider 2023 With 40k+ Channels And 150k+ VOD . Hurry Up

Descriptive programming is a mechanism for creating tests where you use “Programmatic description” of objects instead of recording them.

Recommended IPTV Service Providers

  1. IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
  2. IPTVRESALE – Rating 5/5 ( 200+ Reviews )
  3. IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
  4. IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
  5. IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
  6. IPTVTOPS – Rating 5/5 ( 43 Reviews )

 

=> Click Here For QTP Training Tutorials Series

Descriptive Programming Database Connection

A quick note about this QTP article series before we move to the details of this tutorial:

This is the last tutorial in our online QTP training series. I hope you all enjoyed these tutorials and started learning from them.

Give us your feedback:

feedback

I am looking forward to your feedback not just for this tutorial series but also about the overall site. Please click here to share your thoughts about this website.  It will hardly take a couple of minutes to complete. We value your feedback and suggestions. Let us know what we can do to improve your experience with SoftwareTestingHelp.com


What You Will Learn:

  • Descriptive Programming in QTP
    • Static Descriptive Programming
    • Dynamic Descriptive Programming
  • Connecting to Commonly Used External Data Sources from QTP
    • Database Connection in QTP
    • Connecting to MS Excel Sheets

Descriptive Programming in QTP

Descriptive Programming is a mechanism for creating tests where you use “Programmatic description” of objects instead of recording them.

Using this technique, QTP can be made to identify objects that are not in the repository.

There are 2 variations of Descriptive Programming:

  • Static Descriptive programming
  • Dynamic Descriptive programming

Static Descriptive Programming

A static method is when you try to access an object by using a set of properties and values directly in a VB statement.

Syntax: TestObject(“Property name1:=property value”,”property name 2:=property value”,….n)

This is how you use it:

 Browser(“creationtime:=0”).Page(“title:=Google”).WebButton(“name:=Google Search”) 

Dynamic Descriptive Programming

This works by creating a description object.  Look at the following example to create a webButton object.

Set Testdesc=description.create
Testdesc(“micClass”).value= “webButton”
  • micClass refers to the predefined classes in QTP. The values you can assign can be webbutton, weblist etc.
  • In QTP 10 micClass values are case sensitive but in QTP 11 onwards they are not. If you write webbutton in QTP 10, it will fail. You will have to write webButton. But the same webbutton will pass in QTP 11.

You can extract all the objects of a certain class on a page by using the following statement:

Set ObjectList=Browser(“creationtime:=0”).Page(“title:=*”).ChildObjects(Testdesc)
Msgbox ObjectList.count

The above set of statements will extract all the buttons on a page and store them in the ObjectList object.

The versatility of using descriptive programming is that these lines of code will work on any open page. You can open google.com in your browser and it will count how many buttons are on that page. It will work exactly the same way if you have it on amazon.com or any other site open.

This is because we have the name of the title of the page set to * which is a regular expression.

So you can see how we can write code that can be used in more than one occasion by not hard coding the property values and by creating the objects at runtime.

Let us take our example a little further. Say, I am trying to print the names of all the webbuttons on the page one after the other.

If there are 4 buttons on a page, you can access each one of them in the following way:

Msgbox ObjectList (0).GetRoProperty(“name”) –This will print the name of the first button.
Msgbox ObjectList (1).GetRoProperty(“name”)
Msgbox ObjectList (2).GetRoProperty(“name”)
Msgbox ObjectList (3).GetRoProperty(“name”)

Note that:

  • The index of the child objects starts from 0.
  • Since the object achieves its properties at runtime, we use the GetRoProperty method to retrieve the same.

We can change the above code to work for any number of Buttons on the page by using a ‘For loop’ and repeating the statements within the ‘For block’ until it reaches the end of the object count.

For i=0 to ObjectList.count -1 to Step 1
Msgbox ObjectList (i).GetRoProperty(“name”)
Next

In this case, using a ‘For loop’ is better because, you don’t need to know how many objects are in your description object.

A couple of points to note:

  • You will need the practice to master descriptive programming. No matter how many examples you look at and understand, you will need hands-on experience to really work with it.
  • As a tester, you are not expected to know how the objects are coded into your AUT and what values they are set to. So use ObjectSpy from time to time to choose the right properties to view the properties.
  • The test results will indicate that the test object was created dynamically during the run session using a programming description or ChildObject methods.

Connecting to Commonly Used External Data Sources from QTP

There will be many instances while you are preparing the tests that you will have to connect to an external DB or some other data sources. Once connected, you will also have to move data to and from these apps to QTP and vice versa.

Though it is beyond the scope of these articles to provide a complete guide for working with external interfaces, we will look into a few that are most commonly used.

Database Connection in QTP

To connect to a database, we typically use an ADO connection object. ADO is Microsoft’s ActiveX Data Objects.

Given below are the steps to be followed:

#1) Create a DSN. Please refer to the database checkpoint tutorial to see how this is done or create one from the control panel.
#2) Create a connection object:
Set conn=CreateObject(“ADODB.connection”)
#3) Create a recordset object. The recordset object holds the results of the query that we are going to run.
Set rs=CreateObject(“ADODB.RecordSet”)
#4) Open the connection object and run the query:
conn.Open “DSN=testDB2;UID=swatiseela;[email protected]”
rs.Open “Select * from abc”,conn
#5) All the query results can now be accessed using the “rs” object.
#6) For example, if you want to get the count of the rows returned, you can use
rs.getrows
#7) For example, the table has 2 rows and 3 columns(a,b,c) and you can access the values as follows:
Msgbox rs.fields(0).a
Msgbox rs.fiels(0).b
Msgbox rs.fields(0).c
#8) You can use a loop statement if there are too many values to be accessed.
#9) Some of the functions that record set object can use are: rs.move, rs.movenext, rs.getrows, rs.close, rs.open, etc.

Let us look at all the codes at one time:

Set conn=CreateObject(“ADODB.connection”)
Set rs=CreateObject(“ADODB.RecordSet”)
conn.Open “DSN=testDB2;UID=swatiseela;[email protected]”
rs.Open “Select * from abc”,conn
msgbox  rs.getrows
Msgbox rs.fields(0).a
Msgbox rs.fiels(0).b
Msgbox rs.fields(0).c
Msgbox rs.fields(1).a
Msgbox rs.fiels(1).b
Msgbox rs.fields(1).c
rs.close
conn.close

Connecting to MS Excel Sheets

We all know that when we open an excel application, the entire file is a workbook that has sheets with columns and rows where we put in the data.

The following are the code and comments to help you understand how it is done.

‘Create an excel application object
Set excelobj = CreateObject(“Excel.Application”)
‘Set it to visible, otherwise it will be visible in the task manager but you will not be able to view it but it continues to work in the background
excelobj.visible = true
‘Opens a workbook at the path speficified. If you need to open a new workbook, use excelobj.workbooks.Add
excelobj.workbooks.Open(“C:UsersSwatiDesktopQTPtest.xls”)
‘Sets the current sheet as i. the sheet number starts from 1
i=1
Set sheet1 = excelobj.activeworkbook.sheets(i)
‘write to a cell in sheet 1. The cell is row 8 column 4, D8.
excelobj.activeworkbook.sheets(1).cells(8,4) = “Test QTP Write to cell”
‘To get the data from sheet2 cell ID C6
testretrurnval = excelobj.activeworkbook.sheets(3).cells(6,3)
‘save changes
excelobj.activeworkbook.save
‘close the workbook
excelobj.activeworkbook.close
‘Close Excel application
excelobj.quit
‘Clear memory
Set excelobj = nothing

Apart from the above functions, we have the following ones that we can use depending on your needs.

  • excelobj.activeworkbook.sheets.add – To add a new sheet
  • excelobj.activeworkbook.sheets(i).delete – To delete a sheet with index i
  • excelobj.activeworkbook.sheeets(i).name = “Name of your choice” – To change the name of the sheet with the index i
  • x=excelobj.activeworkbook.sheets.count – To get the count of how many sheets are in a workbook
  • excelobj. activeworkbook.saves “CompletePathWithNewName.xls” – To save the workbook under a new name

This finishes not just this article but our QTP training series. In the next article, we will cover some more important QTP interview questions with answers. Please let us know your comments and questions.

=> Visit Here For The QTP Training Tutorials Series

Stay tuned for more useful articles and tutorials on software testing! If you are not subscribed to our free email newsletter, please do so now by clicking here.

Related

Best Iptv Service Provider 2023 With 40k+ Channels And 150k+ VOD . Hurry Up

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • IPTV List: Best iptv lista 2023
  • IPTV Premium: Best Premium IPTV Service Provider List And Benefits
  • Nikon IPTV Review: Over 10,000 Live Channels for $12/Month
  • Iptvwings. Com Review: +18000 Live IPTV Channels ,+70000 Movies, +40000 TV show For $15/1 month
  • IPTVUNO Review: More Than 16000 Live TV channels, 55,000 Movies & VOD For $15/Month

Recent Comments

  1. IPTV List: Play lista iptv 2022 - Iptv Assist on Best IPTV Player in 2023 for Watching Live TV
  2. Cola IPTV – Over 18,000 Live Channels for $12/Month - Iptv Assist on FileLinked – How to Install on Firestick/Fire TV and Android Devices
  3. Cola IPTV – Over 18,000 Live Channels for $12/Month - Iptv Assist on 50+ Best IPTV Service Providers for Streaming Live TV 2023
  4. XoomsTV IPTV – Over 11,000 Channels & VOD for Under $13/Month on Best VPN for IPTV in 2023 and How to Install on Firestick/Android
  5. Voodoo Streams IPTV Review – Over 12,000 Channels for $11/Month - Iptv Assist on Dynasty TV IPTV Review – Over 6,000 Channels for $10/Month

Archives

  • March 2023

Categories

  • Activate
  • Agile Testing
  • Alternatives
  • Android
  • APK
  • Apple TV
  • Automation Testing
  • Basics of Software Testing
  • Best Apps
  • Breakfast Hours
  • Bug Defect tracking
  • Career in Software Testing
  • Chromebook
  • Chromecast
  • Cross Platform
  • Database Testing
  • Delete Account
  • Discord
  • Error Code
  • Firestick
  • Gaming
  • General
  • Google TV
  • Hisense Smart TV
  • HOW TO
  • Interview Questions
  • iPhone
  • IPTV
  • IPTV Apps
  • Iptv Service SP
  • IPTV Services
  • JVC Smart TV
  • Kodi
  • Lg Smart TV
  • Manual Testing
  • MI TV
  • Mobile Testing
  • Mod APK
  • newestiptv.com
  • News
  • Nintendo Switch
  • Panasonic Smart TV
  • PC Apps
  • Performance Testing
  • Philips Smart TV
  • PS4
  • PS5
  • Python
  • QA Certifications
  • QA Leadership
  • QA Team Skills
  • Quality Assurance
  • Reddit
  • Reviews
  • Roku
  • Samsung Smart TV
  • Screenshot
  • Selenium Tutorials
  • Sharp Smart TV
  • Skyworth Smart TV
  • Smart TV
  • Soft Skills For Testers
  • Software Testing Templates
  • Software Testing Tools
  • Software Testing Training
  • Sony Smart TV
  • Sports
  • Streaming Apps
  • Streaming Devices
  • Tech News
  • Test Management Tools
  • Test Strategy
  • Testing Best Practices
  • Testing Concepts
  • Testing Methodologies
  • Testing News
  • Testing Skill Improvement
  • Testing Tips and Resources
  • Toshiba Smart TV
  • Tutorials
  • Twitch
  • Types of Testing
  • Uncategorized
  • Vizio Smart TV
  • VPN
  • Web Testing
  • What is
  • Xbox
©2023 Iptv Assist | Design: Newspaperly WordPress Theme