System Dialog handling with Appium 1.7.1 and Xcode 9

Hello All,

I am trying to handle the system dialogs for allowing notifications to iOS mobile. The application is a mobile app. The versions that I am using:

  • appium : 1.7.1
  • XCode - Xcode 9
    What I have tried:
    Setting the capability “autoAcceptAlerts : true”

The one which works with Xcode 8.3 and appium 1.6.4 is:
await this.driver.elementByAccessibilityId(‘Allow’).click() --> This does not work with Xcode 9 and appium 1.7.1

But we need to upgrade to latest versions of Appium and Xcode. So I would request if someone could help me out with on how to handle system alerts with the latest versions of appium and Xcode?

did you tried using

driver.switchTo().alert() ;

before clicking on button.

Hello kumarsiva,

I am trying to do that actually but I am getting the error that switchTo() is not a function of driver. I think it is an issue with the framework setup.
This is a native app that I am testing, do you think that has anything to do with the “SwitchTo()” not working?

Yes it could be, Actually that method comes from RemoteWebDriver. If you are not inheriting your IOSdriver from RemoteWebdriver then you wont get this function.

for more understanding on different drivers you can go through this post.

@kumarsiva Thank you for the link, I shall go through the same.
By the first looks of it I think the framework is referring to AppiumDriver as driver. Actually just started understanding the framework which was already built in for testing.I shall get back once I am sure on the driver reference.

@kumarsiva This is the line which sets the driver for the project presently:
driver = wd.promiseChainRemote(getServerConfig())
This seems to point to appium driver as mentioned in the code in comments. Can you please correct me if I am wrong.
If it is the appium driver then how can I change this to iOSDriver?

getServerConfig is just to set the capabilities etc for server.