QTP DataTable - QTP video

This QTP video shows how to work with DataTable.
You will learn different QTP DataTable concepts:
  • How to create QTP DataTable parameter using QTP Data Driver
  • How to create QTP DataTable parameter manually
  • How to read/write values from/to QTP DataTable
  • QTP script and DataTable execution settings
  • Global and local (action) sheets of DataTable
  • QuickTest Professional data-driven tests
There is a sample screenshot from the present QTP video:


QTP DataTable - QTP video


Dear reader! Would you like to get new QTP videos?
Please, suggest new topics! What videos would you most interested in?

Also, I will be grateful for any shared information about QTP and others automated testing tools.

Feel free to cantact me.
My email is: Dmitry Motevich's email

--
Dmitry Motevich


Related articles:


Do you like this QTP Video tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? Video guide)




Do you like this QTP tutorial?
Feel free to use/copy/publish all my materials on your site/blog!


QTP DP (Descriptive Programming) - QTP video

QTP DP (Descriptive Programming) allows working without native QTP Object Repository. QTP Descriptive Programming provides test objects' properties and their values.
So, QTP uses Descriptive Programming statements to identify objects in AUT (application under test) during Run-time.

This QTP video shows and explains concepts of QTP Descriptive Programming:
  • What is QTP Descriptive Programming?
  • How to pass properties and their values directly to test object?
  • How to pass properties and their values using Description object?
  • How to select Descriptive Programming properties of a test object?
  • How t0 oconvert usual QTP script into QTP Descriptive Programming script?
  • How to debug QTP DP?
  • Different secrets of QTP Descriptive Programming
There is a sample screenshot from the present QTP video:
QTP DP (Descriptive Programming) screenshot

QTP DP (Descriptive Programming) - QTP video


Dear reader!
As usual, I need your help :)

Do you have ideas about new video tutorials? Could you suggest new topics? What videos would you most interested in?
Please remember - The content of this blog depends on your wishes and creative ideas!

So, feel free to cantact me.
My email is: Dmitry Motevich's email

--
Dmitry Motevich


Related articles:


Do you like this QTP Video tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? Video guide)




Do you know that you are free to use/copy/publish all my materials on your site/blog?


QTP Hackers - How to decrypt encrypted (SetSecure'd) password

I will explain you how to decode an encoded password in QTP.
Using QuickTest Professional and this approach, you can hack email accounts published on Internet. Are you interested? :) So, continue reading this QTP tutorial for details.

I've just recorded a simple script, which signs into Gmail. It:
  1. Fills 'Username' in
  2. Fills 'Password' in
  3. Clicks 'Sign in' button
Gmail screen
And the recorded QTP script is:
Browser("Gmail").Page("Gmail").WebEdit("Email").Set "someaccount"
Browser("Gmail").Page("Gmail").WebEdit("Passwd").SetSecure "493844a99bee0e3ab952f2e867fd08e3"
Browser("Gmail").Page("Gmail").WebButton("Sign in").Click

As you can see, QTP script is simple enough.
I've set "someaccount" to 'Username' editbox. But what about 'Password' editbox? What value have I filled in?


QTP encrypted the password using SetSecure method:
WebEdit("Passwd").SetSecure "493844a99bee0e3ab952f2e867fd08e3"
QTP Help:
The SetSecure method is recorded when a password or other secure text is entered.
The text is encrypted while recording and decrypted during the test run.


How to know the initial text?

There is one trick. Apply SetSecure method to non-secured edit box!
Instead of this QTP code:
Browser("Gmail").Page("Gmail").WebEdit("Email").Set "someaccount"
Browser("Gmail").Page("Gmail").WebEdit("Passwd").SetSecure "493844a99bee0e3ab952f2e867fd08e3"
I run this QTP script:
Browser("Gmail").Page("Gmail").WebEdit("Email").SetSecure "493844a99bee0e3ab952f2e867fd08e3"
And the result of this QTP script is:
Revealed PasswordYes, "mypwd" was encrypted to "493844a99bee0e3ab952f2e867fd08e3". So, "mypwd" is the password I filled!
So, this is an easy way to decrypt an encrypted password in QTP.


