Example #1
0
        public void TestMethod1()
        {
            // setupn desired capabilities
            AppiumOptions cap = new AppiumOptions();

            cap.AddAdditionalCapability("deviceName", "MyPhone");
            cap.AddAdditionalCapability("platformName", "Android");
            cap.AddAdditionalCapability("platformVersion", "8.0");
            cap.AddAdditionalCapability("udid", "988633474237324346");
            cap.AddAdditionalCapability("appPackage", "gift.giftrete.com");
            cap.AddAdditionalCapability("appActivity", "gift.giftrete.com.SplashScreenActivity");


            //set up the url for appium server to lauch the automation session

            driver = new AndroidDriver <IWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), cap);



            //gather element for writing test
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);


            driver.FindElementById("txtnext").Click();
            driver.FindElementById("txtnext").Click();
            driver.FindElementById("txtnext").Click();

            driver.FindElementById("email").SendKeys("*****@*****.**");
            driver.FindElementById("password").SendKeys("tester!");
            driver.FindElementById("button").Click();

            IWebElement GiftreteLogo = driver.FindElementById("titletxt");
            IWebElement RegisterBtn  = driver.FindElementById("signup");


            if (GiftreteLogo.Displayed)
            {
                Assert.That(RegisterBtn.Displayed, Is.True);
            }
            else if (!GiftreteLogo.Displayed)
            {
                Assert.That(RegisterBtn.Displayed, Is.False);
            }
        }
Example #2
0
        public void SimpleTest()
        {
            var appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1.1");

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.FullReset, true);
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.NewCommandTimeout, 60);

            appiumOptions.AddAdditionalCapability("testobject_api_key", "0D6C044F19D0442BA1E11C3FF087F6A6");
            appiumOptions.AddAdditionalCapability("username", SauceUser.Name);
            appiumOptions.AddAdditionalCapability("accessKey", SauceUser.AccessKey);
            //TODO first you must upload an app to Test Object so that you get your app key

            var rdcUrl = "https://us1.appium.testobject.com/wd/hub";
            var driver = new AndroidDriver <IWebElement>(new Uri(rdcUrl), appiumOptions);

            driver.Navigate().GoToUrl("https://www.ultimateqa.com");
            Console.WriteLine("");
            driver.Quit();
        }
Example #3
0
        public static AndroidDriver <AndroidElement> InitializeAndroidNativeApp()
        {
            Context context       = new Context();
            var     driverOptions = new AppiumOptions();

            context.GetConfiguration();
            dynamic devicesFromconfig = context.Configuration["devices"];

            driverOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, devicesFromconfig[0].os);
            driverOptions.AddAdditionalCapability(MobileCapabilityType.App, context.Configuration[_applicationUnderTest]);
            driverOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, devicesFromconfig[0].deviceName);
            driverOptions.AddAdditionalCapability("autoAcceptAlerts", true);
            driverOptions.AddAdditionalCapability(MobileCapabilityType.NewCommandTimeout, 100);
            driverOptions.AddAdditionalCapability("autoGrantPermissions", true);

            //This line is specific to the current AUT
            driverOptions.AddAdditionalCapability("appWaitActivity", "md525147372f3ece587b62293ecc226e68b.MainActivity");

            AndroidDriver <AndroidElement> androidDriver = new AndroidDriver <AndroidElement>(_appiumLocalService, driverOptions);

            return(androidDriver);
        }
Example #4
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();
        }
Example #5
0
        public void TestBrowser()
        {
            AppiumOptions options = new AppiumOptions();

            options.PlatformName = "Android";
            options.AddAdditionalCapability("deviceName", "Generic_x86");
            options.AddAdditionalCapability("platformVersion", "6.0.0");
            options.AddAdditionalCapability("automationName", "UiAutomator2");
            options.AddAdditionalCapability("browserName", "Browser");
            options.AddAdditionalCapability("chromedriverExecutableDir", @"C:\Users\Administrator\Documents\ChromeDriver");
            options.AddAdditionalCapability("chromedriverChromeMappingFile", @"C:\Users\Administrator\Documents\ChromeDriver\mapping.json");
            options.AddAdditionalCapability("newCommandTimeout", "120");

            _driver = new AndroidDriver <AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), options);

            //Navigate to browser
            _driver.Navigate().GoToUrl("http://www.bing.com");
            _driver.FindElementByName("q").SendKeys("Microsoft");
            _driver.FindElementByName("q").SendKeys(Keys.Enter);

            //Verify something
        }
Example #6
0
        public virtual void InitializeAppiumOptions(string classFullName)
        {
            AppiumOptions = AddAdditionalCapability(classFullName, new AppiumOptions());

            if (!string.IsNullOrEmpty(Build))
            {
                AppiumOptions.AddAdditionalCapability("build", Build);
            }

            AppiumOptions.AddAdditionalCapability("browserName", string.Empty);
            AppiumOptions.AddAdditionalCapability("platform", Platform);
            AppiumOptions.AddAdditionalCapability("version", BrowserVersion);
            AppiumOptions.AddAdditionalCapability("screen_resolution", ScreenResolution);
            AppiumOptions.AddAdditionalCapability("record_video", RecordVideo);
            AppiumOptions.AddAdditionalCapability("record_network", RecordNetwork);

            var crossBrowserTestingCredentialsResolver = new CrossBrowserTestingCredentialsResolver();
            var credentials = crossBrowserTestingCredentialsResolver.GetCredentials();

            AppiumOptions.AddAdditionalCapability("username", credentials.Item1);
            AppiumOptions.AddAdditionalCapability("password", credentials.Item2);

            AppiumOptions.AddAdditionalCapability("name", classFullName);
        }
