0

Given a ProcessTestObject, is there a way to retrieve the window associated with that process as a BrowserTestObject or at least a TopLevelTestObject? E.g.

// Open IE at http://www.google.com/
ProcessTestObject browserProcess = startApp("Google");
// Wait for the browser to load...there's probably a better way, but I don't know it.
sleep(10);
// Now what?

The ProcessTestObject doesn't seem to have any children that I can use. I've tried

browserProcess.find(atDescendant(".class", "Html.HtmlBrowser"));

and

browserProcess.find(atDescendant(".class", "Html.HtmlDocument"));

but neither search yields any results. Trying to find specific HTML tags has failed as well.

I could search the RootTestObject for an HtmlBrowser and it'd probably work 98% of the time. However, I'd really prefer a way to guarantee that I'm grabbing the browser I just launched and not some stray window that may have been left open from a previous test. The only other alternative I can think of is to search for all browser windows and close them beforehand, but I figured there might be a simpler solution.

Doval
  • 2,516
  • 1
  • 22
  • 22

1 Answers1

2

Well closing the browsers and opening a new one is good idea because when the playback is looking for objects it will not have to search in the old browsers.

Another way to get the ProcessTestObject could be:

public void testMain(Object[] args) 
{
    ProcessTestObject pto = startBrowser("http://www.myurl.com");
    System.out.println("PTO "+ pto.getProcessId());
    TestObject[] browsers = find(atChild(".class", "Html.HtmlBrowser" ));
    for(TestObject browser:browsers)
    {
        if(pto.getProcessId() == browser.getProcess().getProcessId())
        {
            //we hv a match, use it 
            ((BrowserTestObject)browser).maximize();
        }

    }
    unregisterAll();    

}

//Note- for IE8 and above you will need to set a flag in ivory.properties file to true rational.test.ft.enablelcieprocessing=true

Prakash
  • 742
  • 7
  • 19
  • After changing the ivory.properties file and playing around with your solution, I've been getting inconsistent results. Sometimes startApp/startBrowser reports the correct processId, sometimes it doesn't. I came up with an alternative solution; rather than check for a browser with a processId matching the one returned by startApp, I check for one whose processId didn't exist before the startApp call. That should work correctly regardless of how RFT's configuration or startApp's behavior. – Doval Jul 16 '13 at 13:07
  • How about closing all the open browser windows before starting out a new browser? You may want to try both and see which one is more efficient. – Prakash Jul 18 '13 at 19:47
  • I'll probably end up closing the browsers as well, but I wanted something to fall back on. In theory attempting to close a browser window could fail; for example, if it brings up a dialog window asking if I'm sure I want to close multiple tabs. – Doval Jul 18 '13 at 23:54