By the way, there are two ways how to decrypt a password in QuickTest Professional:
  1. Using Crypt.Encrypt
    str = "Some Text"
    encrStr = Crypt.Encrypt(str)

    'encrStr' will contain an encrypted text.

  2. Using Password Encoder from 'Start/Programs/QuickTest Professional/Tools'
    QTP Password Encoder
Summary:
  • I explained two ways how to crypt a text in QTP
  • I shown an approach how to decrypt an encrypted text


Well, I promised to show how to hack email addresses... I remember!

I searched several QTP sites and forums for "SetSecure" function and found that some QTP engineers published their code snippets with encrypted passwords (for example, entrance into email accounts) :)

Now you know how to "read" (=steal) passwords in plain text.

Why do I tell that?
Just to remind - be careful when you publish such private info on Internet.

--
Dmitry Motevich



Related articles:


Do you like this QTP tutorial? Would you like to receive them automatically in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? VIDEO guide)




Do you know that you are free to use/copy/publish all my materials on your site/blog?


QTP - How to get all Object Indentification Properties?

There are two ways how to get all properties of an object in QuickTest Professional:
  1. Manually
  2. Programmatically
Use QTP Object Spy to get manually object properties.
I've captured properties of ''Advanced Search" link from Google's page:
So, QTP Object Spy shows these values:
QTP Spy ObjectUsing QTP Object Spy you can get Run-time Object Properties and Test Object Properties.
It's possible to get these properties programatically:
  • The GetTOProperty and GetTOProperties methods enable you to retrieve a specific property value or all the properties and values that QuickTest uses to identify an object.
  • The GetROProperty returns the current value of the test object property from the object in the application.

GetTOProperty differs from the GetROProperty method:
  • GetTOProperty returns the value from the test object's description.
    Test Object Properties are stored in the QTP Object Repository.
  • GetROProperty returns the current property value of the object in the application during the test run.
    QTP reads Run-time Object Properties from actual objects during the runnins can be read and accessed during the run session.

That means that when you work with objects using QTP Descriptive Programming (DP), you will be able to access run-time object properties only (using GetROProperty function). Test object properties (using GetTOProperty function) will not be accessed, because QTP DP doesn't work Object Repository.

There is a problem with Run-time object properties.
In contrast to GetTOProperties (which returns the collection of all properties and values used to identify the test object), GetROProperties function does NOT exist!
Once again - GetROProperties function does NOT exist!


Well, how to get all Object Indentification Properties of an object?
Answer:
We can read them from Windows Registry.

The following registry key contains properties of a given test object:
HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\_Test_Object_\Properties

For example, I've opened:
HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Link\Properties and I've got properties of Link object:

Please note that you can find the same Link Identification Properties in QuickTest Professional Help:
Link Indentification Properties from QuickTest Professional Help
QTP Object Identification Properties can be used:
  • in the object repository description
  • in programmatic descriptions
  • in checkpoint and output value steps
  • and as argument values for the GetTOProperty and GetROProperty methods

So we have to read all Identification Properties from the registry.
This QTP code reads Link Identification Properties:
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

sKeyPath = "SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest\Test Objects\Link\Properties"
oReg.EnumValues HKEY_LOCAL_MACHINE, sKeyPath, arrNames


As a result, arrNames array contains all names of properties.
To prove my words I use this QTP script:
sNames = "Identfication Properties:" & vbNewLine

For
i = 0 to UBound(arrNames)
    sNames = sNames & arrNames(i) & vbNewLine
Next

MsgBox
sNames
The result is:
Compare these Link Identification Properties with properties from the registry. They are the same!

So, we can read names of properties.

