public void CheckAbilityToStartServiceUsingCapabilitiesAndFlags()
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();

            capabilities.SetCapability(MobileCapabilityType.PlatformName, "Android");
            capabilities.SetCapability(MobileCapabilityType.FullReset, true);
            capabilities.SetCapability(MobileCapabilityType.NewCommandTimeout, 60);
            capabilities.SetCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
            capabilities.SetCapability(AndroidMobileCapabilityType.AppActivity, ".view.WebView1");

            OptionCollector args = new OptionCollector().AddCapabilities(capabilities)
                                   .AddArguments(GeneralOptionList.CallbackAddress(testIP))
                                   .AddArguments(GeneralOptionList.OverrideSession());
            AppiumLocalService service = null;

            try
            {
                service = new AppiumServiceBuilder().WithArguments(args).Build();
                service.Start();
                Assert.IsTrue(service.IsRunning);
            }
            finally
            {
                if (service != null)
                {
                    service.Dispose();
                }
            }
        }
        private AndroidDriver <AppiumWebElement> StartApp()
        {
            System.Environment.SetEnvironmentVariable("ANDROID_HOME", @"C:\Users\marko\AppData\Local\Android\Sdk");
            System.Environment.SetEnvironmentVariable("JAVA_HOME", @"C:\Program Files\Java\jdk1.8.0_161\");

            var cappabilities = new AppiumOptions();

            cappabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "52003b08eae92517");
            cappabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, "UiAutomator2");

            var currentPath = Directory.GetCurrentDirectory();

            Console.WriteLine($"Current path: {currentPath}");
            var packagePath = Path.Combine(currentPath, @"..\..\..\TestApp\Interval Timer_v2.2.2_apkpure.com.apk");

            packagePath = Path.GetFullPath(packagePath);
            Console.WriteLine($"package path: {packagePath}");
            cappabilities.AddAdditionalCapability(MobileCapabilityType.App, packagePath);

            cappabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "cc.dreamspark.intervaltimer");
            cappabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".MainActivity");

            var serveroptions        = new OptionCollector();
            var relaxeSecurityOption = new KeyValuePair <string, string>("--relaxed-security", "");

            serveroptions.AddArguments(relaxeSecurityOption);
            var _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().WithArguments(serveroptions).Build();

            _appiumLocalService.Start();
            var driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, cappabilities);

            return(driver);
        }
        public void CheckAbilityToBuildServiceWithDefinedParametersAndExternallyDefinedNode()
        {
            OptionCollector args = new OptionCollector().AddArguments(GeneralOptionList.OverrideSession());

            new AppiumServiceBuilder().WithAppiumJS(new FileInfo(PathToCustomizedAppiumJS)).
            UsingPort(4000).WithArguments(args).Build();
        }
