QTP – Browser CreationTime

I’ve generally seen some confusion around CreationTime. I think between the 3 Ordinal Identifiers, this one may be the easiest to understand and implement. That’s mostly because CreationTime is used only for the Browser object. Below is how CreationTime is applied to browsers:

1st open browser -> CreationTime of -> 0
2nd open browser -> CreationTime of -> 1
3rd open browser -> CreationTime of -> 2
4th open browser -> CreationTime of -> 3

According to QTP help:

This value indicates the order in which the browser was opened relative to other open browsers. For example, if QuickTest learns three browsers that are opened at 9:01 pm, 9:03 pm, and 9:05 pm, QuickTest assigns the CreationTime values, as follows: CreationTime = 0 to the 9:01 am browser, CreationTime = 1 to the 9:03 am browser, and CreationTime = 2 to the 9:06 am browser.

Really, that’s it! No tricks here! To test it for proof, you can open 4 browsers (with different websites) and run the following code in QTP:

For ix = 0 to 3
	Print "CreationTime->" & ix & "->" & Browser("creationtime:=" & ix).GetROProperty("title")
Next

On my desktop, I’ve 4 open IE windows in the following order: Google, Bing, Yahoo, Microsoft. See snapshot below:

My taskbar

My taskbar: Click to view original size

After running the above code, this is what I see in my print log:

Print log

Print log

The output shows the order in which the IE windows are placed on the Desktop, which is same as the order in which they were opened.

The tricky part

The only tricky part in this concept is its applicability when there is only one browser open. With one open browser, regardless of the CreationTime value supplied, QTP will always identify the only open browser. This is because, CreationTime values are generated when there are multiple browsers open – with a single open browser, this value is generally has no usage. This is at least true for QTP 10.0 and previous versions.

Subscribe for Relevant Codes newsletter to get awesome updates and articles delivered straight to your inbox.

Leave a Comment

{ 23 comments… add one }

  • Manideep January 6, 2014, 7:20 am

    Hi Anshoo
    I am tryting to run title script for multiple browsers where 2 of them have multiple tabs open , QTP gives error for such case , kindly shed some light on this issue.

    Reply
  • sadashiv July 6, 2012, 3:34 am

    If you opened 100 browser at a time all browser creation time will be same, then how to close the browser?

    Reply
    • Anshoo Arora July 10, 2012, 10:23 am

      Sadashiv: the first browser will have a CreationTime or 0 and the last opened browser will be 99..

  • Puneet March 20, 2012, 1:01 pm

    Hi Anshoo,

    I have a script which log the time for one iteration, but how can I allow multiple iteration to have a log file.

    Thanks

    Puneet

    Reply
  • Shubhanshu Rastogi November 29, 2011, 1:24 am

    Can we launch two browsers simultaneously ? I need to test a scenario in which I am perform the same operation on two different browsers simultaneously.

    Reply
    • Anshoo Arora December 27, 2011, 6:53 am

      Shubhanshu, its not possible if you’re considering QTP to do this. It will first launch Browser #1, then #2. It will perform an event first on Browser #1, then #2.

  • Suresh July 26, 2011, 4:56 am

    Hi Anshoo,
    I would like to know how to toggle between browsers. Say i send a mail from GMAIL to YAHOO. How can i set the script to Invoke GMAIL first send a mail and then Invoke YAHOO to check the mail has arrived.

    Reply
    • Anshoo Arora August 1, 2011, 4:14 pm

      The only trick between sending and receiving is the sync that you need to take care of to make sure the mail is received. In most cases, this should be instantaneous so as soon as you send your mail via Gmail, it should appear in your Inbox. However, if there is a delay, you can run a loop and check whether the ‘current count’ exceeds the ‘old count’ – this will tell you if the number of mails in your Inbox is increasing or not.

  • qtp que. July 3, 2011, 12:09 am

    Hi, is the creationtime code for also firefox browser. if it is then it’s not working.

    Reply
  • Gowri Harika May 31, 2011, 4:13 am

    If we close Google browser
    Then what is the creation time of Bing?

    Reply
    • Anshoo Arora June 24, 2011, 10:36 am

      Gowri: If there are only 2 browsers open, the maximum creationtime value is 1. If you close either of the two browsers, the maximum creationtime value becomes 0.

  • Godi April 11, 2011, 9:28 am

    How can we identify the tabs in the broswer? Is there any way?

    Reply
  • LAKSHMAN March 31, 2011, 5:54 am

    if i have three browsers with same object properties and values how can i open third browser on QTP

    Reply
  • Pradeep March 31, 2011, 3:21 am

    Hi Anshoo..
    Will I be able to change the creation time value in Obj Repository during run time? My Need is i will be testing the same application through different URL’s simultaneously (in Diff browser) with my script. So the objects in OR will be the same under single parent Browser for which i want to change the creation time during run time. Can you please help me in tis regard?

    Reply
    • Pradeep March 31, 2011, 3:29 am

      Adding to it ….Should i do everything by descriptive method only?for referring objects?

    • Pradeep March 31, 2011, 3:31 am

      Adding to it…. or else should i refer all d objects with descriptive approach only?

  • Amit Saran November 18, 2010, 11:05 am

    Hi Anshoo,

    I want to know can we use unix shell scripting in QTP and if How it can be don. Please reply as soon as possible.

    Reply
    • shashank December 24, 2010, 3:41 pm

      Not At All The only MAJOR Draw-back of QTP

      It’s only works in Windows platform

    • Anonymous February 2, 2011, 10:13 pm

      Amit,

      This reply is incorrect. Yes, you can execute Unix scripts from QTP. If I understood your question correctly, then the way you do this is as follows: 1. Via QTP you have to invoke Unix session by using,say,PuTTY tool. This is done programmetically (VBScript) by writing a PuTTY logon function. Once, you are logged in then (2). Type the unix command to execute your script file the way you do it manually on unix window. Of course, all this you have to do it from within the QTP VBscript function. You can search on Google for “objWindows” object methods and “objShell.Run”, etc.

      -DA

  • biswajit September 23, 2010, 1:52 am

    in runtime can we toggle between the browsers with changing the property of the creation time if multiple browsers are open.

    Reply
    • Anshoo Arora September 29, 2010, 3:12 pm

      Biswajit,

      Do you want to toggle between the browsers manually? If you’re asking with CreationTime, then yes, its certainly possible. You can simply use .Highlight to highlight the specified browser and toggle without performing any specific event.

  • AMIT SARAN September 3, 2010, 7:36 am

    Hi Anshoo,

    I want to ask you one thing. Actually recently I joined a new company and this company asking me to work on VSTS.
    Previously i was working on QTP. Do know anything about VSTS. Is it good for my career ? I am confused now because VSTS is a new tool in market and now a days QTP is popular. So please tell me if you know any information about it.

    Reply
    • Anshoo Arora September 3, 2010, 7:49 am

      Amit,

      I just did a Dice.com search for VSTS and QTP. VSTS has 55 jobs available, whereas QTP has 530. I believe QTP is still the market leader by far when it comes to test tools.

      I don’t have first hand experience with VSTS though. Someone having experience with both tools may be a better judge.