Next step is to read their values. It can be archived using GetTOProperty or GetROProperty.
Also, I'm going to show how GetTOProperty and GetROProperty work for Test Object (located in QTP Object Repository) and Run-time Object (actual object, created during the run session).

  1. Properties of Test Object
    QTP script is:
    ' Link("Advanced Search") is an object from QTP Object Repository
    Set TestLink = Browser("Google").Page("Google").Link("Advanced Search")

    sNamesTO = "GetTOProperty for Test Object" & vbNewLine & "Identfication Properties: Values" & vbNewLine
    sNamesRO = "GetROProperty for Test Object" & vbNewLine & "Identfication Properties: Values" & vbNewLine

    For i = 0 to UBound(arrNames)
        sNamesTO = sNamesTO & arrNames(i) & ": " & TestLink.GetTOProperty(arrNames(i)) & vbNewLine
        sNamesRO = sNamesRO & arrNames(i) & ": " & TestLink.GetROProperty(arrNames(i)) & vbNewLine
    Next

    MsgBox sNamesTO
    MsgBox sNamesRO
    • Test Object Properties of Test Object
      Test Object Properties of Test Object and their values are:
      Test Object Properties for Test Object
    • Run-time Object Properties of Test Object
      Run-time Object Properties of Test Object and their values are:
      Run-time Object Properties for Test Object

  2. Properties of Run-time Object
    QTP script is:
    ' Link("text:=Advanced Search") is a dynamic run-time object
    Set TestLink = Browser("Google").Page("Google").Link("text:=Advanced Search")

    sNamesTO = "GetTOProperty for Run-time Object" & vbNewLine & "Identfication Properties: Values" & vbNewLine
    sNamesRO = "GetROProperty for Run-time Object" & vbNewLine & "Identfication Properties: Values" & vbNewLine

    For i = 0 to UBound(arrNames)
        sNamesTO = sNamesTO & arrNames(i) & ": " & TestLink.GetTOProperty(arrNames(i)) & vbNewLine
        sNamesRO = sNamesRO & arrNames(i) & ": " & TestLink.GetROProperty(arrNames(i)) & vbNewLine
    Next

    MsgBox sNamesTO
    MsgBox sNamesRO
    • Test Object Properties of Run-time Object
      Test Object Properties of Run-time Object and their values are:
      Test Object Properties and their values of Run-time ObjectWhy almost all properties are empty?

      As I said, GetTOProperty function gets values from Test Object, which is stored in QTP Object Repository. Since Run-time Object is a dynamic object, it's not stored in QTP Object Repository. That's why GetTOProperty function cannot read object's properties.

      Look at the above screenshot again. The only one property ('text') contains its value ('Advanced Search'). We used this property to create description for our link:
      Set TestLink = Browser("Google").Page("Google").Link("text:=Advanced Search")
      That's why this Run-time Object contains the only property.

    • Run-time Object Properties of Run-time Object
      Run-time Object Properties of Run-time Object and their values are:
      Run-time Object Properties of Run-time ObjectAs you can see, we got the same Run-time Object Properties both for Test Object and for Run-time Object. I can explain it.
      During the run session, QTP creates a Run-time copy of Test Object. That's why Run-time Object Properties were the same for Test Object and Run-time Object.

    Note: You can download final QTP script here.
--
Dmitry Motevich


Related articles:


How about automatic receiving such QTP tutorials?
Just subscribe to this blog RSS feed or by Email. (How to subscribe? VIDEO guide)




Do you like this QTP visual tutorial? Feel free to place it on your site or blog.


4 ways to get & count objects in QTP

Imagine simple and practical QTP tasks:
  • How to count all links on Web page?
  • How to get them and click each link?
  • How to get all WebEdits and check their values?

I'm going to show 4 approaches how to get lists of UI controls and process them (for example get their count).
As an example, I will work with links on Google Labs page. My goal is to get the list of links and count them.

I've added Google Labs page to my Object Repository and now it looks like:
I use Object Repository (OR) to simplify my demo-scripts.
Since the browser & the page were added to OR, we can use them later like:
Browser("Google Labs").Page("Google Labs").

