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 MoveToTestCase() { IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities); RequestProcessor re = setupTouchAction(); IWebElement element = driver.FindElementByIosUIAutomation(".elements()"); ITouchAction a; a = new TouchAction(driver) .MoveTo(element, 50, 75); a.Perform(); Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"element\":\"5\",\"x\":50,\"y\":75}}]}"); a = new TouchAction(driver) .MoveTo(element, 0.5, 75); a.Perform(); Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"element\":\"5\",\"x\":0.5,\"y\":75}}]}"); a = new TouchAction(driver) .MoveTo(0.5, 75); a.Perform(); Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"x\":0.5,\"y\":75}}]}"); a = new TouchAction(driver) .MoveTo(element); a.Perform(); Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"moveTo\",\"options\":{\"element\":\"5\"}}]}"); }
public void RotateTestCase() { IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities); server.respondTo("POST", "/appium/device/rotate", null); Dictionary<string, int> parameters = new Dictionary<string, int> {{"x", 114}, {"y", 198}, {"duration", 5}, {"radius", 3}, {"rotation", 220}, {"touchCount", 2}}; driver.Rotate(parameters); }
public void FindElementByIosUIAutomationTestCase() { IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities); server.respondTo("POST", "/element", new Dictionary<string, object> { {"ELEMENT", '5'} }); IWebElement element = driver.FindElementByIosUIAutomation(".elements()"); server.clear(); server.respondTo("GET", "/element/5/attribute/id", "1234"); element.GetAttribute("id"); }
public void ElementRotateTestCase() { IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities); server.respondTo("POST", "/element", new Dictionary<string, object> { {"ELEMENT", '5'} }); AppiumWebElement element = (AppiumWebElement)driver.FindElementByIosUIAutomation(".elements()"); server.clear(); server.respondTo("POST", "/appium/device/rotate", null); Dictionary<string, int> parameters = new Dictionary<string, int> {{"x", 114}, {"y", 198}, {"duration", 5}, {"radius", 3}, {"rotation", 220}, {"touchCount", 2}}; element.Rotate(parameters); }
public void FindElementsByAccessibilityIdTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); List<object> results = new List<object>(); results.Add (new Dictionary<string, object> {{"ELEMENT", "4"}}); results.Add (new Dictionary<string, object> {{"ELEMENT", "6"}}); results.Add (new Dictionary<string, object> {{"ELEMENT", "8"}}); server.respondTo ("POST", "/elements", results); ICollection<IWebElement> elements = driver.FindElementsByAccessibilityId (".elements()"); Assert.AreEqual (elements.Count, 3); }
public void FindElementByAccessibilityIdTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); server.respondTo ("POST", "/element", new Dictionary<string, object> { {"ELEMENT", '5'} }); IWebElement element = driver.FindElementByAccessibilityId (".elements()"); server.clear (); server.respondTo ("GET", "/element/5/attribute/id", "1234"); element.GetAttribute ("id"); }
public void BeforeAll(){ DesiredCapabilities capabilities = Caps.getIos71Caps (Apps.get("iosTestApp")); if (Env.isSauce ()) { capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME")); capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY")); capabilities.SetCapability("name", "ios - simple"); capabilities.SetCapability("tags", new string[]{"sample"}); } Uri serverUri = Env.isSauce () ? AppiumServers.sauceURI : AppiumServers.localURI; driver = new IOSDriver<IOSElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC); driver.Manage().Timeouts().ImplicitlyWait(Env.IMPLICIT_TIMEOUT_SEC); }
public void ByIosUIAutomationTestCase() { IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities); server.respondTo("POST", "/element", new Dictionary<string, object> { {"ELEMENT", '5'} }); driver.FindElement(new ByIosUIAutomation(".elements()")); (new ByIosUIAutomation(".elements()")).FindElement(driver); server.clear(); List<object> results = new List<object>(); results.Add(new Dictionary<string, object> { { "ELEMENT", "4" } }); server.respondTo("POST", "/elements", results); driver.FindElements(new ByIosUIAutomation(".elements()")); (new ByIosUIAutomation(".elements()")).FindElements(driver); }
public void FromElementTestCase() { IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities); server.respondTo("POST", "/element", new Dictionary<string, object> { {"ELEMENT", '5'} }); IOSElement element = (IOSElement)driver.FindElementByIosUIAutomation(".elements()"); server.clear(); server.respondTo("POST", "/element/5/element", new Dictionary<string, object> { {"ELEMENT", '6'} }); element.FindElementByIosUIAutomation(".elements()"); server.clear(); List<object> results = new List<object>(); results.Add(new Dictionary<string, object> { { "ELEMENT", "4" } }); server.respondTo("POST", "/element/5/elements", results); element.FindElementsByIosUIAutomation(".elements()"); }
public void ByAccessibilityIdTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); server.respondTo ("POST", "/element", new Dictionary<string, object> { {"ELEMENT", '5'} }); driver.FindElement(new ByAccessibilityId(".elements()")); (new ByAccessibilityId(".elements()")).FindElement(driver); server.clear (); List<object> results = new List<object>(); results.Add (new Dictionary<string, object> {{"ELEMENT", "4"}}); server.respondTo ("POST", "/elements", results); driver.FindElements(new ByAccessibilityId(".elements()")); (new ByAccessibilityId(".elements()")).FindElements(driver); }
public static IOSDriver<IOSElement> XAMLCatalogSession; // Temporary placeholder until Windows namespace exists #endregion Fields #region Methods public static void LaunchApp() { if (XAMLCatalogSession != null) { XAMLCatalogSession.Quit(); } // Launch the XAMLCatalog app DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", "49ab0ab8-f42a-485e-9f46-c1348ba16d5c_tk6g8mba0d0k4!App"); XAMLCatalogSession = new IOSDriver<IOSElement>(RemoteHarnessUrl, appCapabilities); Assert.IsNotNull(XAMLCatalogSession); XAMLCatalogSession.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2)); }
public void BeforeAll() { DesiredCapabilities capabilities = Caps.getIos82Caps(Apps.get("iosTestApp")); if (Env.isSauce()) { capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME")); capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY")); capabilities.SetCapability("name", "ios - actions"); capabilities.SetCapability("tags", new string[] { "sample" }); } Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.LocalServiceURIForIOS; driver = new IOSDriver<AppiumWebElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC); TimeOutDuration timeSpan = new TimeOutDuration(new TimeSpan(0, 0, 0, 5, 0)); pageObject = new IOSPageObjectChecksAttributeMixOnNativeApp(); PageFactory.InitElements(driver, pageObject, new AppiumPageObjectMemberDecorator(timeSpan)); }
public IWebDriver Create() { if (browserType == Type) { DesiredCapabilities capabilities = new DesiredCapabilities(); var settings = ConfigurationManager.AppSettings; var requriedKeys = settings.AllKeys.Where(t => t.Contains("UI.Tests.Appium.capability")); foreach (var keys in requriedKeys) { var keyArray = keys.Split('.'); var tempVallue = ConfigurationManager.AppSettings[keys]; capabilities.SetCapability(keyArray[(keyArray.Length - 1)], tempVallue); } AppiumDriver<AppiumWebElement> browser = new IOSDriver<AppiumWebElement>(new Uri(ConfigurationManager.AppSettings["UI.Tests.Appium.URI"]), capabilities); return browser; } return null; }
public void FromElementTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); server.respondTo ("POST", "/element", new Dictionary<string, object> { {"ELEMENT", '5'} }); AppiumWebElement element = (AppiumWebElement) driver.FindElementByAccessibilityId (".elements()"); server.clear (); server.respondTo ("POST", "/element/5/element", new Dictionary<string, object> { {"ELEMENT", '6'} }); element.FindElementByAccessibilityId (".elements()"); server.clear (); List<object> results = new List<object>(); results.Add (new Dictionary<string, object> {{"ELEMENT", "4"}}); server.respondTo ("POST", "/element/5/elements", results); element.FindElementsByAccessibilityId (".elements()"); }
public void StartingIOSAppWithCapabilitiesOnlyTest() { string app = Apps.get("iosTestApp"); DesiredCapabilities capabilities = Caps.getIos82Caps(app); IOSDriver<AppiumWebElement> driver = null; try { driver = new IOSDriver<AppiumWebElement>(capabilities, Env.INIT_TIMEOUT_SEC); driver.CloseApp(); } finally { if (driver != null) { driver.Quit(); } } }
public void GetContextsTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); server.respondTo ("GET", "/contexts", new string[] {"ab", "cde", "123"}); Assert.AreEqual( driver.Contexts, new string[] {"ab", "cde", "123"}); }
public void ShakeDeviceTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); server.respondTo ("POST", "/appium/device/shake", null); driver.ShakeDevice (); }
public void SetImmediateValueTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); server.respondTo ("POST", "/element", new Dictionary<string, object> { {"ELEMENT", '5'} }); AppiumWebElement element = (AppiumWebElement) driver.FindElementByIosUIAutomation (".elements()"); server.clear (); server.respondTo ("POST", "/appium/element/5/value", null); element.SetImmediateValue ("123"); }
public void SetContextTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); server.respondTo ("POST", "/context", null); driver.Context = "1234"; }
public void LockDeviceTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); server.respondTo ("POST", "/appium/device/lock", null); driver.LockDevice (3); }
public void KeyEventTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); server.respondTo ("POST", "/appium/device/keyevent", null); driver.KeyEvent(5); }
public void ReleaseTestCase() { IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities); RequestProcessor re = setupTouchAction(); ITouchAction a; a = new TouchAction(driver) .Release(); a.Perform(); Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"release\"}]}"); }
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 MultiActionTestCase() { IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities); RequestProcessor re = setupMultiAction(); IWebElement element = driver.FindElementByIosUIAutomation(".elements()"); MultiAction m = new MultiAction(driver); m.Perform(); Assert.AreEqual(re.inputData, ""); TouchAction a1 = new TouchAction(); a1 .Press(element, 100, 100) .Wait(1000) .Release(); m.Add(a1); m.Perform(); Assert.AreEqual(re.inputData, "{\"actions\":[[{\"action\":\"press\",\"options\":{\"element\":\"5\",\"x\":100,\"y\":100}},{\"action\":\"wait\",\"options\":{\"ms\":1000}},{\"action\":\"release\"}]]}"); TouchAction a2 = new TouchAction(); a2 .Tap(100, 100) .MoveTo(element); m.Add(a2); m.Perform(); Assert.AreEqual(re.inputData, "{\"actions\":[[{\"action\":\"press\",\"options\":{\"element\":\"5\",\"x\":100,\"y\":100}},{\"action\":\"wait\",\"options\":{\"ms\":1000}},{\"action\":\"release\"}],[{\"action\":\"tap\",\"options\":{\"x\":100,\"y\":100}},{\"action\":\"moveTo\",\"options\":{\"element\":\"5\"}}]]}"); }
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 GetContextTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); server.respondTo ("GET", "/context", "1234"); Assert.AreEqual( driver.Context, "1234"); }
public void HideKeyboardTestCase() { IOSDriver driver = new IOSDriver(defaultUri, capabilities); { server.clear (); RequestProcessor re = server.respondTo ("POST", "/appium/device/hide_keyboard", null); driver.HideKeyboard (key: "Done"); Assert.AreEqual (re.inputData, "{\"keyName\":\"Done\"}"); } { server.clear (); RequestProcessor re = server.respondTo ("POST", "/appium/device/hide_keyboard", null); driver.HideKeyboard ("pressKey", "Done"); Assert.AreEqual (re.inputData, "{\"strategy\":\"pressKey\",\"keyName\":\"Done\"}"); } { server.clear (); RequestProcessor re = server.respondTo ("POST", "/appium/device/hide_keyboard", null); driver.HideKeyboard ("tapOutside"); Assert.AreEqual (re.inputData, "{\"strategy\":\"tapOutside\"}"); } }
public void WaitTestCase() { IOSDriver<IWebElement> driver = new IOSDriver<IWebElement>(defaultUri, capabilities); RequestProcessor re = setupTouchAction(); ITouchAction a; a = new TouchAction(driver) .Wait(1000); a.Perform(); Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"wait\",\"options\":{\"ms\":1000}}]}"); a = new TouchAction(driver) .Wait(); a.Perform(); Assert.AreEqual(re.inputData, "{\"actions\":[{\"action\":\"wait\"}]}"); }
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(); } } }