Example #7
0
        public static void Setup(TestContext context)
        {
            // Create a desktop session
            AppiumOptions DesktopOptions = new AppiumOptions();

            DesktopOptions.AddAdditionalCapability("app", "Root");
            DesktopSession = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), DesktopOptions);

            // Launch First Pass by using the debug shortkey in Visual Studios
            DesktopSession.Keyboard.SendKeys(Keys.F5);

            Thread.Sleep(TimeSpan.FromSeconds(3));

            var FirstPassWindow = DesktopSession.FindElementByName("PasswordKeeper");
            var FirstPassTopLevelWindowHandle = FirstPassWindow.GetAttribute("NativeWindowHandle");

            FirstPassTopLevelWindowHandle = (int.Parse(FirstPassTopLevelWindowHandle)).ToString("x"); // Convert to Hex

            // Create session by attaching to Cortana top level window
            AppiumOptions appOptions = new AppiumOptions();

            appOptions.AddAdditionalCapability("appTopLevelWindow", FirstPassTopLevelWindowHandle);
            ApplicationSession = new WindowsDriver <WindowsElement>(new Uri(WindowsApplicationDriverUrl), appOptions);
        }
        protected override AndroidDriver <AndroidElement> CreateDriver(AppiumOptions options, UITestConfiguration config)
        {
            if (!string.IsNullOrWhiteSpace(config.AppPath))
            {
                var apkFileInfo = new FileInfo(config.AppPath);
                if (apkFileInfo.Exists)
                {
                    options.AddAdditionalCapability(MobileCapabilityType.App, apkFileInfo.FullName);
                }
            }

            AddAdditionalCapability(options, MobileCapabilityType.PlatformName, "Android");
            AddAdditionalCapability(options, MobileCapabilityType.DeviceName, config.DeviceName);
            //AddAdditionalCapability(options, "forceEspressoRebuild", true);
            AddAdditionalCapability(options, MobileCapabilityType.AutomationName, "Espresso");
            AddAdditionalCapability(options, "enforceAppInstall", true);

            if (!string.IsNullOrEmpty(config.UDID))
            {
                AddAdditionalCapability(options, MobileCapabilityType.Udid, config.UDID);
            }

            return(new AndroidDriver <AndroidElement>(config.AppiumServer, options, TimeSpan.FromSeconds(90)));
        }
Example #9
0
        public void TestMethod9()
        {
            var notepad = @"C:\Windows\System32\notepad.exe";

            var options = new AppiumOptions();

            options.AddAdditionalCapability("app", notepad);

            var driver = new WindowsDriver <WindowsElement>(new Uri(" http://127.0.0.1:4723/"), options);

            var textEditor = driver.FindElementByAccessibilityId("15");

            textEditor.SendKeys("ABCDEF");

            var eyes = new Eyes();

            eyes.ApiKey = "lFMnO9e1nbFQEdhebrDmhEBOqB7jXUXJGogj103lRWAzM110";
            eyes.SetAppEnvironment("Windows 10", null);

            try
            {
                eyes.Open("AppiumPractice", "TestMethod9");
                Thread.Sleep(3000);
                var currentAppScreenshot = driver.GetScreenshot();
                var croppedScreenshot    = CropScreenshotWithRect(currentAppScreenshot, textEditor);

                eyes.CheckImage(croppedScreenshot, "Cropped Text Editor");

                eyes.Close();
            }
            finally
            {
                eyes?.AbortIfNotClosed();
                driver.Quit();
            }
        }
Example #10
0
        public void StartMobileBrowser()
        {
            if (this.autActivityName == null || this.autPackageName == null || this.dutUdid == null)
            {
                throw new SdkException("Not all required environment variables were set before the start of the test.");
            }

            AppiumOptions appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, MobilePlatform.Android);
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.Udid, this.dutUdid);

            appiumOptions.AddAdditionalCapability(CapabilityType.BrowserName, string.Empty);
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Pixel_3a_API_29_x86 [emulator-5554]");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, this.autPackageName);
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, this.autActivityName);

            this.driver = new AndroidDriver <AppiumWebElement>(appiumOptions: appiumOptions);
        }
        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 void BeforeAll()
        {
            AppiumOptions capabilities = Env.isSauce()
                ? Caps.getAndroid501Caps(Apps.get("selendroidTestApp"))
                : Caps.getAndroid19Caps(Apps.get("selendroidTestApp"));

            if (Env.isSauce())
            {
                capabilities.AddAdditionalCapability("username", Env.getEnvVar("SAUCE_USERNAME"));
                capabilities.AddAdditionalCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY"));
                capabilities.AddAdditionalCapability("name", "android - webview");
                capabilities.AddAdditionalCapability("tags", new string[] { "sample" });
            }
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.selendroid.testapp");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".WebViewActivity");
            Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.LocalServiceURIAndroid;

            driver = new AndroidDriver <IWebElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
            driver.Manage().Timeouts().ImplicitWait = Env.IMPLICIT_TIMEOUT_SEC;
        }