Now we are ready to start!

  1. QTP Descriptive Programming (QTP DP) and ChildObjects QTP function
    The approach uses Description object, which contains a 'mask'
    for objects we would like to get.
    QTP script is:
    Set oDesc = Description.Create()
    oDesc("micclass").Value = "Link"
    Set
    Links = Browser("Google Labs").Page("Google Labs").ChildObjects(oDesc)
    Msgbox "Total links: " & Links.Count
    The result of this QTP script is:
    ChildObjects returns the collection of child objects matched the description ("micclass" is "Link") and contained within the object (Page("Google Labs")).


  2. Object QTP property and objects collections
    QTP can work with DOM:
    Set Links = Browser("Google Labs").Page("Google Labs").Object.Links
    Msgbox "Total links: " & Links.Length
    I use Object property of Page object. It represents the HTML document in a given browser window.
    This document contains different collections - forms, frames, images, links, etc.
    And we use Length property to get the number of items in a collection.

    The result is the same as for the previous QTP script:


  3. Object QTP property and GetElementsByTagName method
    Again, we can get access to
    the HTML document and use its GetElementsByTagName method.
    As the name says,
    GetElementsByTagName method returns a collection of objects with the specified tag.
    Since we are going to get all link, we should use "a" tag.

    QTP script is:

    Set Links = Browser("Google Labs").Page("Google Labs").Object.GetElementsByTagName("a")
    Msgbox "Total links: " & Links.Length
    The result is the following:

    Note: There is another way how to select objects by tag name:
    Set Links = Browser("Google Labs").Page("Google Labs").Object.all.tags("a")
    Msgbox "Total links: " & Links.Length
    The result will be the same. 69 link will be found.


  4. XPath queries in QTP
    The idea of this approach is to use XPath queries on a source code of Web page.
    For example, "//a" XPath query returns all "a" nodes (= links) from XML file.

    There is one problem. Web page contains HTML code, which looks like XML code but actually it is not.
    For example:
    • HTML code can contain unclosed img or br tags, XML code cannot.
    • HTML code is a case-insensitive markup language, XML is a case-sensitive markup language, etc
      More details here.

    So, we have to convert HTML source code into XML. The converted code is named as XHTML.

    You can convert HTML documents into XHTML using an Open Source HTML Tidy utility.
    You can find more info about how to convert HTML code into XHTML code here.

    I will use the final QTP script from this page, a bit modified:

    ' to get an HTML source code of Web page
    HtmlCode = Browser("Google Labs").Page("Google Labs").Object.documentElement.outerHtml

    ' save HTML code to a local file
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.CreateTextFile("C:\HtmlCode.html", True, -1)
    f.Write(HtmlCode)
    f.Close()

    ' run tidy.exe to convert HTML to XHTML
    Set oShell = CreateObject("Wscript.shell")
    oShell.Run "C:\tidy.exe --doctype omit -asxhtml -m -n C:\HtmlCode.html", 1, True ' waits for tidy.exe to be finished

    ' create MSXML parser
    Set objXML = CreateObject("MSXML2.DOMDocument.3.0")
    objXML.Async = False
    objXML.Load("C:\HtmlCode.html")

    XPath = "//a" ' XPath query means to find all links
    Set Links = objXML.SelectNodes(XPath)
    Msgbox "Total links: " & Links.Length
    Note: you can download tidy.exe here for above QTP script.

    This QTP script leads to the same results - 69 links found:
    (Click the image to enlarge it)


  5. Bonus approah
    Why don't you count all Wen page objects manually? :) Open a source code of the page and start counting :)
    Just joking :)

Summary:
  • I shown 4 practical approaches how to count Web page links.
    Similarly you can process images, webedits, etc
  • Each approach gets a list of objects.
  • First approach (QTP DP + ChildObjects) is the most easy
  • Second & third approaches (Object + collections; Object + GetElementsByTagName) will work on Internet Explorer, because they use DOM methods
  • Fours approach is biggest but it is more powerful. It allows to use complex XPath queries.


