private void CloseApplication(string applicationId) { DesiredCapabilities appCapabilities = new DesiredCapabilities(); appCapabilities.SetCapability("app", applicationId); IOSDriver <IOSElement> session = new IOSDriver <IOSElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities); Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); Assert.AreNotEqual(String.Empty, session.Title); Assert.AreNotEqual(String.Empty, session.CurrentWindowHandle); var originalWindowHandlesCount = session.WindowHandles.Count; session.CloseApp(); System.Threading.Thread.Sleep(3000); // Sleep for 3 second Assert.IsNotNull(session); Assert.IsNotNull(session.SessionId); Assert.AreEqual(originalWindowHandlesCount - 1, session.WindowHandles.Count); try { session.CloseApp(); // Attempt to close already closed app Assert.Fail("Exception should have been thrown"); } catch (System.InvalidOperationException exception) { Assert.AreEqual("Currently selected window has been closed", exception.Message); } session.Quit(); }
public void ScrollToEndOfListUsingRemoteTouchScreenScroll() { driver.LaunchApp(); var touchScreen = new RemoteTouchScreen(driver); touchScreen.Scroll(0, -300); touchScreen.Scroll(0, -300); driver.CloseApp(); }
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 TearDown() { if (driver != null) { Console.WriteLine("Test Completed and Closing Driver"); driver.CloseApp(); driver.Quit(); Console.WriteLine("Driver Closed and Application Exited !!!"); } }
public static void ClassInitialize(TestContext context) { string testAppPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "TestApp.app.zip"); var appiumOptions = new AppiumOptions(); appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "iPhone 6"); appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "iOS"); appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "11.3"); appiumOptions.AddAdditionalCapability(MobileCapabilityType.App, testAppPath); _driver = new IOSDriver <IOSElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions); _driver.CloseApp(); }
public void testNavigationOnAcuraSupportCommunity() { Console.WriteLine("should allow to navigate to some devices on Acura Support Community"); /* * Steps: * 1. Click on "Car and Truck" Categories on Homepage * 2. Click on "Acura" Categories * * Expected: * 1. General Information is "Acura". * 2.Verify five devices below displays. * + Acura Integra * + Acura MDX * + Acura RL * + Acura TL * + Acura TSX */ driver.FindElementByXPath("//XCUIElementTypeButton[@name='START A REPAIR']").Click(); Thread.Sleep(5000); driver.FindElementByXPath("//*[@name='Car and Truck']").Click(); Thread.Sleep(2000); driver.FindElementByXPath("//*[@name='Acura']").Click(); Thread.Sleep(2000); WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, 60)); wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//XCUIElementTypeNavigationBar"))); string acuraText = driver .FindElementByXPath("//XCUIElementTypeNavigationBar").GetAttribute("name"); bool hasAcuraIntegra = driver .FindElementByXPath("//XCUIElementTypeStaticText[@name='Acura Integra']").Displayed; bool hasAcuraMDX = driver .FindElementByXPath("//XCUIElementTypeStaticText[@name='Acura MDX']").Displayed; bool hasAcuraRL = driver .FindElementByXPath("//XCUIElementTypeStaticText[@name='Acura RL']").Displayed; bool hasAcuraTL = driver .FindElementByXPath("//XCUIElementTypeStaticText[@name='Acura TL']").Displayed; bool hasAcuraTSX = driver .FindElementByXPath("//XCUIElementTypeStaticText[@name='Acura TSX']").Displayed; driver.CloseApp(); Assert.AreEqual(acuraText, "Acura"); Assert.AreEqual(hasAcuraIntegra, true); Assert.AreEqual(hasAcuraMDX, true); Assert.AreEqual(hasAcuraRL, true); Assert.AreEqual(hasAcuraTL, true); Assert.AreEqual(hasAcuraTSX, true); }
public void StartingIosAppWithCapabilitiesOnlyTest() { var app = Apps.Get("iosTestApp"); var capabilities = Caps.GetIosCaps(app); IOSDriver <AppiumWebElement> driver = null; try { driver = new IOSDriver <AppiumWebElement>(capabilities, Env.InitTimeoutSec); driver.CloseApp(); } finally { driver?.Quit(); } }
public static void ClassInitialize(TestContext context) { // There is a bug in current version of Appium and it is not working on MacOS. ////var args = new OptionCollector().AddArguments(GeneralOptionList.PreLaunch()); ////_appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build(); ////_appiumLocalService.Start(); string testAppPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "TestApp.app.zip"); var appiumOptions = new AppiumOptions(); appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "iPhone 6"); appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "iOS"); appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "11.3"); appiumOptions.AddAdditionalCapability(MobileCapabilityType.App, testAppPath); ////_driver = new IOSDriver<IOSElement>(_appiumLocalService, appiumOptions); _driver = new IOSDriver <IOSElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions); _driver.CloseApp(); }
public void StartingIOSAppWithCapabilitiesOnlyTest() { string app = Apps.get("iosTestApp"); DesiredCapabilities capabilities = Caps.getIos92Caps(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 AddNewItem() { IOSDriver <IOSElement> driver = StartApp(); // tap on second item var el1 = driver.FindElementByAccessibilityId("Add"); el1.Click(); var elItemText = driver.FindElementByAccessibilityId("ItemText"); elItemText.Clear(); elItemText.SendKeys("This is a new Item"); var elItemDetail = driver.FindElementByAccessibilityId("ItemDetailsText"); elItemDetail.Clear(); elItemDetail.SendKeys("These are the details"); var elSave = driver.FindElementByAccessibilityId("Add"); CreateScreenshot(driver); elSave.Click(); var scrollableElement = driver.FindElementByAccessibilityId("maintable"); Func <AppiumWebElement> FindElementAction = () => { // find all text views // check if the text matches var element = driver.FindElementByAccessibilityId("This is a new Item"); return(element); }; var elementFound = ScrollUntillItemFound(driver, scrollableElement, FindElementAction); Assert.IsTrue(elementFound != null); driver.CloseApp(); }
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(); } }
public void CheckMasterDetailAndBack() { IOSDriver <IOSElement> driver = StartApp(); // tap on second item var el1 = driver.FindElementByAccessibilityId("Second item"); el1.Click(); var el2 = driver.FindElementByAccessibilityId("ItemText"); var txt = el2.Text; Assert.IsTrue(txt == "Second item"); // find root view controller link var elback = driver.FindElementByAccessibilityId("Root View Controller"); elback.Click(); var el3 = driver.FindElementByAccessibilityId("Fourth item"); Assert.IsTrue(el3 != null); driver.CloseApp(); }
public void TestCleanup() { _driver?.CloseApp(); }
public void CloseIOSApp() { _iosDriver.CloseApp(); }