Posts Tagged ‘QuickTest Pro’

childNodeByID function for Web Extensibility

Friday, June 27th, 2008

During the Web Extensibility talk at HP Software Universe, somebody asked me to post the code for childNodeByID. This is a javascript function that is useful in Web Extensibility projects. It lets you find the child of a DOM object that has a specific id attribute.

At the time, I said this function was only a few lines long. I was wrong. Somebody with more javascript experience could probably golf this down to a few lines, but my version is pretty long.
(more…)

The future of QuickTest Pro

Wednesday, June 18th, 2008

HP just gave a revealing presentation about the next version of QuickTest Pro. It is codenamed Atlantis, and it will probably be called QuickTest Pro 10.0. QTP 10 is targeted to be released in the beginning of 2009.

I’ll break down some of the features that were discussed.
(more…)

QTP’s mysterious Init method

Thursday, May 22nd, 2008

One limitation of QTP that has always bothered me is the inability to reuse its web objects after the browser reloads. I spend countless cpu cycles parsing the DOM to find an element, grab enough properties to make it unique, build a description with those properties and finally get the right micobject. Then I perform some action and that reloads the page, and my object is useless. If I want to use it, I have to start the process all over again.

After years of struggle to find an answer, I packed some gear, hired a Sherpa and set off to find a guru who could give me an answer.
(more…)

Execute Javascript from QuickTest Pro

Tuesday, May 20th, 2008

Despite persistent the rumors to the contrary, you really can execute Javascript from QTP, and not just using Web Extensibility. Here is a simple function that will run some javascript in IE and return the result.

Visual Basic:
  1. Public Function evalJS(oBrowser, sJavaScript)
  2.     Set JSEntry = oBrowser.object.document.documentelement.parentnode.parentwindow
  3.     On Error Resume Next
  4.     evalJS = JSEntry.eval(sJavaScript)
  5.     On Error Goto 0
  6. End Function
  7.  
  8. Set oBrowser = Browser("version:=inter.*")
  9. evalJS oBrowser, "alert('Hello, world');"

(more...)

Help for QTP Novices

Tuesday, February 5th, 2008

This month AdvancedQTP is running The Flight Reservation Project, which is a tutorial series based on the Flight Reservation example application that ships with QuickTest Pro. This series focuses on testing a Windows application, which is outside of the Inquisition's usual subject matter of web apps.
(more...)

QTP 9.5 feature review - Web Extensibility Add-ins

Tuesday, January 29th, 2008

I've now had a few days with Quicktest Pro 9.5, and most of that time has been spent with the new Web Extensibility feature. This feature has huge potential. I look forward to seeing how it is accepted by QTP programmers.

The basic idea is that you can create your own QTP add-in. When your add-in is loaded, Quicktest will recognize objects you defined in your add-in and make your custom methods available for them.

After I went through the tutorial in the QuickTest 9.5 documentation, I jumped into creating a Web add-in for a simple DIV in the product I am testing. I called the extension auLogin and the object auLoginForm. The first method I added was SubmitLogin. All it does is click the Login button. This seemed to be an unambitious task, but it proved more difficult than I counted on because I didn't learn as much as I thought through the tutorial. It is also something much easier done with the single line Browser().Link("html id:=Submit1_a").click, but this exercise is about learning, not being efficient.
(more...)

A funny thing happened

Wednesday, January 23rd, 2008

A funny thing happened the other day. Somebody used the word "inquisition" in conversation. In the back of my mind I remembered that I used to read a blog called The Software Inquisition. I decided to see what has been going on with that blog, but there was nothing new there. I pondered the lack of updates and figured out what had happened. I was supposed to be posting entries all this time.

Now that I have that amnesia problem worked out, I have a lot of catching up to do. Where did I leave off? Maybe something about SIFL. I'll have to sort that out after lunch, but before I go to lunch, I need to remember where I parked my car.

Test Design Studio

Wednesday, September 5th, 2007

I have spent most of the last few weeks working on QTP libraries, but very little of that time was spent wrestling with Mercury’s beast of an IDE. Aside from actually running my tests, I use QuickTest for very little these days. Instead, I am using a new editor called Test Design Studio. Everybody who uses QuickTest Pro’s expert view should try Test Design Studio. Once you do, you won’t go back to QTP.

Before we get too far into this, you need to know that Test Design Studio (TDS) isn’t a complete QTP replacement. TDS replaces QuickTest’s editor and library management, but it doesn’t actually run the tests. You use TDS to write tests and QTP to run them.

I could go on for pages about TDS’s features, but I won’t. You can see all of that at Patterson-consulting.net. Instead I will give you my first-ever top 10 list.

Top Ten Test Design Studio features that QTP is missing

10. Edit two tests at once – QTP is already on version 9.2 and they still haven’t figured out that users programmers might want to copy text from one test to another.

9. Excellent technical support – This isn’t technically a product feature, but it makes a big difference in using the product. I have submitted my share of help requests and bugs to Mercury, and I don’t think I have ever had an issue resolved within a day…rarely within a week. Patterson Consulting is another story. They will bend over backward to help you. Send an email to support or post in their help forum, and you have a good chance of getting a resolution within the hour. I haven’t called their support number, but I think I’m safe in assuming that if I do I won’t have to navigate through multiple levels of tech support before getting a resolution. The same can’t be said for Mercury.

8. Documentation Wizard – Automatically generate a help file from your code comments. If you maintain a large library, you know what a pain the documentation can be. TDS’s Documentation Wizard takes 90% of the work out of it.