Related articles:


Do you like this QTP tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? VIDEO guide)




Do you know that you are free to use/copy/publish all my materials on your site/blog?


Top 40 Automated Testing Blogs - Nov 2008

At the end of October 2008 I invited my readers to send me their favorite Automated Software Testing blogs.

I would like to thank those readers who shared most interesting and useful blogs.
Great job, dear colleagues! :)

As a result, I'm glad to introduce the final list of Top 40 Automated Testing Blogs.

I sorted these blogs on the basis of:
  • PageRank (PR) - Google's view of the importance of a pag. The bigger, the better.
  • AlexaRank (AR) - Alexa's range of a site based on a traffic.The lower, the better.
  • TechnoratiRank (TR) - position of the blog among all Technorati blogs. The lower, the better.
  • Comments (Cmts) - number of comments for all articles posted during previous 3 months (Aug, Sep, Oct 2008). The bigger, the better.
  • Incoming links (Links) - number calculated by Yahoo Site Explorer. The bigger, the better.
Top 40 Automated Testing Blogs

# Site / Author PR AR TR Cmts Links
1
Google Testing Blog (various)
5
219028
47930
112
8507
2
Performance Tidbits Rico Mariani
5

113248
31
16924
3
Scott Barber's blog Scott Barber
4

72223

19683
4
Collaborative Software Testing Jonathan Kohl
5

404815

8838
5
Cem Kaner's blog Cem Kaner5



5077
6
Agile Testing Grig Gheorghiu
5
315063
205275
56
4393
7
James Bach’s blog James Bach
4

164842
44
14020
8
Creative Chaos Matthew Heusser
5
2306703
373134
54
7655
9
Advanced QTP (various)
4
620947
722230
79
8585
10
Corey Goldberg's blog Corey Goldberg
4
1282348
256345
142
3244
11
The Braidy Tester Michael J Hunter
5

437554
17
4692
12
Tester Tested! Pradeep Soundararajan
4
1195245
770942
99
3810
13
WilsonMar.com Wilson Mar
4
164760
512788

1431
14
Testing Hotlist Update Bret Pettichord
4
1657484
446540
11
7487
15
Test Obsessed Elisabeth Hendrickson
5
3148166
351547
6
2493
16
My Load Test Stuart Moncrieff
4
1009095
553587

921
17
Theo Moore's blog Theo Moore
3

80402532
9155
18
Thinking Tester Shrini Kulkarni
4
1427381
1052395
30
3482
19
Observations on software testing and quality Michael Bolton
4

1038615
11
3653
20
Quality through Innovation Adam Goucher
4
8063489
722230
11
3973
21
Easy way to automate testing Dmitry Motevich
3
675427
1038615
131
503
22
Software Testing Zone Debasis Pradhan
3
760191
906103
14
1461
23
JW on Test James Whittaker
3


71
1027
24
Mike Kelly's blog Mike Kelly
4

1038615
1
2757
25
Questioning Software Ben Simo
5
4064149
1285236
4
1679
26
London software testing news (various)
4
2598600
2593630
3
1937
27
Ankur Jain's blog Ankur Jain
2
478294
655996
9
281
28
Jeff Fry on Testing Jeff Fry
4
11028482
1214675
7
1565
29
The Software Inquisition (various)
3
1449194
1214675
7
886
30
90kts Tim Koopmans
2
1648922
600724
5
63
31
Test this Blog Eric Jacobson
3
9632080
3324847
27
716
32
Stefan Thelenius about Software Testing
Stefan Thelenius
3
5716662
1867832
5
916
33
LoadRunner Tips and Tricks Hwee Seong Tan
0
2422241
1214675
24
478
34
QuickTest Pro Mohan Kumar Kakarla
3
1884598
1211403
1
91
35
KnowledgeInbox Tarun Lalwani
2
1165000


