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 CheckAbilityToStartServiceUsingFlags() { AppiumLocalService service = null; OptionCollector args = new OptionCollector().AddArguments(GeneralOptionList.CallbackAddress(testIP)) .AddArguments(GeneralOptionList.OverrideSession()); try { service = new AppiumServiceBuilder().WithArguments(args).Build(); service.Start(); Assert.IsTrue(service.IsRunning); } finally { if (service != null) { service.Dispose(); } } }
public void CheckThatServiseIsNotRunWhenTheCreatingOfANewSessionIsFailed() { DesiredCapabilities capabilities = Env.isSauce() ? //it will be a cause of error Caps.getAndroid501Caps(Apps.get("androidApiDemos")) : Caps.getAndroid19Caps(Apps.get("androidApiDemos")); capabilities.SetCapability(MobileCapabilityType.DeviceName, "iPhone Simulator"); capabilities.SetCapability(MobileCapabilityType.PlatformName, MobilePlatform.IOS); AppiumServiceBuilder builder = new AppiumServiceBuilder(); 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(); } } }
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 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 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 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(); } } }
public void CheckStartingOfTheServiceDefinedExternally() { AppiumLocalService service = new AppiumServiceBuilder().WithAppiumJS(new FileInfo(PathToCustomizedAppiumJS)).Build(); try { service.Start(); Assert.IsTrue(service.IsRunning); } finally { service.Dispose(); } }
public void CheckTheAbilityToDefineTheDesiredLogFile() { FileInfo log = new FileInfo("Log.txt"); AppiumLocalService service = new AppiumServiceBuilder().WithLogFile(log).Build(); try { service.Start(); Assert.IsTrue(log.Exists); Assert.IsTrue(log.Length > 0); //There should be Appium greeting messages } finally { service.Dispose(); if (log.Exists) { File.Delete(log.FullName); } service.Dispose(); } }
public void CheckAbilityToBuildServiceUsingNodeDefinedExplicitly() { AppiumLocalService service = null; try { service = new AppiumServiceBuilder().WithAppiumJS(new FileInfo(PathToCustomizedAppiumJS)).Build(); service.Start(); Assert.AreEqual(true, service.IsRunning); } finally { if (service != null) { service.Dispose(); } } }
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 CheckStartingOfTheServiceDefinedByProperty() { try { string definedNode = PathToCustomizedAppiumJS; Environment.SetEnvironmentVariable(AppiumServiceConstants.AppiumBinaryPath, definedNode); AppiumLocalService service = new AppiumServiceBuilder().Build(); try { service.Start(); Assert.IsTrue(service.IsRunning); } finally { service.Dispose(); } } finally { Environment.SetEnvironmentVariable(AppiumServiceConstants.AppiumBinaryPath, string.Empty); } }
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(); } } }
public void CheckAbilityToStartServiceOnAFreePort() { AppiumLocalService service = null; try { service = new AppiumServiceBuilder().UsingAnyFreePort().Build(); service.Start(); Assert.AreEqual(true, service.IsRunning); } finally { if (service != null) { service.Dispose(); } } }
public void CheckAbilityToStartAndShutDownFewServices() { AppiumLocalService service1 = new AppiumServiceBuilder().UsingAnyFreePort().Build(); AppiumLocalService service2 = new AppiumServiceBuilder().UsingAnyFreePort().Build(); AppiumLocalService service3 = new AppiumServiceBuilder().UsingAnyFreePort().Build(); AppiumLocalService service4 = new AppiumServiceBuilder().UsingAnyFreePort().Build(); service1.Start(); service2.Start(); service3.Start(); service4.Start(); service1.Dispose(); Thread.Sleep(1000); service2.Dispose(); Thread.Sleep(1000); service3.Dispose(); Thread.Sleep(1000); service4.Dispose(); Assert.IsTrue(!service1.IsRunning); Assert.IsTrue(!service2.IsRunning); Assert.IsTrue(!service3.IsRunning); Assert.IsTrue(!service4.IsRunning); }
public void CheckAbilityToStartServiceOnAFreePort() { AppiumLocalService service = new AppiumServiceBuilder().UsingAnyFreePort().Build(); try { service.Start(); Assert.IsTrue(service.IsRunning); } finally { service.Dispose(); } }
public void CheckStartingOfAServiceWithNonLocalhostIP() { IPHostEntry host; string localIp = "?"; string hostName = Dns.GetHostName(); host = Dns.GetHostEntry(hostName); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily.ToString() == "InterNetwork") { localIp = ip.ToString(); break; } } Console.WriteLine(localIp); AppiumLocalService service = new AppiumServiceBuilder().WithIPAddress(localIp).UsingPort(4000). Build(); try { service.Start(); Assert.IsTrue(service.IsRunning); } finally { service.Dispose(); } }
public void CheckStartingOfAServiceWithNonLocalhostIP() { AppiumLocalService service = new AppiumServiceBuilder().WithIPAddress(testIP).UsingPort(4000). Build(); try { service.Start(); Assert.IsTrue(service.IsRunning); } finally { service.Dispose(); } }
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(); } }