Search code examples
ui-automationqtphp-uft

Exist is always coming TRUE in UFT when using index to identify Browser


I've to get the number of opened browsers having some title. The approach that I used was using the index. But the problem is, whatever index I pass, Exist function is always returning true.

Browser("openurl:=.*something.*", "index:=0").Exist  => True

when i change the index to 10 or some other number, it still returns me True even if there is only one browser window. My problem statement is to find any new browser window opened after a click of a button, this window can be a pdf or csv file. After identifying the window (by using index in my case) I've to get the visible text of the window.

PS: I'm new to UFT, have worked on automation using selenium tool.


Solution

  • The index (or any ordinal identifier like CreationTime) are used only if the description matches multiple Browsers, if the description you supply only matches one object it will be ignored.

    I tried with two open tabs and got the following results:

    Print Browser("opentitle:=.*", "index:=10").Exist         ' => False
    Print Browser("opentitle:=.*Example*", "index:=10").Exist ' => True
    

    If you're seeing different results I would suggest try using the undocumented function Highlight to see which Browser UFT thinks matches your description.