Example #13
0
        public void Setup()
        {
            var capabilities = new AppiumOptions();

            //We can run on any version of the platform as long as it's the correct device
            //Make sure to pick an Android or iOS device based on your app
            capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Google Pixel");
            capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            //make sure you set locale as sometimes it opens in a different location and throws off locations
            capabilities.AddAdditionalCapability("locale", "en");
            capabilities.AddAdditionalCapability("language", "en");

            /*
             * !!!!!!
             * TODO first you must upload an app to RDC so that you get your app key
             * Then, make sure you can hardcode it here just to get started
             */
            capabilities.AddAdditionalCapability("testobject_api_key", new ApiKeys().Rdc.Apps.SampleAppAndroid);
            capabilities.AddAdditionalCapability("name", TestContext.CurrentContext.Test.Name);
            //It's important to keep the newCommandTimeout on the higher end as Real Devices are slow
            capabilities.AddAdditionalCapability("newCommandTimeout", 180);

            _driver = new AndroidDriver <AndroidElement>(new Uri(RdcUsHubUrl), capabilities);
        }
        public TestAppFixture()
        {
            var opts = new AppiumOptions();
            var path = Path.GetFullPath(TestAppPath);

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                opts.AddAdditionalCapability(MobileCapabilityType.App, path);
                opts.AddAdditionalCapability(MobileCapabilityType.PlatformName, MobilePlatform.Windows);
                opts.AddAdditionalCapability(MobileCapabilityType.DeviceName, "WindowsPC");

                Session = new WindowsDriver <AppiumWebElement>(
                    new Uri("http://127.0.0.1:4723"),
                    opts);

                // https://github.com/microsoft/WinAppDriver/issues/1025
                SetForegroundWindow(new IntPtr(int.Parse(
                                                   Session.WindowHandles[0].Substring(2),
                                                   NumberStyles.AllowHexSpecifier)));
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                opts.AddAdditionalCapability("appium:bundleId", TestAppBundleId);
                opts.AddAdditionalCapability(MobileCapabilityType.PlatformName, MobilePlatform.MacOS);
                opts.AddAdditionalCapability(MobileCapabilityType.AutomationName, "mac2");
                opts.AddAdditionalCapability("appium:showServerLogs", true);

                Session = new MacDriver <AppiumWebElement>(
                    new Uri("http://127.0.0.1:4723/wd/hub"),
                    opts);
            }
            else
            {
                throw new NotSupportedException("Unsupported platform.");
            }
        }
Example #15
0
        private static IWebDriver CreateAndroidDriver()
        {
            var capabilities = new AppiumOptions();

            capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "HT4CLJT00667");
            capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1.1");
            capabilities.AddAdditionalCapability(MobileCapabilityType.App, @"C:\Ranorex\AUT\android\app-debug.apk");
            capabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, "UiAutomator2");
            capabilities.AddAdditionalCapability(MobileCapabilityType.AutoWebview, true);

            //capabilities.AddAdditionalCapability("appPackage", "com.mobisys.msbclientdev");
            //capabilities.AddAdditionalCapability("appActivity", "com.mobisys.msbclientdev.MainActivity");

            //capabilities.AddAdditionalCapability("appWaitPackage", "com.mobisys.msbclientdev");
            //capabilities.AddAdditionalCapability("appWaitActivity", "com.mobisys.msbclientdev.MainActivity");

            return(new AndroidDriver <IWebElement>(
                       new HttpCommandExecutor(new Uri("http://localhost:4723/wd/hub"), TimeSpan.FromMinutes(5)),
                       capabilities));
        }
Example #16
0
        public void TestMethod1()
        {
            AppiumOptions cap = new AppiumOptions();

            cap.AddAdditionalCapability("platformName", "Android");
            cap.AddAdditionalCapability("deviceName", "nokia7plus");
            cap.AddAdditionalCapability("udid", "B2NGAA9832502143");
            cap.AddAdditionalCapability("platformVersion", "6.0");
            cap.AddAdditionalCapability("appPackage", "gift.giftrete.com");
            cap.AddAdditionalCapability("appActivity", "gift.giftrete.com.SplashScreenActivity");


            driver = new AndroidDriver <IWebElement>(new Uri("http://127.0.0.01:4723/wd/hub"), cap);


            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);

            driver.FindElementById("txtnext").Click();
            driver.FindElementById("txtnext").Click();
            driver.FindElementById("txtnext").Click();

            driver.FindElementById("email").SendKeys("*****@*****.**" + "\n");
            driver.FindElementById("passwordli").SendKeys("TestPass!23" + "\n");
            driver.FindElementById("button").Click();

            driver.FindElementById("navigation_cart").Click();
            driver.FindElementById("createcommunity").Click();
            driver.FindElementById("name").SendKeys("Testing");
            driver.FindElementById("description").SendKeys("Testing2");
            driver.FindElementById("status").Click();
            driver.FindElementById("tv_tinted_spinner").Click();
            driver.FindElementById("type").Click();
            driver.FindElementById("tv_tinted_spinner").Click();
            driver.FindElementById("location").SendKeys("London");
            driver.FindElementById("website").SendKeys("www.giftrete.com");
            driver.HideKeyboard();
            driver.FindElementById("regUserPhoto").Click();
            driver.FindElementById("title").Click();
            driver.FindElementById("ContinueButton").Click();
        }
