Handling Unexpected Pop-ups on Mobile

There’s a nice discussion on handling unexpected pop-ups for Web automation, but is there information about handling them on Mobile?

I often have to dismiss the prompts for Android updates. There are pop-ups when other applications crash, or the system (Android or carrier) prompts for some reminder or added feature.

Thank you,
David

Yes. You can try it with a custom keyword or a test listener. Both works.
I do prefer the test listener.

My TestListener looks like this:

class DismissAlertXY{

@BeforeTestCase
@AfterTestCase
def isAlertXYPresent(){
	TestObject to = findTestObject('Object Repository/Alert_FailureXY/XCUIElementTypeButton - XY')
	int timeout = 5
	
	try {
		KeywordUtil.logInfo("Finding element with value 'XY':" + to.findPropertyValue('XY'))

		WebElement element = MobileElementCommonHelper.findElement(to, timeout)
		if (element != null) {
			Mobile.takeScreenshot() /
			KeywordUtil.markPassed("Object " + to.findPropertyValue('XY') + " is present")
			MobileElementCommonHelper.tapAndHold(to, 1, 1)
			if (element == null) {
				KeywordUtil.logInfo(("Object " + to.findPropertyValue('XY') + " was closed"))
			}
		}
	
	} catch (Exception e) {
		KeywordUtil.markPassed("Object " + to.findPropertyValue('XY') + " is not present")
	}
}

}