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:
After running the above code, this is what I see in my 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.