Autoalerts not working for iOS by Appium in C#

Hi All,

I am trying to Automate my iOS app with Appium in C# , my application has a popup message which appears when the app i launched for first time after app is installed on the devie. I have tried setting the “AutoAcceptAlerts” capability:

var driverOption = new AppiumOptions();
driverOption.AddAdditionalCapability(MobileCapabilityType.PlatformName, “iOS”);
driverOption.AddAdditionalCapability(MobileCapabilityType.DeviceName, “iPhone XR”);
driverOption.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, “14.6”);

            driverOption.AddAdditionalCapability(MobileCapabilityType.App, appPath);
            driverOption.AddAdditionalCapability("autoAcceptAlerts", true);
            driverOption.AddAdditionalCapability("noReset", true);

But it does not seem to working i am getting Noalert present exception because the popup is displayed after some time when app is launched so i tried below code :slight_smile:

try
{
WebDriverWait wait = new WebDriverWait(_driver, IMPLICIT_TIMEOUT_SEC);

                wait.Until(ExpectedConditions.AlertIsPresent());
                IAlert alert = _driver.SwitchTo().Alert();
  
                alert.Accept();
            
            }
            catch (Exception e)
            {
                //exception handling
            } 

But still the alert is not cleared.
Please find attached Appium logs for more information.

Can anyone please help me with this?appiumlog.txt (2.7 KB)

Can anyone please help with this issue?

I’m going to take some time here to explain why I didn’t answer this question in the first place: I can’t figure out what you are talking about. You set autoAcceptAlerts to true but you are still getting alerts and then you post some half code and not even half a log. I’m not sure what you expect here, as far as I know, there aren’t any mind readers on this board. I’m certainly not one.

Here is a nice guide from the folks at StackOverflow on asking a good question. Could you go over this and ask your question again? Act like we don’t know anything about your app (we don’t). Act like we can’t see your code (we can’t). Explain your research and understand that you may have overlooked something, so posting a full log (using gist) would help. Here is the guide to asking questions:

https://stackoverflow.com/help/how-to-ask

Note: Nothing personal, I really would like to help you and I understand that Most people do not understand how to ask questions. Please help me to help you.

1 Like

Hi Wreed, Thank you for the detailed information on how to ask question, but apart from the Grammatical errors that you found in my post, what else you found missing? i have provided the part of the code where i have set the autoAcceptAlert capability of Appium to automatically clear iOS popups. Also as i have mentioned above, i have tried several code snippets to get it cleared like one mentioned above in the conversation but still no luck. I agree that i did not post the complete Appium logs as it would be too heavy file but i posted the Error that i was facing. Did you find anything in the logs that rings a bell?

I have tried to attach a new Appium log hope that helps to understand the issue. Appium_alert_log.txt (17.1 KB)

Ok, first thank you for posting the full log. I do see a lot of problems in there, and I’m going to try and cover them all, but first let me address the issue at hand: Why are your alerts not being accepted.

When I look at the first (truncated) log, I see this:

[XCUITest]\cf2 Executing command ‘getAlertText’
[debug] \cf3 [WD Proxy]\cf2 Matched ‘/alert/text’ to command name ‘getAlertText’
[debug] \cf3 [WD Proxy]\cf2 Proxying [GET /alert/text] to [GET http://127.0.0.1:8100/session/2A8493E7-71C7-459F-A1D4-B5B399F30F2A/alert/text] with no body
\cf3 [WD Proxy]\cf2 Got response with status 404: {“value”:{“error”:“no such alert”,“message”:“An attempt was made to operate on a modal dialog when one was not open”,“traceback”:“”},“sessionId”:“2A8493E7-71C7-459F-A1D4-B5B399F30F2A”}
[debug] \cf3 [W3C]\cf2 Matched W3C error code ‘no such alert’ to NoSuchAlertError\

What does the above mean? If read plainly it says that the test code attempted to get the /alert/text, but there was no alert present. Note that this error is NOT present in the second, more complete log.

Here are the reasons the error could not be handled:

  1. Timing issue. Code to handle alert is called before/after alert is present. In this case I would think it’s before.
  2. Pop up is not an alert. Not all pop ups are alerts. I would encourage you to take a look with Appium Inspector to see if element of type XCUIElementTypeAlert exists. If not, it’s not an alert and you will have to handle it with your code.
  3. Mistake in your code. This one is tough to judge as I can’t see your code. However, the log shows some problems so I will address those in the hope that you can improve it.
  4. Bug in Appium. While I think this is unlikely, if you really think so you should write a Short Self Contained Correct Example and share it. More on that concept here: http://www.sscce.org/

For the second, (more complete) log, the above issue is not present. In that log the failure is:

WebDriverAgent]\cf2 xcodebuild exited with code ‘65’ and signal ‘null’