Esempio n. 4
0
        public void StartingAndroidAppWithCapabilitiesOnTheServerSideTest()
        {
            var app = Apps.Get("androidApiDemos");

            var serverCapabilities = Env.ServerIsRemote()
                ? Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos"))
                : Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos"));

            var clientCapabilities = new AppiumOptions();

            clientCapabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
            clientCapabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".view.WebView1");

            var argCollector = new OptionCollector().AddCapabilities(serverCapabilities);
            var builder      = new AppiumServiceBuilder().WithArguments(argCollector);

            AndroidDriver <AppiumWebElement> driver = null;

            try
            {
                driver = new AndroidDriver <AppiumWebElement>(builder, clientCapabilities);
                driver.CloseApp();
            }
            finally
            {
                driver?.Quit();
            }
        }
        public void StartingAndroidAppWithCapabilitiesAndServiceTest()
        {
            string app = Apps.get("androidApiDemos");

            DesiredCapabilities capabilities = new DesiredCapabilities();

            capabilities.SetCapability(MobileCapabilityType.DeviceName, "Android Emulator");

            OptionCollector argCollector = new OptionCollector().AddArguments(GeneralOptionList.App(app))
                                           .AddArguments(GeneralOptionList.AutomationName(AutomationName.Appium));
            AppiumServiceBuilder builder = new AppiumServiceBuilder().WithArguments(argCollector);

            AndroidDriver <AppiumWebElement> driver = null;

            try
            {
                driver = new AndroidDriver <AppiumWebElement>(builder, capabilities);
                driver.CloseApp();
            }
            finally
            {
                if (driver != null)
                {
                    driver.Quit();
                }
            }
        }
        public void StartingIOSAppWithCapabilitiesAndServiseTest()
        {
            string app = Apps.get("iosTestApp");

            DesiredCapabilities capabilities = new DesiredCapabilities();

            capabilities.SetCapability(MobileCapabilityType.DeviceName, "iPhone Simulator");

            OptionCollector argCollector = new OptionCollector().AddArguments(GeneralOptionList.App(app))
                                           .AddArguments(GeneralOptionList.AutomationName(AutomationName.Appium)).
                                           AddArguments(GeneralOptionList.PlatformVersion("8.2"));

            AppiumServiceBuilder         builder = new AppiumServiceBuilder().WithArguments(argCollector);
            IOSDriver <AppiumWebElement> driver  = null;

            try
            {
                driver = new IOSDriver <AppiumWebElement>(builder, capabilities, Env.INIT_TIMEOUT_SEC);
                driver.CloseApp();
            }
            finally
            {
                if (driver != null)
                {
                    driver.Quit();
                }
            }
        }
        public void StartingAndroidAppWithCapabilitiesOnTheServerSideTest()
        {
            string app = Apps.get("androidApiDemos");

            DesiredCapabilities serverCapabilities = Env.isSauce() ?
                                                     Caps.getAndroid501Caps(Apps.get("androidApiDemos")) :
                                                     Caps.getAndroid19Caps(Apps.get("androidApiDemos"));

            DesiredCapabilities clientCapabilities = new DesiredCapabilities();

            clientCapabilities.SetCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
            clientCapabilities.SetCapability(AndroidMobileCapabilityType.AppActivity, ".view.WebView1");

            OptionCollector      argCollector = new OptionCollector().AddCapabilities(serverCapabilities);
            AppiumServiceBuilder builder      = new AppiumServiceBuilder().WithArguments(argCollector);

            AndroidDriver <AppiumWebElement> driver = null;

            try
            {
                driver = new AndroidDriver <AppiumWebElement>(builder, clientCapabilities);
                driver.CloseApp();
            }
            finally
            {
                if (driver != null)
                {
                    driver.Quit();
                }
            }
        }
        public void StartingIOSAppWithCapabilitiesAndServiseTest()
        {
            string app = Apps.get("iosTestApp");
            DesiredCapabilities capabilities =
                Caps.getIos92Caps(app);

            OptionCollector argCollector = new OptionCollector()
                                           .AddArguments(GeneralOptionList.OverrideSession()).AddArguments(GeneralOptionList.StrictCaps());

            AppiumServiceBuilder         builder = new AppiumServiceBuilder().WithArguments(argCollector);
            IOSDriver <AppiumWebElement> driver  = null;

            try
            {
                driver = new IOSDriver <AppiumWebElement>(builder, capabilities, Env.INIT_TIMEOUT_SEC);
                driver.CloseApp();
            }
            finally
            {
                if (driver != null)
                {
                    driver.Quit();
                }
            }
        }
        public void StartingAndroidAppWithCapabilitiesAndServiceTest()
        {
            DesiredCapabilities capabilities = Env.isSauce() ?
                                               Caps.getAndroid501Caps(Apps.get("androidApiDemos")) :
                                               Caps.getAndroid19Caps(Apps.get("androidApiDemos"));


            OptionCollector argCollector = new OptionCollector()
                                           .AddArguments(GeneralOptionList.OverrideSession()).AddArguments(GeneralOptionList.StrictCaps());
            AppiumServiceBuilder builder = new AppiumServiceBuilder().WithArguments(argCollector);

            AndroidDriver <AppiumWebElement> driver = null;

            try
            {
                driver = new AndroidDriver <AppiumWebElement>(builder, capabilities);
                driver.CloseApp();
            }
            finally
            {
                if (driver != null)
                {
                    driver.Quit();
                }
            }
        }
        public void CheckAbilityToStartServiceUsingCapabilities()
        {
            AppiumOptions capabilities = new AppiumOptions();

            capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            capabilities.AddAdditionalCapability(MobileCapabilityType.FullReset, true);
            capabilities.AddAdditionalCapability(MobileCapabilityType.NewCommandTimeout, 60);
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".view.WebView1");

            OptionCollector    args    = new OptionCollector().AddCapabilities(capabilities);
            AppiumLocalService service = null;

            try
            {
                service = new AppiumServiceBuilder().WithArguments(args).Build();
                service.Start();
                Assert.IsTrue(service.IsRunning);
            }
            finally
            {
                if (service != null)
                {
                    service.Dispose();
                }
            }
        }
