Start your demo and save on the first 12 months!

Blog

Get Instance

Posted by on 2 June 2020 in Blog, Tips

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?