This indicates a problem with signing the WebDriverAgent. This is outside the scope of handling alerts, so I encourage you to read and follow this tutorial:
https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md

Other advice:

  1. Your capabilities are inconsistent, at best. Why use MobileCapabilityType for only some capabilities but not others? Try to be consistent in your code if only to eliminate errors.
  2. You don’t include the capability, ‘automationName’. The log complains about this and states that in the future this will be required. Why not fix it now before it’s a problem?

Finally, I’m going to point you to 2 things:

  1. A couple of basic tutorials on automating with dot net: Mobile Automation with Appium in .NET - Setup and writing first test - Multiplatform App https://www.automatetheplanet.com/getting-started-appium-android-csharp/
  2. Another thread on iOS Alerts. We can all learn a lot from reading these: Unable to accept iOS permission alerts from appium automation code

I wish you good luck and I hope this helps.

Hi, Thank you for the help. I have tried updating my code to setup appium as below:
using System;
using Xunit;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.iOS;
using OpenQA.Selenium.Appium.Enums;
using Altom.AltUnityDriver;
using AppiumcSharp.pages;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium;
using By = OpenQA.Selenium.By;

namespace AppiumcSharp
{
public class AppTest1
{
private AppiumDriver _driver;
private AltUnityDriver altUnityDriver;
private static Uri testServerAddress = new Uri(“http://127.0.0.1:4723/wd/hub”); // If Appium is running locally
private static TimeSpan INIT_TIMEOUT_SEC = TimeSpan.FromSeconds(180); /* Change this to a more reasonable value /
private static TimeSpan IMPLICIT_TIMEOUT_SEC = TimeSpan.FromSeconds(10); /
Change this to a more reasonable value */

    [Fact]
    public void Test1()
       
    {
        try
        {
           
            var appPath = @"/Users/usename/Documents/projectfolder/IPA/Codename_xyz.ipa";
            var driverOption = new AppiumOptions();
            driverOption.AddAdditionalCapability(MobileCapabilityType.PlatformName, "iOS");
            driverOption.AddAdditionalCapability(MobileCapabilityType.AutomationName, "XCUItest");
            driverOption.AddAdditionalCapability(MobileCapabilityType.DeviceName, "iPhone XR");
            driverOption.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "14.6");
            driverOption.AddAdditionalCapability(MobileCapabilityType.Udid, "00004030-00XXXA91EEA104E");
            driverOption.AddAdditionalCapability(MobileCapabilityType.App, appPath);
  
            driverOption.AddAdditionalCapability(IOSMobileCapabilityType.AutoAcceptAlerts, "true");
            driverOption.AddAdditionalCapability(IOSMobileCapabilityType.AutoDismissAlerts, "true");
           driverOption.AddAdditionalCapability(IOSMobileCapabilityType.LaunchTimeout, INIT_TIMEOUT_SEC);
   

            _driver = new IOSDriver<IOSElement>(new Uri("http://127.0.0.1:4723/wd/hub"), driverOption);

            System.Threading.Thread.Sleep(5000);

            _driver.Manage().Timeouts().ImplicitWait = IMPLICIT_TIMEOUT_SEC;


            _driver.SwitchTo().Alert().Accept();
         }
        catch (Exception e)
        {
            System.Console.WriteLine(e);
            //exception handlin e
        }
    }
          [Fact]
    public void TearDown()
    {
        try
        {
            _driver.Close();
            _driver.Quit();
            altUnityDriver.Stop();
            AltUnityPortForwarding.KillAllIproxyProcess();
        }
        catch (Exception e)
        {
            System.Console.WriteLine(e);
        }
    }

}

}
But still not able to accept alerts and below is the complete Log from Appium server:
[Appium] Welcome to Appium v1.21.0