Esempio n. 11
0
 public static void StartAppiumLocalService()
 {
     if (_shouldStartAppiumLocalService)
     {
         var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());
         WrappedAppiumCreateService.AppiumLocalService = new AppiumServiceBuilder().WithArguments(args).UsingAnyFreePort().Build();
         WrappedAppiumCreateService.AppiumLocalService.Start();
     }
 }
Esempio n. 12
0
        Uri IDriverService.Start()
        {
            var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());

            _appiumLocalService = new AppiumServiceBuilder().WithArguments(args).UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            Assert.IsTrue(_appiumLocalService.IsRunning);
            return(_appiumLocalService.ServiceUrl);
        }
 public void CheckAbilityToBuildServiceWithDefinedParametersAndNodeSetInProperties()
 {
     try
     {
         string definedNode = PathToCustomizedAppiumJS;
         Environment.SetEnvironmentVariable(AppiumServiceConstants.AppiumBinaryPath, definedNode);
         OptionCollector args = new OptionCollector().AddArguments(GeneralOptionList.OverrideSession());
         new AppiumServiceBuilder().UsingPort(4000).WithArguments(args).Build();
     }
     finally
     {
         Environment.SetEnvironmentVariable(AppiumServiceConstants.AppiumBinaryPath, string.Empty);
     }
 }
        public void CheckStartingOfAServiceWithNonDefaultArguments()
        {
            OptionCollector    args    = new OptionCollector().AddArguments(GeneralOptionList.LogNoColors());
            AppiumLocalService service = new AppiumServiceBuilder().UsingPort(4000).WithArguments(args).Build();

            try
            {
                service.Start();
                Assert.IsTrue(service.IsRunning);
            }
            finally
            {
                service.Dispose();
            }
        }
Esempio n. 15
0
 public void AppiumServerRun(int pThreadIndex)
 {
     try
     {
         OptionCollector args = new OptionCollector().AddArguments(GeneralOptionList.OverrideSession());
         args.AddArguments(AndroidOptionList.BootstrapPort((bootstrapPort + pThreadIndex * 2).ToString()));
         args.AddArguments(AndroidOptionList.SelendroidPort((selendroidPort + pThreadIndex * 2).ToString()));
         service = new AppiumServiceBuilder().UsingPort(appiumServerPort + pThreadIndex * 2).WithArguments(args).Build();
         service.Start();
     }
     catch (Exception e)
     {
         _Log.PrintTaskStatus(pThreadIndex, "\tCreate the Appium Server Exception : " + e.Message);
     }
 }
Esempio n. 16
0
        public AppiumLocalService StartAppiumLocalService()
        {
            var severoptions           = new OptionCollector();
            var relaxedSecurityOptions = new KeyValuePair <string, string>("--relaxed-security", "");

            severoptions.AddArguments(relaxedSecurityOptions);
            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort()
                                  .Build();
            if (!_appiumLocalService.IsRunning)
            {
                _appiumLocalService.Start();
            }

            return(_appiumLocalService);
        }
