문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top