7. IntelliSense for every class and function in your library – Don’t confuse this with QTP’s IntelliSense. TDS goes far beyond what QTP offers. With QTP, if you type Browser(oDescription), you will get IntelliSense for the various methods registered to the Browser type, but what if you have a function that returns a Browser object? You are out of luck with QTP, but TDS is able to tell that the function will return a browser. For instance, I often call the function BrowserDefault, which returns my default browser. With TDS, as soon as I type the period after the function name, I see all of Browser’s registered methods.
TDS Intellisense
I can’t do justice to TDS’s IntelliSense here. You’ll have to see it for yourself.

6. Customizable menus – You can put almost anything you can think of on any toolbar or menu. I recently worked on customizing the xslt file that defines the layout of TDS’s Object Browser. Instead of restarting TDS to try out changes, I added the “Reload ObjectBrowser.xslt” command to my tools menu. For most applications, that would be an internal-only call, but it looks like Patterson Consulting has made a point to make everything possible available to their users.

5. Hooks for external tools – There are still a few things that Test Design Studio doesn’t do. For that, there are external tools. For instance, I have an external tool set up that grabs all the vbs files in my project and adds them as resources on the active test. Another external tool is a vbs script that will open and run the current test in QTP.

4. Customizable Hot Keys – One of the few things I don’t care for in TDS are the default hot-keys assignments, but thanks to the customizable hot keys, I don’t have to remember that Ctrl+E,C is the command to comment out a block of text. It took about five minutes to make TDS match the Eclipse hot keys that I am used to.
Also, by combining this with the external tools mentioned above, I just have to press F5 to run the current test in QTP.

3. Code snippets – If you use Visual Studio, you already know what these are. I had not used code snippets before TDS, but I have come to find them very useful. I’m not sure that I can adequately explain code snippets in this post, so I’ll let Patterson explain it.

2. Macros – If you like to do the same thing over and over and over and over, this isn’t for you.

1. Search and replace throughout the project – Search and replace throughout the project is huge. Shortly after I started evaluating TDS, I changed the signature on a function. It literally took less than a minute to find and update hundreds of calls to that function spread over dozens of files.

There you have my first-ever top ten list. I hope you enjoyed it. I probably shouldn’t have numbered them because I just wrote them in the order that I thought of them. I also ran out of numbers before I ran out of features. If the list were a bit longer I would have included Object Browser, collapsible code outlining and xml-comments.

Domain Specific Language

Tuesday, August 28th, 2007

One of my favorite talks at GTAC was Douglas Sellers' presentation on implementing a Domain Specific Language (DSL) with Selenium. I am not a Selenium user, but a lot of what he talked about relates well to what we are trying to do with QTP.

Here is the video for your viewing pleasure.

Introducing SIFL

Thursday, August 23rd, 2007

The Inquisitors are proud to introduce a bit of code we have been working on. We are calling it the Software Inquisition Foundation Library for QTP, but you can call it SIFL (pronounced like "sniffle", but without the "n").

SIFL is a collection of QTP functions that we have been using for a while as a base framework for our QTP tests. Having eschewed checkpoints, the object repository, and the idea of record-and-playback testing, we needed a uniform way to write tests. SIFL is what we came up with.

Before I get into the details, let me show you a sample test to give an idea of what we are looking at. This is a quick example that uses the all-too-familiar Mercury Tours web site. We will open the site, navigate to the cruises page and make sure the departure time for the Skagway cruise is 5 pm.

Visual Basic:
  1. BrowserDefault.Navigate "http://newtours.mercuryinteractive.com"
  2. BrowserDefault.Link("innerText:=Cruises").Click
  3. Set oTable = BrowserDefault.WebTable("innerText:=Cruise Itinerary.*")
  4. sDeparture = oTable.GetXWhereYisString("Departure", "Port of Call", "Skagway, Alaska")
  5. assertStringEquals sDeparture, "5 pm"

If you are used to seeing QTP code, that should look somewhat – but not entirely – familiar. I’ll go line-by-line to show you what is happening.

BrowserDefault.Navigate "http://newtours.mercuryinteractive.com"

The “BrowserDefault” function returns the current default browser. Because we have not already defined a default browser, it will open a new instance of IE for us and make it the default for future calls to BrowserDefault. The “Navigate” portion of that line is just the browser object’s standard navigate method. This causes the newly opened instance of IE to navigate to the Mercury Tours site.

BrowserDefault.Link("innerText:=Cruises").Click

Here we are calling the default browser again. This time we are clicking a link in the default browser.

Set oTable = BrowserDefault.WebTable("innerText:=Cruise Itinerary.*")

Once again, this is pretty standard. We are just assigning this web table instance to oTable. This step isn’t really necessary, but I wanted to keep the next line short

sDeparture = oTable.GetXWhereYisString("Departure", "Port of Call", "Skagway, Alaska")

Here we are using the SIFL method “GetXWhereYisString”. To put it simply, this gets the data from the “Departure” column in the row where the “Port of Call” column is “Skagway, Alaska”. If everything is kosher on the site, sDeparture should be a string with the value “5 pm”.

assertStringEquals sDeparture, "5 pm"

Here we assert that the string sDeparture equals “5 pm” and note the results in the log. If the assertion is correct, it passes, if not, it fails. Note the fine control we have over the types involved in this homemade "checkpoint". This is what allows us to execute tests across continents without a complicated source tree.

I am writing this on a plane that is about to land, so that's it for now. Expect to see more on SIFL in the next few days along with a link to download it for yourself.