/// <summary> /// /// </summary> /// <param name="deviceTarget"></param> /// <param name="packagePath">Mobile applpication package path</param> /// <param name="appiumHost">Host name/ip address of appium service</param> /// <param name="appiumPort">Appium service port</param> /// <param name="aaptExePath">Path of aapt.exe file</param> public AppiumMetaPilot(DeviceTarget deviceTarget, string packagePath, string appiumHost, int appiumPort, string aaptExePath) : this(deviceTarget, packagePath, new Uri($"http://{appiumHost}:{appiumPort}/wd/hub"), aaptExePath) { }
public AppiumMetaPilot(DeviceTarget deviceTarget, string packagePath, Uri appiumServerUri, string aaptExePath) { _deviceTarget = deviceTarget; _packagePath = packagePath; _appiumServerUri = appiumServerUri; _aaptExePath = aaptExePath; _installedPackageName = ""; UnInstallOnDriverQuit = true; AppiumDriver = null; Console.WriteLine($"Start AppiumPilot deviceTarget:{deviceTarget} package:{packagePath}"); if (deviceTarget.Platform == DevicePlatform.Other) { return; } try { if (!IsUp()) { Console.WriteLine("Appium is not running !"); return; } //TODO ADD IMPLEMENTATION FOR iOS EMULATOR + REAL devices if (!deviceTarget.IsRealDevice && deviceTarget.Platform == DevicePlatform.Android) { try { var androidDriverBuilder = new AndroidDriverBuilder(); AppiumDriver = androidDriverBuilder .DeviceTarget(deviceTarget) .AaptExePath(aaptExePath) .AppiumUri(appiumServerUri) .CommandTimeout(CommandTimeout) .PackagePath(packagePath) .Build(); _installedPackageName = androidDriverBuilder.InstalledPackageName; AppiumDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); Thread.Sleep(10 * 1000); } catch (Exception e) { Console.WriteLine("Error launching device : " + e.Message); return; } } else if (!deviceTarget.IsRealDevice && deviceTarget.Platform == DevicePlatform.IOs) { try { var iosDriverBuilder = new IosDriverBuilder(); AppiumDriver = iosDriverBuilder .DeviceTarget(deviceTarget) .AppiumUri(appiumServerUri) .CommandTimeout(CommandTimeout) .PackagePath(packagePath) .Build(); AppiumDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); //ugly, wait for derbier warmup Thread.Sleep(10 * 1000); } catch (Exception e) { Console.WriteLine("Error launching device : " + e.Message); return; } } else { AppiumDriver = null; } } catch (Exception e) { Console.WriteLine("An error occured : " + e); AppiumDriver = null; } }
public bool StartDevice(DeviceTarget deviceTarget, string packagePath, string appiumHost, int appiumPort, string aaptPath) { _appiumMetaPilot = new AppiumMetaPilot(deviceTarget, packagePath, appiumHost, appiumPort, aaptPath); return(!(_appiumMetaPilot == null || (_appiumMetaPilot != null && _appiumMetaPilot.AppiumDriver == null))); }