Is it possible to change device capabilities after mobile driver has been started?

Scenario:

Katalon doesn’t appear to be able to see some of the native iOS alerts so I set the device capability.

capabilities.setCapability("autoDismissAlerts", true);

This will dismiss all native alerts which is great except one thing. When I go to logout of the app the alert is dismissed when I want to click the ‘YES’ button to logout and the test fails when the ‘YES’ button is not found.

Is it possible to change the autoDismissAlerts capability at this point to false just so the ‘YES’ button will be clickable instead of being dismissed?

Thank you!

Hi @JTConstellation ,

Can you please share the error log about this? I guess you should not use autoDismissAlerts then try to crack it in specific cases (i.e. YES buttom) later in the test.

hi @JTConstellation

autoDismissAlerts is a session capability, it cannot be flipped once the session is up. what you can do is drop it and handle the alerts yourself, xcuitest exposes them even when they are not in the page source:

import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory

def driver = MobileDriverFactory.getDriver()
// dismiss whatever is showing
driver.executeScript('mobile: alert', [action: 'dismiss'])
// or press a specific button
driver.executeScript('mobile: alert', [action: 'accept', buttonLabel: 'YES'])
// see what buttons the alert has
println driver.executeScript('mobile: alert', [action: 'getButtons'])

plain driver.switchTo().alert().accept() works too for simple ok/cancel ones. wrap the dismiss in a try/catch (it throws when no alert is showing) and call it where you used to rely on the auto dismiss, then at logout you call accept with YES and the test continues.