Reputation: 11
Can uft 12.5 support a test opening two ie browsers? I want to run a test with multiple sessions
Upvotes: 1
Views: 2177
Reputation: 466
OK, so you're wanting to open the exact same page in two separate browser windows/pages/tabs...
Normally, I am an extremely strong advocate for using the Object Repository over descriptive programming, but this is one scenario where descriptive programming really is the best way to handle it.
First, I want to explain my approach to defining web objects.
1) the Browser object does not describe the browser (IE, firefox, chrome)... Instead the Browser object describes the Web Site. For example, I might have a browser object defined in the OR for "Stackoverflow.Com" and a separate browser object defined for "Amazon.Com". I usually include the URL as one of the identifying properties, but I use regular expressions to allow the URL to change from page to page and still let the same browser object identify any page from that site as the site itself.
2) The page object describes whichever specific page the web site is showing at any given moment. (I know many people just wildcard the page since a browser object can only have one page child object at a time, but that doesn't make sense in my OR structure...) For the most part, any web site can be said to be made up of various pages, and each page can be uniquely identified in some way (usually by the second half of the URL). I use regular expressions to pick out the page portion of the website - whichever part never changes for that page - so that each page object will uniquely identify whenever that page is loaded.
3) All of the controls that live on a specific page are stored under the page they belong to in the OR.
I prefer to always use the Object Repository to store my object descriptions. The only time I use Descriptive Programming is when I can't hard-code -which- of my predefined objects I'm referring to in a line of code.. So, Adapting this strategy to handle your needs, we would look at the Browser object using Descriptive Programming. (Theoretically, we could still use the Object Repository to do this, but I feel that it's twisting the OR in a way that doesn't represent what's really going on)
So... using normal code, you would launch your web page twice using SystemUtil.Run URL
(where URL is a var containing the URL to your page).
Then, you could check that the first page exists in a manner similar to this:
if Browser("openurl:=.*stackoverflow\.com.*","index:=0").Page("title:=Stack Overflow").Exist then...
and then check that the second page exists similar to this:
if Browser("openurl:=.*stackoverflow\.com.*","index:=1").Page("title:=Stack Overflow").Exist then...
Note that the only difference is the index number is either 0 or 1. This should be able to uniquely identify each window separately, and you can do whatever you want to whichever window as long as you include the index in the browser's description - even if the page is exactly the same.
Also note that... It shouldn't matter if the browsers are two tabs in the same browser window, or if they are two separate windows that each contain one tab. As far as QTP/UFT is concerned, if there are more than one browser tabs open that each match the description Browser("openurl:=.*stackoverflow\.com.*")
, then it uses the index (or creation time) property to tell them apart. In fact, you could run the test with two tabs in one window, then manually drag one tab off into it's own window and run it again and it should still work. Heck, it shouldn't even matter if you have OTHER tabs open (i.e. you could have an Amazon.Com page open and it should still find your pages and ignore the Amazon page.
Let me know if you need more info.
Upvotes: 2