[Appium] Appium REST http interface listener started on 0.0.0.0:4723

[HTTP] --> POST /wd/hub/session

[HTTP] {“desiredCapabilities”:{“platformName”:“iOS”,“automationName”:“XCUItest”,“deviceName”:“iPhone XR”,“platformVersion”:“14.6”,“udid”:“00004030-001569A91EEXXXX”,“app”:"/Users/username/Documents/Project/IPA/Codename_Project.ipa",“autoAcceptAlerts”:“true”,“autoDismissAlerts”:“true”,“launchTimeout”:“00:03:00”},“capabilities”:{“firstMatch”:[{“platformName”:“iOS”}]}}

[debug] [W3C] Calling AppiumDriver.createSession() with args: [{“platformName”:“iOS”,“automationName”:“XCUItest”,“deviceName”:“iPhone XR”,“platformVersion”:“14.6”,“udid”:“00004030-001569A91EEXXXX”,“app”:"/Users/username/Documents/Project/IPA/Codename_Project.ipa",“autoAcceptAlerts”:“true”,“autoDismissAlerts”:“true”,“launchTimeout”:“00:03:00”},null,{“firstMatch”:[{“platformName”:“iOS”}]}]

[debug] [BaseDriver] Event ‘newSessionRequested’ logged at 1646647935299 (11:12:15 GMT+0100 (Central European Standard Time))

[Appium] The following capabilities were provided in the JSONWP desired capabilities that are missing in W3C capabilities: [“automationName”,“deviceName”,“platformVersion”,“udid”,“app”,“autoAcceptAlerts”,“autoDismissAlerts”,“launchTimeout”]

[Appium] Trying to fix W3C capabilities by merging them with JSONWP caps

[BaseDriver] The following capabilities are not standard capabilities and should have an extension prefix:

[BaseDriver] automationName

[BaseDriver] deviceName

[BaseDriver] platformVersion

[BaseDriver] udid

[BaseDriver] app

[BaseDriver] autoAcceptAlerts

[BaseDriver] autoDismissAlerts

[BaseDriver] launchTimeout

[Appium] Appium v1.21.0 creating new XCUITestDriver (v3.43.0) session