Esempio n. 17
0
        //start appium local service
        public static void StartAppium()
        {
            var appiumLogBasedir   = ".\\Logs\\Appium\\";
            var appiumLogCreateDir = Directory.CreateDirectory(appiumLogBasedir);
            var fileName           = appiumLogBasedir + "\\appiumLog.txt";

            if (!File.Exists(fileName))
            {
                File.Create(fileName);
            }
            var logFile = new FileInfo(fileName);
            var args    = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());

            appiumLocalService = new AppiumServiceBuilder().WithIPAddress("127.0.0.1").WithLogFile(logFile).Build();
            appiumLocalService.Start();
        }
        public static void ClassInitialize(TestContext context)
        {
            var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());

            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            var desiredCaps = new DesiredCapabilities();

            desiredCaps.SetCapability(MobileCapabilityType.DeviceName, "Android_Accelerated_x86_Oreo");
            desiredCaps.SetCapability(MobileCapabilityType.PlatformName, "Android");
            desiredCaps.SetCapability(MobileCapabilityType.PlatformVersion, "7.1");
            desiredCaps.SetCapability(MobileCapabilityType.BrowserName, "Chrome");

            _driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, desiredCaps);
            _driver.CloseApp();
        }
        public void CheckStartingOfTheServiceDefinedExternallyWithNonDefaultArguments()
        {
            OptionCollector    args    = new OptionCollector().AddArguments(GeneralOptionList.LogNoColors());
            AppiumLocalService service = new AppiumServiceBuilder().WithAppiumJS(new FileInfo(PathToCustomizedAppiumJS)).
                                         UsingPort(4000).WithArguments(args).Build();

            try
            {
                service.Start();
                Assert.IsTrue(service.IsRunning);
            }
            finally
            {
                service.Dispose();
            }
        }
        public void CheckAbilityToStartServiceUsingFlags()
        {
            AppiumLocalService service = null;
            var args = new OptionCollector().AddArguments(GeneralOptionList.CallbackAddress(_testIp))
                       .AddArguments(GeneralOptionList.OverrideSession());

            try
            {
                service = new AppiumServiceBuilder().WithArguments(args).Build();
                service.Start();
                Assert.IsTrue(service.IsRunning);
            }
            finally
            {
                service?.Dispose();
            }
        }
        public static void ClassInitialize(TestContext context)
        {
            var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());

            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            string testAppPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "selendroid-test-app-0.10.0.apk");
            var    desiredCaps = new DesiredCapabilities();

            desiredCaps.SetCapability(MobileCapabilityType.DeviceName, "Android_Accelerated_x86_Oreo");
            desiredCaps.SetCapability(MobileCapabilityType.PlatformName, "Android");
            desiredCaps.SetCapability(MobileCapabilityType.PlatformVersion, "7.1");
            desiredCaps.SetCapability(AndroidMobileCapabilityType.AppPackage, "io.selendroid.testapp");
            desiredCaps.SetCapability(AndroidMobileCapabilityType.AppActivity, "HomeScreenActivity");

            _driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, desiredCaps);
            _driver.CloseApp();
        }
        public static void ClassInitialize(TestContext context)
        {
            var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());

            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            string testAppPath   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "ApiDemos-debug.apk");
            var    appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android_Accelerated_x86_Oreo");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".graphics.TouchRotateActivity");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.App, testAppPath);

            _driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, appiumOptions);
            _driver.CloseApp();
        }
        public static void ClassInitialize(TestContext context)
        {
            var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());

            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            string testAppPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "ApiDemos-debug.apk");
            var    desiredCaps = new DesiredCapabilities();

            desiredCaps.SetCapability(MobileCapabilityType.DeviceName, "Android_Accelerated_x86_Oreo");
            desiredCaps.SetCapability(AndroidMobileCapabilityType.AppPackage, "com.example.android.apis");
            desiredCaps.SetCapability(MobileCapabilityType.PlatformName, "Android");
            desiredCaps.SetCapability(MobileCapabilityType.PlatformVersion, "7.1");
            desiredCaps.SetCapability(AndroidMobileCapabilityType.AppActivity, ".view.ControlsMaterialDark");
            desiredCaps.SetCapability(MobileCapabilityType.App, testAppPath);

            _driver = new AndroidDriver <AndroidElement>(_appiumLocalService, desiredCaps);
            _driver.CloseApp();
        }
        private AndroidDriver <AppiumWebElement> StartApp()
        {
            System.Environment.SetEnvironmentVariable("ANDROID_HOME", @"C:\Program Files (x86)\Android\android-sdk");
            System.Environment.SetEnvironmentVariable("JAVA_HOME", @"C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25");

            var capabilities = new AppiumOptions();

            // automatic start of the emulator if not running
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.Avd, "demo_device");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AvdArgs, "-no-boot-anim -no-snapshot-load");
            capabilities.AddAdditionalCapability(MobileCapabilityType.FullReset, true);


            // connecting to a device or emulator
            capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "emulator-5554");
            capabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, "UiAutomator2");
            // specifyig which app we want to install and launch
            var currentPath = Directory.GetCurrentDirectory();

            Console.WriteLine($"Current path: {currentPath}");
            var packagePath = Path.Combine(currentPath, @"..\..\..\AppsToTest\com.fluentbytes.carvedrock-x86.apk");

            packagePath = Path.GetFullPath(packagePath);
            Console.WriteLine($"Package path: {packagePath}");
            capabilities.AddAdditionalCapability(MobileCapabilityType.App, packagePath);

            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "com.fluentbytes.carvedrock");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, "crc641782d5af3c9cf50a.MainActivity");
            // additional wait time in case we have a clean emulator and need to wait for the install
            capabilities.AddAdditionalCapability("appWaitDuration", 4800000);
            // specify startup flags appium server to execute adb shell commands
            var serveroptions         = new OptionCollector();
            var relaxedSecurityOption = new KeyValuePair <string, string>("--relaxed-security", "");

            serveroptions.AddArguments(relaxedSecurityOption);
            var _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().WithArguments(serveroptions).Build();

            _appiumLocalService.Start();;
            var driver = new AndroidDriver <AppiumWebElement>(_appiumLocalService, capabilities);

            return(driver);
        }