Example #17
0
        public AppiumDriver <AndroidElement> Init()
        {
            AppiumOptions appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Galaxy S9");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "9.0");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.App, "https://testingbot.com/appium/sample.apk");

            String key    = Environment.GetEnvironmentVariable("TB_KEY");
            String secret = Environment.GetEnvironmentVariable("TB_SECRET");

            appiumOptions.AddAdditionalCapability("key", key);
            appiumOptions.AddAdditionalCapability("secret", secret);

            AppiumDriver <AndroidElement> driver = new AndroidDriver <AndroidElement>(
                new Uri("https://hub.testingbot.com/wd/hub"),
                appiumOptions
                );

            return(driver);
        }
      public void BeforeScenario()
      {
          // setupn desired capabilities
          AppiumOptions cap = new AppiumOptions();

          cap.AddAdditionalCapability("deviceName", "MyPhone");
          cap.AddAdditionalCapability("platformName", "Android");
          cap.AddAdditionalCapability("platformVersion", "8.0");
          cap.AddAdditionalCapability("udid", "988633474237324346");
          cap.AddAdditionalCapability("appPackage", "gift.giftrete.com");
          cap.AddAdditionalCapability("appActivity", "gift.giftrete.com.SplashScreenActivity");


          //set up the url for appium server to lauch the automation session

          driver = new AndroidDriver <IWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), cap);



          //gather element for writing test
          driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
      }
        public static void Main()
        {
            appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
            appiumLocalService.Start();
            var appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "device");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "9.0");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "com.draeger.connect.cse");
            appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, "com.draeger.connect.cse.MainActivity");
            appiumOptions.AddAdditionalCapability(MobileCapabilityType.NoReset, true);
            //new Uri("http://127.0.0.1:4723/wd/hub")
            driver = new AndroidDriver <AppiumWebElement>(appiumLocalService, appiumOptions);

            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
            AppiumWebElement approveBox             = driver.FindElementByAndroidUIAutomator("new UiSelector().textContains(\"Approve\");");

            approveBox.Click();
            AppiumWebElement background = driver.FindElementByAndroidUIAutomator("new UiSelector().textContains(\"Dräger CSE Mobile\");");

            background.Click();
        }
Example #20
0
        public static void ClassInitialize(TestContext context)
        {
            var appiumOptions = new AppiumOptions();

            appiumOptions.AddAdditionalCapability(MobileCapabilityType.BrowserName, "chrome");
            appiumOptions.AddAdditionalCapability("version", "mobile-79.0");
            appiumOptions.AddAdditionalCapability("enableVNC", true);
            appiumOptions.AddAdditionalCapability("enableVideo", true);
            appiumOptions.AddAdditionalCapability("desired-skin", "WSVGA");
            appiumOptions.AddAdditionalCapability("desired-screen-resolution", "1024x600");

            try
            {
                var timeout = TimeSpan.FromSeconds(120);
                _driver = new AndroidDriver <AndroidElement>(new Uri("http://127.0.0.1:4444/wd/hub"), appiumOptions, timeout);
                _driver.Manage().Timeouts().ImplicitWait           = TimeSpan.FromSeconds(120);
                _driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(120);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Example #21
0
        public void iOS13()
        {
            var capabilities = new AppiumOptions();

            //We can run on any iPhone Device
            capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "13");
            capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "iOS");
            //TODO it's a best practice to set the appium version so that you're always getting the latest
            capabilities.AddAdditionalCapability("appiumVersion", APPIUM_VERSION);

            /*
             * !!!!!!
             * TODO first you must upload an app to RDC so that you get your app key
             * Then, make sure you can hardcode it here just to get started
             */
            capabilities.AddAdditionalCapability("testobject_api_key", new ApiKeys().Rdc.Apps.SampleAppIOS);
            capabilities.AddAdditionalCapability("name", TestContext.CurrentContext.Test.Name);
            capabilities.AddAdditionalCapability("newCommandTimeout", 90);

            //60 seconds for the connection timeout
            _driver = new IOSDriver <IOSElement>(new Uri(RdcUsHubUrl), capabilities);
            Assert.True(IsLoginButtonDisplayed());
        }
        public void TestIOSFeaturesUsingIOSDriver()
        {
            // This is your api key, make sure you use it in all your tests.
            Eyes eyes = new Eyes();

            // Setup appium - Ensure the capabilities meets your environment.
            // Refer to http://appium.io documentation if required.
            AppiumOptions options = new AppiumOptions();

            options.AddAdditionalCapability("platformName", "iOS");
            options.AddAdditionalCapability("browserName", "Safari");
            options.AddAdditionalCapability("platformVersion", "14");
            options.AddAdditionalCapability("deviceName", "iPad Pro 12.9 2020");
            options.AddAdditionalCapability("browserstack.user", TestDataProvider.BROWSERSTACK_USERNAME);
            options.AddAdditionalCapability("browserstack.key", TestDataProvider.BROWSERSTACK_ACCESS_KEY);

            IWebDriver driver = new IOSDriver <AppiumWebElement>(new Uri(TestDataProvider.BROWSERSTACK_SELENIUM_URL), options);

            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);


            try
            {
                driver.Url = "https://www.lampsplus.com/products/wall-lights";

                // Start the test.
                eyes.Open(driver, "Lampsplus Ticket", "37479_2");
                eyes.CheckWindow("ScreenShot", true);
                eyes.Close(false);
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
        }
