Get Instance
Using The Maveryx Test Automation Framework sometimes you could encounter the βmultiple objects found errorβ. This error occurs when the intelligent Maveryx search and recognition engine is not able to distinguish between two or more objects. This may happen if the AUTβs (Application Under Test) UI has two or more identical objects in the same container with no other info to discern which is the right one.
Imagine, for example, a frame with some text areas and some βbrowseβ buttons associated. Asking Maveryx to click on one of these buttons will let fail the test because of the βmultiple objects found errorβ.
In a case like this, even a manual tester will have problems. The only way to let the tester discerning which object is the correct one is giving her at least the information about its position respect the others: the first, the second, the last, etcβ¦
It is possible to do the same with Maveryx by using the function getInstance(int position) by specifying the value of the βpositionβ.
In the following test script, we are going to test a very easy AUT with 5 text areas and 5 associated βbrowseβ buttons. In this case, we want to click on the first button.
/**
* This Test Case provides an example of managing multiple instances of the same objects by the relavant Maveryx APIs.
* @throws Exception
*/
@Test
public void clickTheFirst() throws Exception {
//the button to test
GuiButton button = new GuiButton(βBrowseβ);
button.getInstance(0).click(); //click the first button
GuiLabel message = new GuiLabel(βmessageβ);
assertEquals(βYou pressed the first Browse button!β, message.getText()); //check expected message has been displayed
}
Alternatively, we can write the test through a codeless approach based on keywords.
In the following xls file we wrote the same automated test script by using the Maveryx keywords.
In both the executions, the Maveryx Test Automation Framework successfully located at runtime the right βBrowseβ button and clicked on it.
Have you encountered a problem like this in your test automation experience? In case, how did you fixed it?