[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided

[debug] [BaseDriver] Creating session with W3C capabilities: {

[debug] [BaseDriver] “alwaysMatch”: {

[debug] [BaseDriver] “appium:automationName”: “XCUItest”,

[debug] [BaseDriver] “appium:deviceName”: “iPhone XR”,

[debug] [BaseDriver] “appium:platformVersion”: “14.6”,

[debug] [BaseDriver] “appium:udid”: “00004030-001569A91EEXXXX”,

[debug] [BaseDriver] “appium:app”: “/Users/username/Documents/Project/IPA/Codename_Project.ipa”,

[debug] [BaseDriver] “appium:autoAcceptAlerts”: “true”,

[debug] [BaseDriver] “appium:autoDismissAlerts”: “true”,

[debug] [BaseDriver] “appium:launchTimeout”: “00:03:00”,

[debug] [BaseDriver] “platformName”: “iOS”

[debug] [BaseDriver] },

[debug] [BaseDriver] “firstMatch”: [

[debug] [BaseDriver] {}

[debug] [BaseDriver] ]

[debug] [BaseDriver] }

[BaseDriver] Capability ‘autoAcceptAlerts’ changed from string to boolean. This may cause unexpected behavior

[BaseDriver] Capability ‘autoDismissAlerts’ changed from string to boolean. This may cause unexpected behavior

[BaseDriver] Session created with session id: ad50e616-2b1f-48b2-84ef-cb1334ada7a9

[debug] [XCUITest] Current user: ‘username’

[debug] [XCUITest] Available devices: 00004030-001569A91EEXXXX

[debug] [XCUITest] Creating iDevice object with udid ‘00004030-001569A91EEXXXX’

[XCUITest] Determining device to run tests on: udid: ‘00004030-001569A91EEXXXX’, real device: true

[debug] [BaseDriver] Event ‘xcodeDetailsRetrieved’ logged at 1646647936191 (11:12:16 GMT+0100 (Central European Standard Time))

[BaseDriver] Using local app ‘/Users/username/Documents/Project/IPA/Codename_Project.ipa’

[debug] [BaseDriver] Unzipping ‘/Users/username/Documents/Project/IPA/Codename_Project.ipa’

[debug] [BaseDriver] Enforcing UTF-8 encoding on the extracted file names for ‘Codename_Project.ipa’

[debug] [BaseDriver] Extracted 131 items from ‘/Users/username/Documents/Project/IPA/Codename_Project.ipa’ in 1546ms

[debug] [BaseDriver] Matched 1 item in the extracted archive. Assuming ‘Payload/worlds.app’ is the correct bundle

[BaseDriver] Unzipped local app to ‘/var/folders/k_/xbcp52_960j28t3tl1nqd0n89bndkr/T/202227-49847-153a7ro.yvjc/worlds.app’

[debug] [BaseDriver] Event ‘appConfigured’ logged at 1646647937996 (11:12:17 GMT+0100 (Central European Standard Time))

[debug] [XCUITest] Checking whether app ‘/var/folders/k_/xbcp52_960j28t3tl1nqd0n89bndkr/T/202227-49847-153a7ro.yvjc/worlds.app’ is actually present on file system

[debug] [XCUITest] App is present

[debug] [iOS] Getting bundle ID from app ‘/var/folders/k_/xbcp52_960j28t3tl1nqd0n89bndkr/T/202227-49847-153a7ro.yvjc/worlds.app’: ‘com.lego.cct.Projectworlds’

[debug] [BaseDriver] Event ‘resetStarted’ logged at 1646647937998 (11:12:17 GMT+0100 (Central European Standard Time))

[debug] [XCUITest] Reset: running ios real device reset flow

[debug] [BaseDriver] Event ‘resetComplete’ logged at 1646647937998 (11:12:17 GMT+0100 (Central European Standard Time))

[WebDriverAgent] Using WDA path: ‘/Users/username/.nvm/versions/node/v14.17.1/lib/node_modules/appium/node_modules/appium-webdriveragent’

[WebDriverAgent] Using WDA agent: ‘/Users/username/.nvm/versions/node/v14.17.1/lib/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj’

[debug] [XCUITest] Crash reports root ‘/Users/username/Library/Logs/CrashReporter/MobileDevice/Vikrant’s iPhone’ does not exist. Got nothing to gather.

[debug] [BaseDriver] Event ‘logCaptureStarted’ logged at 1646647938188 (11:12:18 GMT+0100 (Central European Standard Time))

[XCUITest] Setting up real device

[debug] [XCUITest] Verifying application platform

[debug] [XCUITest] CFBundleSupportedPlatforms: [“iPhoneOS”]

[debug] [XCUITest] Reset requested. Removing app with id ‘com.lego.cct.Projectworlds’ from the device

[debug] [XCUITest] Installing ‘/var/folders/k_/xbcp52_960j28t3tl1nqd0n89bndkr/T/202227-49847-153a7ro.yvjc/worlds.app’ on device with UUID ‘00004030-001569A91EEXXXX’…

[debug] [WebDriverAgent] Parsed BUILD_DIR configuration value: ‘/Users/username/Library/Developer/Xcode/DerivedData/WebDriverAgent-atayhgcubfmrncbcwuxvmxoqmwvs/Build/Products’

[debug] [WebDriverAgent] Got derived data root: ‘/Users/username/Library/Developer/Xcode/DerivedData/WebDriverAgent-atayhgcubfmrncbcwuxvmxoqmwvs’

[debug] [Support] Traversed 24 directories and 106 files in 16225ms

[debug] [XCUITest] Pushed the app files successfully after 16338ms

[XCUITest] App installation succeeded after 18703ms

[debug] [XCUITest] The app has been installed successfully.

[debug] [BaseDriver] Event ‘appInstalled’ logged at 1646647957319 (11:12:37 GMT+0100 (Central European Standard Time))

[debug] [WebDriverAgent] No obsolete cached processes from previous WDA sessions listening on port 8100 have been found

[DevCon Factory] Requesting connection for device 00004030-001569A91EEXXXX on local port 8100, device port 8100

[debug] [DevCon Factory] Cached connections count: 0

[DevCon Factory] Successfully requested the connection for 00004030-001569A91EEXXXX:8100

[debug] [XCUITest] Starting WebDriverAgent initialization with the synchronization key ‘/Users/username/Library/Developer/Xcode/DerivedData/WebDriverAgent-atayhgcubfmrncbcwuxvmxoqmwvs’

[debug] [WD Proxy] Matched ‘/status’ to command name ‘getStatus’

[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

[debug] [WD Proxy] Got response with status 200: {“value”:{“message”:“WebDriverAgent is ready to accept commands”,“state”:“success”,“os”:{“testmanagerdVersion”:28,“name”:“iOS”,“sdkVersion”:“15.2”,“version”:“15.3.1”},“ios”:{“ip”:“169.254.126.160”},“ready”:true,“build”:{“upgradedAt”:“1624977466951”,“time”:“Mar 5 2022 19:39:08”,“productBundleIdentifier”:“com.facebook.WebDriverAgentRunner”}},“sessionId”:“42315DE6-E5AE-4A89-A94F-DDBC71FBA4E4”}

[debug] [WebDriverAgent] Upgrade timestamp of the currently bundled WDA: 1624977466951

[debug] [WebDriverAgent] Upgrade timestamp of the WDA on the device: 1624977466951

[WebDriverAgent] Will reuse previously cached WDA instance at ‘http://127.0.0.1:8100/’ with ‘com.facebook.WebDriverAgentRunner’. Set the wdaLocalPort capability to a value different from 8100 if this is an undesired behavior.

[debug] [XCUITest] Trying to start WebDriverAgent 1 times with 10000ms interval

[debug] [XCUITest] These values can be customized by changing wdaStartupRetries/wdaStartupRetryInterval capabilities

[debug] [BaseDriver] Event ‘wdaStartAttempted’ logged at 1646647957452 (11:12:37 GMT+0100 (Central European Standard Time))

[WebDriverAgent] Using provided WebdriverAgent at ‘http://127.0.0.1:8100/

[debug] [WD Proxy] Matched ‘/status’ to command name ‘getStatus’

[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

[debug] [WD Proxy] Got response with status 200: {“value”:{“message”:“WebDriverAgent is ready to accept commands”,“state”:“success”,“os”:{“testmanagerdVersion”:28,“name”:“iOS”,“sdkVersion”:“15.2”,“version”:“15.3.1”},“ios”:{“ip”:“169.254.126.160”},“ready”:true,“build”:{“upgradedAt”:“1624977466951”,“time”:“Mar 5 2022 19:39:08”,“productBundleIdentifier”:“com.facebook.WebDriverAgentRunner”}},“sessionId”:“42315DE6-E5AE-4A89-A94F-DDBC71FBA4E4”}

[debug] [BaseDriver] Event ‘wdaSessionAttempted’ logged at 1646647957459 (11:12:37 GMT+0100 (Central European Standard Time))

[debug] [XCUITest] Sending createSession command to WDA

[debug] [WD Proxy] Matched ‘/session’ to command name ‘createSession’

[debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8100/session] with body: {“capabilities”:{“firstMatch”:[{“bundleId”:“com.lego.cct.Projectworlds”,“arguments”:[],“environment”:{},“eventloopIdleDelaySec”:0,“shouldWaitForQuiescence”:true,“shouldUseTestManagerForVisibilityDetection”:false,“maxTypingFrequency”:60,“shouldUseSingletonTestManager”:true,“shouldTerminateApp”:true,“defaultAlertAction”:“accept”}],“alwaysMatch”:{}}}

[debug] [WD Proxy] Got response with status 200: {“value”:{“sessionId”:“3E8D5B94-8DAA-46CF-B357-38BC02412E86”,“capabilities”:{“device”:“iphone”,“browserName”:" ",“sdkVersion”:“15.3.1”,“CFBundleIdentifier”:“com.apple.springboard”}},“sessionId”:“3E8D5B94-8DAA-46CF-B357-38BC02412E86”}

[WD Proxy] Determined the downstream protocol as ‘W3C’

[debug] [BaseDriver] Event ‘wdaSessionStarted’ logged at 1646647964518 (11:12:44 GMT+0100 (Central European Standard Time))

[debug] [BaseDriver] Event ‘wdaStarted’ logged at 1646647964518 (11:12:44 GMT+0100 (Central European Standard Time))

[XCUITest] Skipping setting of the initial display orientation. Set the “orientation” capability to either “LANDSCAPE” or “PORTRAIT”, if this is an undesired behavior.

[debug] [BaseDriver] Event ‘orientationSet’ logged at 1646647964519 (11:12:44 GMT+0100 (Central European Standard Time))

[debug] [BaseDriver] The value of ‘elementResponseAttributes’ setting did not change. Skipping the update for it

[debug] [BaseDriver] The value of ‘shouldUseCompactResponses’ setting did not change. Skipping the update for it

[Appium] New XCUITestDriver session created successfully, session ad50e616-2b1f-48b2-84ef-cb1334ada7a9 added to master session list

[debug] [BaseDriver] Event ‘newSessionStarted’ logged at 1646647964520 (11:12:44 GMT+0100 (Central European Standard Time))

[debug] [W3C (ad50e616)] Cached the protocol value ‘W3C’ for the new session ad50e616-2b1f-48b2-84ef-cb1334ada7a9

[debug] [W3C (ad50e616)] Responding to client with driver.createSession() result: {“capabilities”:{“webStorageEnabled”:false,“locationContextEnabled”:false,“browserName”:"",“platform”:“MAC”,“javascriptEnabled”:true,“databaseEnabled”:false,“takesScreenshot”:true,“networkConnectionEnabled”:false,“platformName”:“iOS”,“automationName”:“XCUItest”,“deviceName”:“iPhone XR”,“platformVersion”:“14.6”,“udid”:“00004030-001569A91EEXXXX”,“app”:"/Users/username/Documents/Project/IPA/Codename_Project.ipa",“autoAcceptAlerts”:true,“autoDismissAlerts”:true,“launchTimeout”:“00:03:00”}}

[HTTP] <-- POST /wd/hub/session 200 29226 ms - 548

[HTTP]

[HTTP] --> POST /wd/hub/session/ad50e616-2b1f-48b2-84ef-cb1334ada7a9/timeouts

[HTTP] {“implicit”:10000}

[debug] [W3C (ad50e616)] Calling AppiumDriver.timeouts() with args: [null,null,null,null,10000,“ad50e616-2b1f-48b2-84ef-cb1334ada7a9”]

[debug] [XCUITest] Executing command ‘timeouts’

[debug] [BaseDriver] W3C timeout argument: {“implicit”:10000}}

[debug] [BaseDriver] Set implicit wait to 10000ms

[debug] [W3C (ad50e616)] Responding to client with driver.timeouts() result: null

[HTTP] <-- POST /wd/hub/session/ad50e616-2b1f-48b2-84ef-cb1334ada7a9/timeouts 200 4 ms - 14

[HTTP]

[HTTP] --> GET /wd/hub/session/ad50e616-2b1f-48b2-84ef-cb1334ada7a9/alert/text

[HTTP] {}

[debug] [W3C (ad50e616)] Calling AppiumDriver.getAlertText() with args: [“ad50e616-2b1f-48b2-84ef-cb1334ada7a9”]

[debug] [XCUITest] Executing command ‘getAlertText’

[debug] [WD Proxy] Matched ‘/alert/text’ to command name ‘getAlertText’

[debug] [WD Proxy] Proxying [GET /alert/text] to [GET http://127.0.0.1:8100/session/3E8D5B94-8DAA-46CF-B357-38BC02412E86/alert/text] with no body

[debug] [iProxy@00008030:8100] Connection was refused to port 8100

[WD Proxy] socket hang up

[debug] [W3C (ad50e616)] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up

[debug] [W3C (ad50e616)] at JWProxy.command (/Users/username/.nvm/versions/node/v14.17.1/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:274:13)

[debug] [W3C (ad50e616)] at runMicrotasks ()

[debug] [W3C (ad50e616)] at processTicksAndRejections (internal/process/task_queues.js:95:5)

[debug] [W3C (ad50e616)] at XCUITestDriver.proxyCommand (/Users/username/.nvm/versions/node/v14.17.1/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/commands/proxy-helper.js:96:12)

[debug] [W3C (ad50e616)] at XCUITestDriver.getAlertText (/Users/username/.nvm/versions/node/v14.17.1/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/commands/alert.js:12:10)

[HTTP] <-- GET /wd/hub/session/ad50e616-2b1f-48b2-84ef-cb1334ada7a9/alert/text 500 44 ms - 1013

[HTTP]

I got this working by upgrading to Appium version 1.22.2 and making some changes to Capabilities:

driverOption.AddAdditionalCapability(MobileCapabilityType.AutomationName, “appium”);
driverOption.AddAdditionalCapability(IOSMobileCapabilityType.AutoAcceptAlerts, true);
driverOption.AddAdditionalCapability(IOSMobileCapabilityType.AutoDismissAlerts, true);

apart from doing this i also tried to reinstall webdriverAgent runner on my mobile Device.

Couple things about this:

  1. I don’t think you should tell Appium to BOTH accept AND dismiss all alerts. It can only be one or the other. You are going to crash a computer by telling it both ‘true’ and ‘false’.
  2. I don’t know if you bother to read the logs before you post them, but there is a difference between “true” and true. One is a string, the other is a boolean. When the log says, “Capability ‘autoAcceptAlerts’ changed from string to boolean. This may cause unexpected behavior”, and then you get unexpected behavior, you should probably pay attention: Boolean data type - Wikipedia

We can see that there is an alert, and that Appium is trying to get it’s text, then it crashes. Does it crash because it’s getting conflicting instructions to both accept and dismiss? Can’t tell exactly from the log, but it’s a definite possibility. Or it could be:

Why are you doing this? You’ve told Appium to handle the alerts and then you are handling them in your code. You should tell Appium to handle it, OR you should handle it in code. Do you understand why you can’t do both? This is never going to work so just remove it.

Finally, have you tested this thoroughly? I think you should actually get a test to run before mucking around with timeouts. It seems like you are doing a refactor before you’ve finished coding. My best advice to you would be to get this running with as many default settings as you can, and then you can tune the code for better performance once things are working. By doing this you are adding unnecessary complexity to the problem. Please use the KISS principle. It really works: KISS principle - Wikipedia