示例#1
0
        public static void StartApp(UITestConfiguration testConfig)
        {
            if (testConfig is null)
            {
                throw new ArgumentNullException(nameof(testConfig));
            }

            _testConfig = testConfig;

            if (string.IsNullOrEmpty(testConfig.ScreenshotsPath))
            {
                testConfig.ScreenshotsPath = "Screenshots";
            }

            if (testConfig.AppiumServer is null)
            {
                testConfig.AppiumServer = UITestDefaults.DefaultAppiumServer;
            }

            if (testConfig.Platform != Platform.Android && testConfig.Platform != Platform.iOS)
            {
                testConfig.Platform = Platform.iOS;
            }

            if (!Directory.Exists(testConfig.ScreenshotsPath))
            {
                Directory.CreateDirectory(testConfig.ScreenshotsPath);
            }

            if ((!Directory.Exists(testConfig.AppPath) && testConfig.Platform == Platform.iOS) ||
                (!File.Exists(testConfig.AppPath) && testConfig.Platform == Platform.Android))
            {
                throw new FileNotFoundException($"The App Package could not be found at the specified location. '{testConfig.AppPath}'");
            }

            _engine = testConfig.Platform switch
            {
                Platform.NotSet => throw new NotSupportedException("The platform has not been set in the test config. You must select a valid platform"),
                      Platform.Android => new AndroidXappiumTestEngine(testConfig),
                      Platform.iOS => IsRunningOnMac ? new iOSXappiumTestEngine(testConfig) : throw new PlatformNotSupportedException("iOS is only supported while running on a Mac host"),
                            _ => throw new PlatformNotSupportedException($"The selected platform {testConfig.Platform} is not currently implemented"),
            };
        }
示例#2
0
 internal static void AppStopped()
 {
     _testConfig = null;
     _engine     = null;
 }
 public iOSXappiumTestEngine(UITestConfiguration config)
     : base(config)
 {
 }
        protected override IOSDriver <IOSElement> CreateDriver(AppiumOptions options, UITestConfiguration config)
        {
            // The value of DEVICE_NAME is only used for running on the iOS simulator,
            // but must also have some (any) value for iOS and Android physical devices
            AddAdditionalCapability(options, MobileCapabilityType.DeviceName, config.DeviceName);
            if (!string.IsNullOrWhiteSpace(config.AppPath))
            {
                AddAdditionalCapability(options, MobileCapabilityType.App, config.AppPath);
            }
            AddAdditionalCapability(options, MobileCapabilityType.PlatformName, "iOS");
            AddAdditionalCapability(options, MobileCapabilityType.AutomationName, "XCUITest");
            AddAdditionalCapability(options, "autoAcceptAlerts", true);
            AddAdditionalCapability(options, "isHeadless", true);

            return(new IOSDriver <IOSElement>(config.AppiumServer, options, TimeSpan.FromSeconds(90)));
        }
示例#5
0
        protected override IOSDriver <IOSElement> CreateDriver(AppiumOptions options, UITestConfiguration config)
        {
            // The value of DEVICE_NAME is only used for running on the iOS simulator,
            // but must also have some (any) value for iOS and Android physical devices
            AddAdditionalCapability(options, MobileCapabilityType.DeviceName, config.DeviceName);
            if (!string.IsNullOrWhiteSpace(config.AppPath))
            {
                AddAdditionalCapability(options, MobileCapabilityType.App, config.AppPath);
            }
            AddAdditionalCapability(options, MobileCapabilityType.PlatformName, "iOS");
            AddAdditionalCapability(options, MobileCapabilityType.PlatformVersion, config.OSVersion);
            AddAdditionalCapability(options, MobileCapabilityType.AutomationName, "XCUITest");
            AddAdditionalCapability(options, "autoAcceptAlerts", true);
            AddAdditionalCapability(options, "isHeadless", true);
            AddAdditionalCapability(options, IOSMobileCapabilityType.LaunchTimeout, 90000);
            AddAdditionalCapability(options, "appium:screenshotQuality", 2);
            AddAdditionalCapability(options, "appium:showIOSLog", true);
            AddAdditionalCapability(options, "showXcodeLog", true);
            AddAdditionalCapability(options, "deviceReadyTimeout", 30);

            // https://github.com/appium/appium/issues/12094#issuecomment-482593020
            AddAdditionalCapability(options, "wdaStartupRetries", "8");
            AddAdditionalCapability(options, "iosInstallPause", "15000");
            AddAdditionalCapability(options, "wdaStartupRetryInterval", "45000");

            return(new IOSDriver <IOSElement>(config.AppiumServer, options));
        }
示例#6
0
 protected abstract T CreateDriver(AppiumOptions options, UITestConfiguration config);
示例#7
0
 protected XappiumTestEngineBase(UITestConfiguration config)
 {
     _config = config;
     SetupDriver();
 }
        protected override AndroidDriver <AndroidElement> CreateDriver(AppiumOptions options, UITestConfiguration config)
        {
            if (!string.IsNullOrWhiteSpace(config.AppPath))
            {
                var apkFileInfo = new FileInfo(config.AppPath);
                if (apkFileInfo.Exists)
                {
                    options.AddAdditionalCapability(MobileCapabilityType.App, apkFileInfo.FullName);
                }
            }

            AddAdditionalCapability(options, MobileCapabilityType.PlatformName, "Android");
            //options.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android Emulator");
            AddAdditionalCapability(options, MobileCapabilityType.DeviceName, config.DeviceName);
            AddAdditionalCapability(options, MobileCapabilityType.Udid, config.UDID);
            AddAdditionalCapability(options, "forceEspressoRebuild", true);
            AddAdditionalCapability(options, MobileCapabilityType.AutomationName, "Espresso");
            AddAdditionalCapability(options, "enforceAppInstall", true);

            return(new AndroidDriver <AndroidElement>(config.AppiumServer, options, TimeSpan.FromSeconds(90)));
        }
 public AndroidXappiumTestEngine(UITestConfiguration config)
     : base(config)
 {
 }