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 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()
        {
            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 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();
                }
            }
        }
示例#5
0
        private void Initialize()
        {
            var args = new OptionColector().AddArguments(GeneralOptionList.PreLaunch());

            _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            _appiumLocalService.Start();
        }
        public void CheckAbilityToBuildServiceWithDefinedParametersAndExternallyDefinedNode()
        {
            OptionCollector args = new OptionCollector().AddArguments(GeneralOptionList.OverrideSession());

            new AppiumServiceBuilder().WithAppiumJS(new FileInfo(PathToCustomizedAppiumJS)).
            UsingPort(4000).WithArguments(args).Build();
        }
        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();
                }
            }
        }
示例#8
0
文件: App.cs 项目: tamirg7/BELLATRIX
 public static void StartAppiumLocalService()
 {
     if (_shouldStartAppiumLocalService)
     {
         var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch());
         WrappedAppiumCreateService.AppiumLocalService = new AppiumServiceBuilder().WithArguments(args).UsingAnyFreePort().Build();
         WrappedAppiumCreateService.AppiumLocalService.Start();
     }
 }
示例#9
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();
            }
        }
示例#12
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);
     }
 }
示例#13
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();
        }
示例#20
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();
                }
            }
        }
示例#22
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();
        }
示例#23
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();
            }
        }
示例#24
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();
            }
        }