121
36
Alexander Podelko's blog Alexander Podelko
3



490
37
Software Performance Engineering & Testing Charlie Weiblen
3
5451220
4978471

152
38
Software Testing Blog Unknown
2
2712832
2593630

430
39
Automated Chaos Bas M. Dam
2
5130521


148
40
Automated Web Test Meena
2
7702460
4697735
2
144

Note: You can download raw statistic of this list here.

I know for sure - authors of these blogs did an excellent job. Thank you very much!

Note: I understand that nothing is constant. And this list of Automated Testing Blogs should be updated periodically. Also I'm sure that some cool blogs are not present on this list.

That's why I need to know your opinions. Do you have something to add? Please share.

Dear reader, do you have interesting ideas for such future lists, surveys, actions? What posts would you like to see here? Let me know please.
My email is: Dmitry Motevich's email

--
Dmitry Motevich




Related articles:



I recommend to subscribe to my blog and you will receive updates automatically.
You can subscribe to this blog RSS feed or by Email. (How to subscribe? Video guide)



Would you like to publish this Top 40 Automated Testing Blogs List on your site or blog?
Please know that
you are free to use/copy/publish all my materials.


Manual Correlation in LoadRunner - Video

In previous LoadRunner video (Automated Correlation in LoadRunner) I shown how to use Automated Correlation. The present LoadRunner video explains how to manually correlate dynamic values:
  • How to find dynamic values in a server response
  • How to correlate them in LoadRunner
  • How to verify the correlation
There is a screenshot from the present LoadRunner video:
Manual Correlation in LoadRunner

Automated Correlation in LoadRunner - Video

Correlation is a key concept of HP LoadRunner. The present LoadRunner video tutorial explains how to correlate dynamic values in LoadRunner automatically:
  • How to find dynamic values to be correlated
  • How to compare recorded & replayed dynamic values
  • How to correlate them in LoadRunner
  • How to verify correlation
There is a screenshot from the present LoadRunner video:
Different server responses
Also, this LoadRunner video explains concepts of Correlation and how Correlation works.
Video tutorial demonstrates LoadRunner Correlation by the example of HP Web Tours application, which is shipped with LoadRunner. So, you can repeat and learn all shown actions yourself.

Automated Correlation in LoadRunner - Video


Related articles:


Do you like these LoadRunner video? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? Video guide)



Do you
know that you are free to use/copy/publish all my materials on your site/blog?


LoadRunner video - How to check manually a downloaded file

Do you know how to check that file or page was downloaded successfully in LoadRunner?
The present LoadRunner video tutorial explains how to do that. All you need is to check LoadRunner snapshot files (inf-files) located in LoadRunner script folder:
LoadRunner script files
LoadRunner video - How to check manually a downloaded file




Related articles:


Do you like this LoadRunner video tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? Video guide)




Do you know that you are free to use/copy/publish all my materials on your site/blog?


LoadRunner video - How to capture the whole Web page?

This LoadRunner video tutorial shows how to capture Web page.
Using this approach, you can get HTML source code of any Web page and then downloade it to a local file.

LoadRunner video - How to capture the whole Web page?


There is a final LR script for capturing and saving Web page:
int hFile;
char *szFileName = "c:\\page.html";

//Mark that we will capture the whole body of Web page
//Note: Mark that web_reg_save_param should be placed *before* web_url
web_reg_save_param("prmPage", "LB=", "RB=", "Search=Body", "RelFrameID=1", LAST);

web_url("labs.google.com", "URL=http://labs.google.com/", LAST);

//Web page has been captured, so print it out
lr_output_message("Page is: \r\n%s", lr_eval_string("{prmPage}"));

//Truncate to zero length or create file for writing.
if ((hFile = fopen(szFileName, "wb")) == NULL)
{
    lr_error_message("Cannot open %s", szFileName);
    return LR_FAIL;
}

//Write captured Web page to an output file
fprintf(hFile, "%s", lr_eval_string("{prmPage}"));

