Handling ambiguous recognition
In some situations during playback, Functional Tester might not be able to differentiate between two like objects in the software under test. This topic describes handling these situations.
For example, in HTML applications when more than one instance of a browser is active, recognizing one browser from another on toolbar actions would be impossible if they were recorded like these examples:BrowserToolbar_Back().click() BrowserToolbar_Forward().click()
In cases like this, Functional Tester avoids ambiguous recognition by locating the toolbar button in the browser that is identified by its currently loaded document (referred to as an anchor for the target object). For example:BrowserToolbar_Back(Browser_htmlBrowser(Document_MyHomePage(), DEFAULT), DEFAULT).click();
The toolbar back button is anchored by the browser, which is anchored by the document "My HomePage". This example would not work, of course, if each instance of the browser has the same loaded document. Note that the helper script methods that take an anchor as an argument also require another argument that specifies the component's state (the DEFAULT argument in the example above). The default state for HTML objects is LOADED. For HTML components LOADING and UNINITIATED are also possible. The default state for Java objects is SHOWING and ENABLED. Other supported state flags for Java objects are NOT_SHOWING and DISABLED.
In addition, you can identify the browser instance by using a TestObject reference for it, invoking the find method on the browser as follows (remember to unregister the TestObject when you are done).:TestObject browserOne = Browser_htmlBrowser(Document_MyHomePage(), DEFAULT).find();
The browser toolbar commands in the test script would look like this example:BrowserToolbar_Back(myBrowser, DEFAULT).click();
Another situation where ambiguous recognition can be an issue is when a test has more than one application running at the same time. During playback, commands like b5().click() are ambiguous. Because the startApp command returns a ProcessTestObject, this reference can be used to specify which application a particular command applies to. For example:ProcessTestObject p1 = startApp("SwingTest"); ProcessTestObject p2 = startApp("TryIt"); ... //b5().click(); ambiguous on playback; which application? b5(p1, DEFAULT).click();
In the last line of the example, the ProcessTestObject functions as an anchor to locate the desired application. Note that calling the unregister method for a ProcessTestObject is unnecessary.