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]