//Close the file pointer.

fclose(hFile);


Related articles:


Do you like this LoadRunner video tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? VIDEO guide)



Call for votes - Top Automated Software Testing Blogs

Today I've decided to create a list of best & recommended Automated Software Testing Blogs.

It will be extremely useful for every engineer or manager working in QA field and in automated testing especially.

How the list of blogs will be created?
I think, the best way is to ask persons who work in automated software testing. I mean you, my readers!
That's why I ask your help, dear readers.
Your vote is important! Please, email me URLs of your favorite and most valuable blogs on automated testing.
My email is: Dmitry Motevich's email

What blogs can participate?
Blogs can contain any information related to automated testing:
  • working with automated testing tools
  • test automation frameworks
  • automated testing approaches anf methodologies
  • tips, tricks, experience
  • etc.
Please, pay attention, that only blogs can participate in the present poll.
I will create separate lists for automated testing sites, forums etc.

What are criteria to include blog into the list?
I will use these criteria to select most popular automated software testing blogs:

What is a deadline for blogs submitting?
The deadline is an end of October 2008. So, please hurry up :)
I plan to create the final list of Automated Software Testing Blogs in early November 2008 and publish it on my blog.

Update: Top 40 Automated Testing Blogs created :) Thank you very much!



Do you know that you are free to use/copy/publish all my materials on your site/blog?


How to update XML file from QTP

In previous QTP tutorial I shown how QTP can read data from XML file.
Today I will explain how to update XML data from QTP.

We will use this XML file:
Initial XML fileNote: You can download this XML file here.

Let's check how to update different values in above XML file:
  1. How to rename the title of first book?
    The QTP script is:
    Const XMLDataFile = "C:\TestData.xml"
    Const XMLNewFile = "C:\TestData2.xml"

    Set xmlDoc = CreateObject("Microsoft.XMLDOM")
    xmlDoc.Async = False
    xmlDoc.Load(XMLDataFile)


    ' update the title of the first book
    Set node = xmlDoc.SelectSingleNode("/bookstore/book[0]/title")
    node.Text = "Romeo and Juliet - Salvation"

    ' save changes

    xmlDoc.Save(XMLNewFile)
    And the result is:
    Note: The numeration begins from zero. That's why I use book[0] to access first item.


  2. How to change the year of second book?
    I skip the opening and saving of XML file (see above QTP script). I show only the essence:
    ' update the attribute of the second book
    Set node = xmlDoc.SelectSingleNode("/bookstore/book[1]/title/@published")
    node.Text = "2009"

    And the result is:
    Note: Use @ to access an attribute of XML node.


  3. How to add new author add its new attribute?
    QTP script:
    ' select a parent node
    Set parentNode = xmlDoc.SelectSingleNode("/bookstore/book[2]")

    ' add a new author
    Set newNode = xmlDoc.CreateElement("author")
    newNode.Text = "Mr. Noname"
    parentNode.AppendChild (newNode)
    And the result is:
    As you can see, we've added "Mr. Noname" as the new author.


  4. How to add new attribute for author (XML node)?
    QTP script:
    ' select a parent node
    Set parentNode = xmlDoc.SelectSingleNode("/bookstore/book[2]")

    ' add its attribute
    Set newAttrib = xmlDoc.CreateAttribute("bestseller")
    newAttrib.Text = "yes"
    parentNode.Attributes.SetNamedItem(newAttrib)
    The result is:
    New attribute of a boof and its value ("bestseller"="yes") have been added.

Well, the working with XML files from QTP is easy enough.


Summary:
  • shown in QTP - how to change value of XML node
  • shown in QTP - how to change value of attribute
  • shown in QTP - how to add new XML node
  • shown in QTP - how to add new attribute


Do you have any comments, dear reader? Please, leave them below the present article.
Thank you in advance :)



Related articles:


Do you like this QTP tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? VIDEO guide)




Do you know that you are free to use/copy/publish all my materials on your site/blog?