Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            AppiumOptions caps = new AppiumOptions();

            caps.AddAdditionalCapability("browserstack.user", userName);
            caps.AddAdditionalCapability("browserstack.key", accessKey);
            caps.AddAdditionalCapability("device", "Samsung Galaxy S10e");
            caps.AddAdditionalCapability("os_version", "9.0");
            caps.AddAdditionalCapability("project", "My First Project");
            caps.AddAdditionalCapability("build", "My First Build");
            caps.AddAdditionalCapability("name", "Bstack-[C#] Sample Test");
            caps.AddAdditionalCapability("app", "bs://ae2ce961fcec8d8c04b9d84b93848b100eab5b41");

            AndroidDriver <AndroidElement> driver = new AndroidDriver <AndroidElement>(new Uri("http://hub-cloud.browserstack.com/wd/hub"), caps);
            AndroidElement searchElement          = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
                ExpectedConditions.ElementToBeClickable(MobileBy.Id("com.getzuper.debug:id/input_email"))
                );

            searchElement.Click();

            searchElement.SendKeys("*****@*****.**");

            AndroidElement confirmButton = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
                ExpectedConditions.ElementToBeClickable(MobileBy.Id("com.getzuper.debug:id/bt_confirm")));

            confirmButton.Click();
            System.Threading.Thread.Sleep(30);

            driver.Quit();
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            DesiredCapabilities caps = new DesiredCapabilities();

            caps.SetCapability("browserstack.user", userName);
            caps.SetCapability("browserstack.key", accessKey);

            caps.SetCapability("realMobile", true);
            caps.SetCapability("device", "Google Pixel");
            caps.SetCapability("app", "bs://<hashed app-id>");

            AndroidDriver <AndroidElement> driver = new AndroidDriver <AndroidElement>(new Uri("http://hub.browserstack.com/wd/hub"), caps);
            AndroidElement searchElement          = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
                ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Search Wikipedia"))
                );

            searchElement.Click();
            AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
                ExpectedConditions.ElementToBeClickable(MobileBy.Id("org.wikipedia.alpha:id/search_src_text"))
                );

            insertTextElement.SendKeys("BrowserStack");
            System.Threading.Thread.Sleep(5000);
            driver.Quit();
        }
Exemplo n.º 3
0
        public AndroidElement FindById(string id)
        {
            AndroidElement element = (AndroidElement) new WebDriverWait(
                driver, TimeSpan.FromSeconds(30)).Until(
                SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(
                    MobileBy.Id(id))
                );

            return(element);
        }
        static void Main(string[] args)
        {
            AppiumOptions caps = new AppiumOptions();

            // Set your BrowserStack access credentials
            caps.AddAdditionalCapability("browserstack.user", "YOUR_USERNAME");
            caps.AddAdditionalCapability("browserstack.key", "YOUR_ACCESS_KEY");

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

            // Specify device and os_version
            caps.AddAdditionalCapability("device", "Google Pixel 3");
            caps.AddAdditionalCapability("os_version", "9.0");

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

            // Set other BrowserStack capabilities
            caps.AddAdditionalCapability("project", "First CSharp project");
            caps.AddAdditionalCapability("build", "CSharp Android");
            caps.AddAdditionalCapability("name", "first_test");


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

            // Test case for the BrowserStack sample Android app.
            // If you have uploaded your app, update the test case here.
            AndroidElement searchElement = (AndroidElement) new WebDriverWait(
                driver, TimeSpan.FromSeconds(30)).Until(
                SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(
                    MobileBy.AccessibilityId("Search Wikipedia"))
                );

            searchElement.Click();
            AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(
                driver, TimeSpan.FromSeconds(30)).Until(
                SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(
                    MobileBy.Id("org.wikipedia.alpha:id/search_src_text"))
                );

            insertTextElement.SendKeys("BrowserStack");
            System.Threading.Thread.Sleep(5000);

            IReadOnlyList <AndroidElement> allTextViewElements =
                driver.FindElementsByClassName("android.widget.TextView");

            Console.WriteLine(allTextViewElements.Count > 0);

            // Invoke driver.quit() after the test is done to indicate that the test is completed.
            driver.Quit();
        }
        public void AddOneSet()
        {
            AndroidDriver <AppiumWebElement> driver = StartApp();

            var el1 = driver.FindElement(MobileBy.Id("button_toggle_volume"));

            el1.Click();

            var setNumber         = driver.FindElement(MobileBy.Id("edit_number_sets"));
            var numberOfSets      = setNumber.Text;
            var expectedSetNumber = "3";

            Assert.IsTrue(numberOfSets == expectedSetNumber);
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            Local local = new Local();

            List <KeyValuePair <string, string> > options = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("key", accessKey)
            };

            local.start(options);

            DesiredCapabilities caps = new DesiredCapabilities();

            caps.SetCapability("browserstack.user", userName);
            caps.SetCapability("browserstack.key", accessKey);

            caps.SetCapability("device", "Google Pixel");
            caps.SetCapability("browserstack.local", true);
            caps.SetCapability("app", "bs://<hashed app-id>");

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

            AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
                ExpectedConditions.ElementToBeClickable(MobileBy.Id("com.example.android.basicnetworking:id/test_action"))
                );

            searchElement.Click();
            AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
                ExpectedConditions.ElementToBeClickable(MobileBy.ClassName("android.widget.TextView"))
                );

            AndroidElement testElement = null;

            IReadOnlyList <AndroidElement> allTextViewElements = driver.FindElementsByClassName("android.widget.TextView");

            System.Threading.Thread.Sleep(5000);
            foreach (AndroidElement textElement in allTextViewElements)
            {
                if (textElement.Text.Contains("The active connection is"))
                {
                    testElement = textElement;
                }
            }

            Console.WriteLine(testElement.Text);

            driver.Quit();
            local.stop();
        }
        public void Click(string text)
        {
            AndroidElement el = driver.FindElement(MobileBy.Id(GetElementByText(text).Id));

            el.Tap(1, 10);
        }
Exemplo n.º 8
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", "Google Pixel 3");
            appiumOptions.AddAdditionalCapability("os_version", "9.0");

            appiumOptions.AddAdditionalCapability("browserstack.local", "true");

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

            // Set other BrowserStack capabilities
            appiumOptions.AddAdditionalCapability("project", "First CSharp project");
            appiumOptions.AddAdditionalCapability("build", "CSharp Android 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
            AndroidDriver <AndroidElement> driver = new AndroidDriver <AndroidElement>(
                new Uri("http://hub-cloud.browserstack.com/wd/hub"), appiumOptions);

            // Test case for the BrowserStack sample Android Local app.
            // If you have uploaded your app, update the test case here.
            AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
                SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.Id("com.example.android.basicnetworking:id/test_action"))
                );

            searchElement.Click();
            AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
                SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.ClassName("android.widget.TextView"))
                );

            AndroidElement testElement = null;

            IReadOnlyList <AndroidElement> allTextViewElements = driver.FindElementsByClassName("android.widget.TextView");

            System.Threading.Thread.Sleep(5000);
            foreach (AndroidElement textElement in allTextViewElements)
            {
                if (textElement.Text.Contains("The active connection is"))
                {
                    testElement = textElement;
                }
            }

            Console.WriteLine(testElement.Text);
            // Invoke driver.quit() after the test is done to indicate the test is completed.
            driver.Quit();

            // Stop the BrowserStack Local Binary.
            if (browserStackLocal != null)
            {
                browserStackLocal.stop();
            }
        }