Esempio n. 25
0
        /// <summary>
        /// Function Name :- FnStartAppiumServer
        /// Created By :- Pankaj Kumar
        /// Date of Creation :- 11-Apr-2020
        /// </summary>
        public bool FnStartAppiumServer()
        {
            bool blnStatus = true;

            try
            {
                OptionCollector args = new OptionCollector().AddArguments(GeneralOptionList.LogNoColors());
                Environment.SetEnvironmentVariable(AppiumServiceConstants.NodeBinaryPath, objConfig.NodeBinaryPath);
                Environment.SetEnvironmentVariable(AppiumServiceConstants.AppiumBinaryPath, objConfig.AppiumBinaryPath);
                service = new AppiumServiceBuilder().UsingPort(4723).WithArguments(args).Build();
                service.Start();
                Console.WriteLine("Appium Server Started at ==> " + service.ServiceUrl);
            }
            catch (Exception e)
            {
                blnStatus = false;
                Console.WriteLine(e.StackTrace);
            }
            return(blnStatus);
        }
        public void CheckThatServiseIsNotRunWhenTheCreatingOfANewSessionIsFailed()
        {
            string app = Apps.get("androidApiDemos");

            DesiredCapabilities capabilities = new DesiredCapabilities();

            capabilities.SetCapability(MobileCapabilityType.DeviceName, "iPhone Simulator");

            OptionCollector argCollector = new OptionCollector().AddArguments(GeneralOptionList.App(app)) //it will be a cause of error
                                                                                                          //that is expected
                                           .AddArguments(GeneralOptionList.AutomationName(AutomationName.Appium)).AddArguments(GeneralOptionList.PlatformName("Android"));

            AppiumServiceBuilder builder = new AppiumServiceBuilder().WithArguments(argCollector);
            AppiumLocalService   service = builder.Build();

            service.Start();

            IOSDriver <AppiumWebElement> driver = null;

            try
            {
                try
                {
                    driver = new IOSDriver <AppiumWebElement>(service, capabilities);
                }
                catch (Exception e)
                {
                    Assert.IsTrue(!service.IsRunning);
                    return;
                }
                throw new Exception("Any exception was expected");
            }
            finally
            {
                if (driver != null)
                {
                    driver.Quit();
                }
            }
        }