Example #23
0
        public void TestMethod1()
        {
            //Initial setup of desired capabilites
            AppiumOptions cap = new AppiumOptions();

            cap.AddAdditionalCapability("DeviceName", "Android");
            cap.AddAdditionalCapability("PlatformName", "Android");
            cap.AddAdditionalCapability("PlatformVersion", "19.0");
            cap.AddAdditionalCapability("uuid", "11160b8c2fea0303");
            cap.AddAdditionalCapability("AppPackage", "com.costar.marketingcenter.app");
            cap.AddAdditionalCapability("AppActivity", "com.costar.marketingcenter.app.feature.login.activities.LoginActivity");

            //setup the url for appium server
            driver = new AndroidDriver <IWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), cap);

            //driver = new AndroidDriver<IWebElement>(new Uri("http://0.0.0.0:4723/wd/hub"), cap);

            //gather information for my test
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(300);
            driver.FindElementById("com.costar.marketingcenter.app:id/editTextUsername").Clear();
            driver.FindElementById("com.costar.marketingcenter.app:id/editTextUsername").SendKeys("*****@*****.**");
            driver.FindElementById("com.costar.marketingcenter.app:id/editTextPassword").SendKeys("Semal@1972");
            driver.FindElementById("com.costar.marketingcenter.app:id/buttonLogin").Click();
        }
        public void AddNewItemWithNewCategory()
        {
            var capabilities = new AppiumOptions();

            capabilities.AddAdditionalCapability(MobileCapabilityType.App, "8b831c56-bc54-4a8b-af94-a448f80118e7_sezxftbtgh66j!App");
            capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Windows");
            capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "WindowsPC");

            var _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();

            _appiumLocalService.Start();
            var driver = new WindowsDriver <WindowsElement>(_appiumLocalService, capabilities);

            // Create new Category item first
            var categoryButton = driver.FindElement(MobileBy.AccessibilityId("AddCategory"));

            categoryButton.Click();

            // fill out the form for a new category
            var categoryName = driver.FindElement(MobileBy.AccessibilityId("categoryName"));

            categoryName.Clear();
            categoryName.SendKeys("New category from automation");

            //save category
            var saveCategory = driver.FindElement(MobileBy.AccessibilityId("Save"));

            saveCategory.Click();

            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("ItemDescription");

            elItemDetail.Clear();
            elItemDetail.SendKeys("These are the details");

            var elItemCategory = driver.FindElement(MobileBy.AccessibilityId("ItemCategory"));

            elItemCategory.Click();

            var categoryListItem = elItemCategory.FindElement(By.Name("New category from automation"));

            categoryListItem.Click();

            var elSave = driver.FindElementByAccessibilityId("Save");

            elSave.Click();
            elSave.ClearCache();

            //wait for progress bar to disapear
            var wait = new DefaultWait <WindowsDriver <WindowsElement> >(driver)
            {
                Timeout         = TimeSpan.FromSeconds(60),
                PollingInterval = TimeSpan.FromMilliseconds(500)
            };

            wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
            wait.Until(d => d.FindElementByName("Second item"));

            var listview = driver.FindElementByAccessibilityId("ItemsListView");

            //now use wait to scroll untill we find item
            wait = new DefaultWait <WindowsDriver <WindowsElement> >(driver)
            {
                Timeout         = TimeSpan.FromSeconds(60),
                PollingInterval = TimeSpan.FromMilliseconds(500)
            };
            wait.IgnoreExceptionTypes(typeof(NoSuchElementException));

            var elementfound = wait.Until(d =>
            {
                var input = new PointerInputDevice(PointerKind.Touch);
                ActionSequence FlickUp = new ActionSequence(input);
                FlickUp.AddAction(input.CreatePointerMove(listview, 0, 0, TimeSpan.Zero));
                FlickUp.AddAction(input.CreatePointerDown(MouseButton.Left));
                FlickUp.AddAction(input.CreatePointerMove(listview, 0, -300, TimeSpan.FromMilliseconds(200)));
                FlickUp.AddAction(input.CreatePointerUp(MouseButton.Left));
                driver.PerformActions(new List <ActionSequence>()
                {
                    FlickUp
                });

                return(d.FindElementByName("This is a new Item"));
            });

            Assert.IsTrue(elementfound != null);

            driver.CloseApp();
        }
