Handling ambiguous recognition
In some situations during playback, HCL OneTest™ UI 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, HCL OneTest™ UI 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 READY. For HTML components LOADING and UNINITIALIZED are also possible. The default state for Java™ objects is SHOWING and ENABLED. Other supported state flags 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:
TestObject BrowserOne = Browser_htmlBrowser(Document_MyHomePage(),
DEFAULT).Find()
TestObject
when you are
done.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() REM (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.