Esempio n. 27
0
        public static void ClassInit(TestContext context)
        {
            // Start Appium Server
            var             avdOptions       = new KeyValuePair <string, string>("--avd", "Emulator-Api19-Default");
            var             avdParamsOptions = new KeyValuePair <string, string>("--avd-args", "\"-scale 0.50\"");
            OptionCollector args             = new OptionCollector();

            args.AddArguments(avdOptions);
            args.AddArguments(avdParamsOptions);

            service = new AppiumServiceBuilder().WithArguments(args).UsingAnyFreePort().Build();
            service.Start();
            Assert.IsTrue(service.IsRunning);

            // Start Appium Client
            DesiredCapabilities capabilities = new DesiredCapabilities();

            capabilities.SetCapability("deviceName", "Android Emulator");
            capabilities.SetCapability("platformName", "Android");
            capabilities.SetCapability("app", "C:\\Git\\qa-academy\\2015\\MobileTesting\\testapp\\android-rottentomatoes-demo-debug.apk");
            driver = new AndroidDriver <AndroidElement>(service.ServiceUrl, capabilities);
        }
Esempio n. 28
0
        public static void ClassInitialize(TestContext context)
        {
            var args = new OptionCollector()
                       .AddArguments(GeneralOptionList.PreLaunch())
                       .AddArguments(new KeyValuePair <string, string>("--relaxed-security", string.Empty));

            _appiumLocalService = new AppiumServiceBuilder().WithArguments(args).UsingAnyFreePort().Build();
            _appiumLocalService.Start();
            string testAppPath   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "ApiDemos-debug.apk");
            var    appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.AutomationName, "UiAutomator2");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "android25-test");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "com.example.android.apis");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".ApiDemos");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.App, testAppPath);

            _driver = new AndroidDriver <AndroidElement>(_appiumLocalService, appiumOptions);
            _driver.CloseApp();
        }
Esempio n. 29
0
        public void StartingIosAppWithCapabilitiesAndServiseTest()
        {
            var app          = Apps.Get("iosTestApp");
            var capabilities =
                Caps.GetIosCaps(app);

            var argCollector = new OptionCollector()
                               .AddArguments(GeneralOptionList.OverrideSession()).AddArguments(GeneralOptionList.StrictCaps());

            var builder = new AppiumServiceBuilder().WithArguments(argCollector);
            IOSDriver <AppiumWebElement> driver = null;

            try
            {
                driver = new IOSDriver <AppiumWebElement>(builder, capabilities, Env.InitTimeoutSec);
                driver.CloseApp();
            }
            finally
            {
                driver?.Quit();
            }
        }
Esempio n. 30
0
        public void StartingAndroidAppWithCapabilitiesAndServiceTest()
        {
            var capabilities = Env.ServerIsRemote()
                ? Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos"))
                : Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos"));


            var argCollector = new OptionCollector()
                               .AddArguments(GeneralOptionList.OverrideSession()).AddArguments(GeneralOptionList.StrictCaps());
            var builder = new AppiumServiceBuilder().WithArguments(argCollector);

            AndroidDriver <AppiumWebElement> driver = null;

            try
            {
                driver = new AndroidDriver <AppiumWebElement>(builder, capabilities);
                driver.CloseApp();
            }
            finally
            {
                driver?.Quit();
            }
        }