Example #25
0
        private static void Main(string[] args)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            Console.WriteLine("Starting to measure speed...");

            DriverOptions driverOptions = new AppiumOptions();

            driverOptions.AddAdditionalCapability("platformName", "android");
            driverOptions.AddAdditionalCapability("platformVersion", "10");
            driverOptions.AddAdditionalCapability("automationName", "Appium");
            driverOptions.AddAdditionalCapability("deviceName", "Android Emulator");
            driverOptions.AddAdditionalCapability("unlockType", "pin");
            driverOptions.AddAdditionalCapability("unlockKey", "0000");
            driverOptions.AddAdditionalCapability("appPackage", "com.android.settings");
            driverOptions.AddAdditionalCapability("appActivity", ".Settings");
            driverOptions.AddAdditionalCapability("autoGrantPermissions", "true");
            driverOptions.AddAdditionalCapability("noSign", "true");

            Console.WriteLine("Starting Android-Driver!");
            double driverStartTime = watch.ElapsedMilliseconds;
            var    androidDriver   = new AndroidDriver <AppiumWebElement>(new Uri("http://localhost:4723/wd/hub"), driverOptions, TimeSpan.FromMinutes(5));

            Console.WriteLine($"It took <{watch.ElapsedMilliseconds - driverStartTime}> ms to start the driver...");
            Console.WriteLine("Getting UDID...");
            double udidStartTime = watch.ElapsedMilliseconds;
            string androidUdid   = androidDriver.Capabilities.GetCapability("deviceUDID").ToString().ToLower();

            Console.WriteLine($"It took <{watch.ElapsedMilliseconds - udidStartTime}> ms to get the udid <{androidUdid}>...");

            watch.Stop();
            Thread.Sleep(TimeSpan.FromSeconds(5));
            watch.Start();

            Console.WriteLine("Getting all Elements as a collection");
            double collectionStartTime = watch.ElapsedMilliseconds;
            var    coll = androidDriver.FindElementsByXPath("//*");

            Console.WriteLine($"It took <{watch.ElapsedMilliseconds - collectionStartTime}> ms to get the collection of elements...");

            Console.WriteLine("Getting all heights of the elements");
            double heightStartTime = watch.ElapsedMilliseconds;

            foreach (AppiumWebElement item in coll)
            {
                double elementHeightStartTime = watch.ElapsedMilliseconds;
                var    height = item.Size.Height;
                Console.WriteLine($"It took <{watch.ElapsedMilliseconds - elementHeightStartTime}> ms to get the following height <{height}> for item with id <{item.Id}>");
            }
            Console.WriteLine($"It took <{watch.ElapsedMilliseconds - heightStartTime}> ms to get the heights of all elements...");

            Console.WriteLine("Stopping the driver...");
            double quitStartTime = watch.ElapsedMilliseconds;

            androidDriver.Quit();
            Console.WriteLine($"It took <{watch.ElapsedMilliseconds - quitStartTime}> ms to stop the driver...");

            watch.Stop();
            Console.WriteLine($"It took <{watch.ElapsedMilliseconds}> ms to complete the run...");
            Console.WriteLine("Enter any key to close the application...");
            Console.Read();
        }
Example #26
0
        static void Main(string[] args)
        {
            Local browserStackLocal = null;

            AppiumOptions appiumOptions = new AppiumOptions();

            // Set your BrowserStack access credentials
            appiumOptions.AddAdditionalCapability("browserstack.user", userName);
            appiumOptions.AddAdditionalCapability("browserstack.key", accessKey);


            // Set URL of the application under test
            appiumOptions.AddAdditionalCapability("app", "bs://<app_id>");

            // Specify device and os_version
            appiumOptions.AddAdditionalCapability("device", "iPhone 11 Pro");
            appiumOptions.AddAdditionalCapability("os_version", "13");

            // Set browserstack.local capability as true
            appiumOptions.AddAdditionalCapability("browserstack.local", "true");

            // Specify the platform name
            appiumOptions.PlatformName = "iOS";

            // Set other BrowserStack capabilities
            appiumOptions.AddAdditionalCapability("project", "First CSharp project");
            appiumOptions.AddAdditionalCapability("build", "CSharp iOS local");
            appiumOptions.AddAdditionalCapability("name", "local_test");



            // if the platform is Windows, enable local testing fropm within the test
            // for Mac and GNU/Linux, run the local binary manually to enable local testing (see the docs)
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
                appiumOptions.ToCapabilities().HasCapability("browserstack.local") &&
                appiumOptions.ToCapabilities().GetCapability("browserstack.local").ToString() == "true")
            {
                browserStackLocal = new Local();
                List <KeyValuePair <string, string> > bsLocalArgs = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("key", accessKey)
                };
                browserStackLocal.start(bsLocalArgs);
            }


            // Initialize the remote Webdriver using BrowserStack remote URL
            // and desired capabilities defined above
            IOSDriver <IOSElement> driver = new IOSDriver <IOSElement>(new Uri("http://hub-cloud.browserstack.com/wd/hub"), appiumOptions);

            //Test case for sample iOS Local app.
            // If you have uploaded your app, update the test case here.
            IOSElement testButton = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
                SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("TestBrowserStackLocal"))
                );

            testButton.Click();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));

            wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.TextToBePresentInElementValue(driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")), "Response is: Up and running"));
            IOSElement resultElement = (IOSElement)driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal"));

            Console.WriteLine(resultElement.Text);

            //Invoke driver.quit() after the test is done to indicate that the test is completed.
            driver.Quit();

            //Stop the BrowserStack Local binary
            if (browserStackLocal != null)
            {
                browserStackLocal.stop();
            }
        }
