Be careful while using SystemUtil.Run method

SystemUtil.RunFor one of my projects, I was using SystemUtil -an inbuilt object of QTP- to launch my application. For about 5 times script-replay was perfect, the 6th times onwards QTP started throwing an error:

Cannot identify the object parent. Make sure that……

Object spy on browser bar revealed that it was being recognized as window instead of browser! Some more R & D and I discovered that the problem lies with the SystemUtil.Run method. I was using SystemUtil.Run “explorer”, <URL>. When I changed that to SystemUtil.Run “iexplore”, <URL> script started running fine. I guess while using explorer, QTP expects a file path and not a HTTP path on it. Having said that, I am still not sure how it ran fine for the first few times.

To launch an application, I think a better alternative would be to create a shell object and launch applications using its Run method. It will take about 4 lines of code.(including declaration and destruction of shell object)

Probably a good time to change my habit of writing the shortest possible code while programming!

If you want to keep track of further articles on QTP. I recommend you to subscribe via RSS Feed. You can also subscribe by Email and have new QTP articles sent directly to your inbox.

Have you ever used Web Event Recording Configuration in QTP?

Web Event Recording ConfigurationThere is this little feature - Web Event Recording Configuration - sitting inside Tools menu of QTP. QTP help has this to say about it.

QuickTest creates your test by recording the events you perform on your Web-based application. An event is a notification that occurs in response to an operation, such as a change in state, or as a result of the user clicking the mouse or pressing a key while viewing the document. You may find that you need to record more or fewer events than QuickTest automatically records by default. You can modify the default event recording settings by using the Web Event Recording Configuration dialog box to select one of three standard configurations, or you can customize the individual event recording configuration settings to meet your specific needs.

I find it as one of the most neglected areas, as I have never received a single query regarding this feature on my blog or forums in the past 2+years! So , just want to know from you, have you ever used this feature in the past? If yes. Please let us know how it helped you with your QTP issues.

If you want to keep track of further articles on QTP. I recommend you to subscribe via RSS Feed. You can also subscribe by Email and have new QTP articles sent directly to your inbox.

How to delete cookies through a script?

Cookies are those small files on your computer that store information between sessions or between two login attempts. There are valid reasons where you might need to delete codelete cookiesokies stored on your computer through scripting.

Now, how can we delete cookies through VB Scripting in QTP? This one is a very often repeated question on the testing tools forums. I will first provide a hint here.

  1. You need to write a custom function to do this. IMHO there is no direct way available.
  2. Write a shell script to reach to the cookies file residing in your corresponding folder.
  3. Delete all the files inside that folder.

Please post your script in the comments below. If I don’t get an answer by tomorrow, I will update the post with my script.

If you want to keep track of further articles on QTP. I recommend you to subscribe via RSS Feed. You can also subscribe by Email and have new QTP articles sent directly to your inbox.

Quiz: A message box that will close automatically

While debugging your scripts I am sure you must be using a lot of “msgbox” functions. Won’t it be good if this message box closes automatically so you need to have to pain yourselfqtp_msgbox to reach that mouse. 

Can you design a function which will close the message box automatically after x seconds. If yes, write your script in comments below.

Check out this space tomorrow for an answer.