Unable to click "OK" on alert box IOS using Appium 1.21.0

I’m writing a test using Java & Appium 1.21.0. I’m unable to click “OK” button on alert box to close the popup on the Simulator iPhone.

I tried the following code:

Actions action = new Actions(getDriver());

The above code is not working.

Using the following:

  • Appium 1.21.0
  • Xcode 14.0.1 - running simulator iPhone 8