Example #27
0
        static void Main(string[] args)
        {
            WindowsDriver <WindowsElement> sessionJpt;
            AppiumOptions appOptions = new AppiumOptions();

            appOptions.AddAdditionalCapability("app", @"C:\Program Files\TechnoStar\Jupiter-Pre_5.0\DCAD_main.exe");

            sessionJpt = new WindowsDriver <WindowsElement>(
                new Uri("http://127.0.0.1:4723"),
                appOptions
                );

            // IMPORT:

            /* var importCad = sessionJpt.FindElementByName("Import CAD");
             * action.MoveToElement(importCad);
             * action.MoveToElement(importCad, importCad.Size.Width/2, importCad.Size.Height/3 + 40).Click().Perform();
             *
             * sessionJpt.FindElementByName("VRML").Click();
             *
             * action.SendKeys(@"V:\Technologies\CS\UIAutomation\ScenarioTestDocs\SampleData\Block\Block.wrl");
             * action.SendKeys(Keys.Enter);
             * action.Perform();
             *
             * sessionJpt.FindElementByName("OK").Click();
             */
            sessionJpt.FindElementByName("Open...").Click();
            System.Threading.Thread.Sleep(3000);
            Actions action = new Actions(sessionJpt);

            action.SendKeys(@"V:\Technologies\CS\UIAutomation\ScenarioTestDocs\SampleData\Block\Block.jtdb");
            action.SendKeys(Keys.Enter);
            action.Perform();


            sessionJpt.FindElementByName("Mesh Cleanup").Click();
            sessionJpt.FindElementByName("Free Edges").Click();

            var allParts = sessionJpt.FindElementByName("All Parts");

            action = new Actions(sessionJpt);
            action.MoveToElement(allParts);
            action.Click();
            // Right Click
            action.ContextClick();
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            sessionJpt.FindElementByName("Apply").Click();

            action = new Actions(sessionJpt);
            action.SendKeys(Keys.Enter);
            action.Perform();

            sessionJpt.FindElementByName("Cancel").Click();
            sessionJpt.FindElementByName("Close Gaps").Click();

            action = new Actions(sessionJpt);
            action.MoveToElement(allParts);
            action.Click();
            action.ContextClick();
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            typeInBox(1001, 0.01, sessionJpt);

            sessionJpt.FindElementByName("OK").Click();


            sessionJpt.FindElementByName("Geometry").Click();
            sessionJpt.FindElementByName("Merge Entities").Click();
            action = new Actions(sessionJpt);
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            sessionJpt.FindElementByName("Home").Click();
            WindowsElement find = sessionJpt.FindElementByName("Find");

            action = new Actions(sessionJpt);
            action.MoveToElement(find);
            action.MoveToElement(find, find.Size.Width / 2, find.Size.Height / 3 + 40).Click();
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            int[] faceIdArr = { 321, 317, 316, 320, 333, 343, 354, 353, 342, 332, 328, 340, 350, 351, 341, 329 };

            WindowsElement idBox = sessionJpt.FindElementByAccessibilityId("1582");

            foreach (int faceId in faceIdArr)
            {
                InputId(faceId, idBox, action, sessionJpt, find);
            }

            sessionJpt.FindElementByName("OK").Click();

            sessionJpt.FindElementByName("Meshing").Click();

            WindowsElement localSettings = sessionJpt.FindElementByName("Local Settings");

            action = new Actions(sessionJpt);
            action.MoveToElement(localSettings);
            action.MoveToElement(localSettings, localSettings.Size.Width / 2 - 50, localSettings.Size.Height / 2)
            .Click();
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            action = new Actions(sessionJpt);
            action.SendKeys(Keys.Down);
            action.SendKeys(Keys.Enter);
            action.Perform();

            sessionJpt.FindElementByName("Home").Click();

            InputId(708, idBox, action, sessionJpt, find);
            InputId(698, idBox, action, sessionJpt, find);

            sessionJpt.FindElementByName("Mesh Size").Click();
            typeInBox(1006, 4, sessionJpt);
            typeInBox(1007, 1, sessionJpt);
            typeInBox(1008, 8, sessionJpt);

            sessionJpt.FindElementByName("Apply").Click();

            InputId(1, idBox, action, sessionJpt, find);
            InputId(2, idBox, action, sessionJpt, find);
            InputId(3, idBox, action, sessionJpt, find);
            InputId(4, idBox, action, sessionJpt, find);

            sessionJpt.FindElementByName("Mesh Size").Click();
            sessionJpt.FindElementByName("Keep Entity").Click();
            sessionJpt.FindElementByName("OK").Click();


            sessionJpt.FindElementByName("Meshing").Click();
            sessionJpt.FindElementByName("Surface Meshing").Click();
            typeInBox(1001, 15, sessionJpt);
            typeInBox(1002, 1, sessionJpt);
            typeInBox(1003, 30, sessionJpt);
            typeInBox(1004, 1, sessionJpt);

            sessionJpt.FindElementByName("OK").Click();

            /*
             * System.Threading.Thread.Sleep(10000);
             *
             * WindowsElement completeDialog = sessionJpt.FindElementByName("Meshing Surf Meshing");
             * action = new Actions(sessionJpt);
             * action.MoveToElement(completeDialog);
             * action.MoveToElement(completeDialog, completeDialog.Size.Width / 2 + 70,
             *  completeDialog.Size.Height / 2 + 60)
             *  .Click();
             * action.Perform();
             */

            //sessionJpt.FindElementByName("OK").Click();
            System.Threading.Thread.Sleep(20000);
            var okBtns = sessionJpt.FindElementsByName("OK");

            if (okBtns[0].Location.Y < okBtns[1].Location.Y)
            {
                okBtns[0].Click();
            }
            else
            {
                okBtns[1].Click();
            }
            Debug.WriteLine(okBtns.Count);

            /*
             * foreach (WindowsElement okBtn in okBtns)
             * {
             *  Debug.WriteLine(okBtn.Location.Y);
             * }
             */
        }
