SeeTestAutomation- Using Mobile Listeners In Java
Please note that this tool is classified as a Legacy tool. We recommend transitioning to our updated solutions to maintain optimal performance and security in your workflows. For more information on this matter, please reach out to technical support .
It will enable you to ‘Handle’ unexpected UI interrupts without compromising the test execution speed.
Once you register a ‘MobileListener’ you will get notified when the event register for is found.
You can then handle the event and return the recover status as true (indicating that the recovery was successful).
// in case of incoming call during a test the call will be rejected and will
// not affect the test
client.addMobileListener("NATIVE", "xpath=//*[@text='Incoming call']",
new MobileListener() {
@Override
public boolean recover(String type, String xpath) {
client.click("NATIVE", "xpath=//*[@text='Decline']", 0, 1);
return true;
}
}
);
In this example we are handling an incoming call by clicking on the decline button. We can now call the device during tests execution. Doing that will identify that the incoming call will be declined without affecting the test itself.
To disable the mobile listener, call it without a nul MobileListener.
client.addMobileListener("NATIVE", "xpath=//*[@text='Incoming call']", null);