Example #28
0
        public void Setup()
        {
            capabilities = new AppiumOptions();
            capabilities.AddAdditionalCapability("browserstack.user", Environment.GetEnvironmentVariable("browserstack.user"));
            capabilities.AddAdditionalCapability("browserstack.key", Environment.GetEnvironmentVariable("browserstack.key"));

            // Set URL of the application under test
            capabilities.AddAdditionalCapability("app", "bs://16ca59803e95ce5206916cb67469fd69189551f6");

            // Specify device and os_version
            capabilities.AddAdditionalCapability("device", "Google Pixel 3");
            capabilities.AddAdditionalCapability("os_version", "10.0");

            // Specify the platform name
            capabilities.PlatformName = "Android";

            // Set other BrowserStack capabilities
            capabilities.AddAdditionalCapability("project", "First CSharp project");
            capabilities.AddAdditionalCapability("build", "CSharp Android");
            capabilities.AddAdditionalCapability("name", "first_test");
            //capabilities = new AppiumOptions();
            //capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "6378e3f9");
            //capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
            //capabilities.AddAdditionalCapability(MobileCapabilityType.App, @"C:\Users\yyuur\AndroidStudioProjects\Practice8\app\build\outputs\apk\debug\app-debug.apk");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "com.example.practice8");
            capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, "com.example.practice8.ui.login.LoginActivity");
            capabilities.AddAdditionalCapability(MobileCapabilityType.NoReset, true);

            AndroidDriver <AndroidElement> driver = new AndroidDriver <AndroidElement>(
                new Uri("http://hub-cloud.browserstack.com/wd/hub"), capabilities);

            loginPage = new LoginPage(driver)
            {
                UsernameField = driver.FindElementById("com.example.practice8:id/username"),
                PasswordField = driver.FindElementById("com.example.practice8:id/password"),
                LoginButton   = driver.FindElementById("com.example.practice8:id/login")
            };
        }
        public static IOSDriver <IOSElement> GetDriver()
        {
            int retries = 5;

            string browserStackUrl             = Configurations.BrowserStackUrl;
            string browserstackLocalIdentifier = Environment.GetEnvironmentVariable("BROWSERSTACK_LOCAL_IDENTIFIER");
            string buildID  = Environment.GetEnvironmentVariable("CurrentBuildId");
            string customId = "ZonalIOSApp" + buildID;

            // Android only for now
            AppiumOptions opt = new AppiumOptions();

            opt.AddAdditionalCapability("os_version", "12");
            opt.AddAdditionalCapability("device", "iPad Pro 12.9 2018");
            opt.AddAdditionalCapability("browserstack.appium_version", "1.13.0");
            opt.AddAdditionalCapability("real_mobile", "true");
            opt.AddAdditionalCapability("browserstack.debug", "true");
            //opt.AddAdditionalCapability("acceptSslCerts", "false");
            opt.AddAdditionalCapability("browserstack.networkLogs", "false");
            opt.AddAdditionalCapability("deviceOrientation", "landscape");
            opt.AddAdditionalCapability("browserstack.user", Configurations.BrowserStackUserName);
            opt.AddAdditionalCapability("browserstack.key", Configurations.BrowserStackAccessKey);
            opt.AddAdditionalCapability("browserstack.video", "true");

            // this will let application uninstall after every test run
            opt.AddAdditionalCapability("noReset", "true");

            // hashed app-id changes with every upload, using Custom ID for now
            // IMP: SET THIS TO YOUR LOCAL TUNNEL NAME FOR LOCAL RUNS
            opt.AddAdditionalCapability("app", customId);

            IOSDriver <IOSElement> driver = null;

            while (true)
            {
                try
                {
                    driver = new IOSDriver <IOSElement>(new Uri(browserStackUrl), opt);
                    break;
                }
                catch (WebDriverException e)
                {
                    driver.Quit();
                    Console.WriteLine("Failed to start the IOS driver. Attempt: " + retries);
                    Console.WriteLine(e);
                    if (--retries == 0)
                    {
                        throw;
                    }
                    else
                    {
                        // do nothing
                    }
                }
            }
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);

            return(driver);
        }
Example #30
0
        protected void initDriver(string device, string app)
        {
            AppiumOptions options = new AppiumOptions();

            options.AddAdditionalCapability(MobileCapabilityType.AppiumVersion, "1.17.1");
            options.AddAdditionalCapability(MobileCapabilityType.PlatformName, DEVICES[device]["platformName"]);
            options.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, DEVICES[device]["platformVersion"]);
            options.AddAdditionalCapability(MobileCapabilityType.DeviceName, DEVICES[device]["deviceName"]);
            if (DEVICES[device].ContainsKey("deviceOrientation"))
            {
                options.AddAdditionalCapability("deviceOrientation", DEVICES[device]["deviceOrientation"]);
            }
            else
            {
                options.AddAdditionalCapability("deviceOrientation", "portrait");
            }
            options.AddAdditionalCapability("browserName", "");

            options.AddAdditionalCapability("phoneOnly", false);
            options.AddAdditionalCapability("tabletOnly", false);
            options.AddAdditionalCapability("privateDevicesOnly", false);

            options.AddAdditionalCapability(MobileCapabilityType.App, app);

            string url = null;

            if (DEVICES[device].ContainsKey("sauce"))
            {
                options.AddAdditionalCapability("username", CREDENTIALS["sauce"]["username"]);
                options.AddAdditionalCapability("accesskey", CREDENTIALS["sauce"]["access_key"]);
                url = SAUCE_SERVER_URL;
            }
            options.AddAdditionalCapability("name", "Android Demo");

            options.AddAdditionalCapability("idleTimeout", 300);

            switch (DEVICES[device]["platformName"])
            {
            case "Android":
                driver = new AndroidDriver <AppiumWebElement>(
                    new Uri(url), options, TimeSpan.FromMinutes(5));
                break;

            case "iOS":
                driver = new IOSDriver <AppiumWebElement>(
                    new Uri(url), options, TimeSpan.FromMinutes(5));
                break;
            }
        }