static void Main(string[] args)
        {
            CBTAPI cbt = new CBTAPI(username, authkey);

            Dictionary <string, object> myCaps = new Dictionary <string, object>();

            myCaps.Add("name", "Basic Example test");
            myCaps.Add("recordVideo", "false");
            ICapabilities   caps   = cbt.GetCapabilitiesFromBrowserName("firefox", "latest", "Windows 10", myCaps);
            RemoteWebDriver driver = new RemoteWebDriver(new Uri("https://hub.crossbrowsertesting.com:443/wd/hub"), caps, TimeSpan.FromSeconds(180));

            try
            {
                driver.Navigate().GoToUrl("http://crossbrowsertesting.github.io/selenium_example_page.html");
                cbt.TakeSnapshot(driver.SessionId.ToString());
                cbt.SetScore(driver.SessionId.ToString(), "pass");
            } catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                cbt.SetScore(driver.SessionId.ToString(), "fail");
            } finally
            {
                driver.Quit();
            }
        }
        static void Main(string[] args)
        {
            CBTAPI cbt = new CBTAPI(username, authkey);

            Dictionary <string, object> myCaps = new Dictionary <string, object>();

            myCaps.Add("name", "My test");
            myCaps.Add("recordVideo", "false");
            ICapabilities   caps   = cbt.GetCapabilitiesFromBrowserName("chrome", "latest", "Windows 10", myCaps);
            RemoteWebDriver driver = new RemoteWebDriver(new Uri("https://hub.crossbrowsertesting.com:443/wd/hub"), caps, TimeSpan.FromSeconds(180));

            try
            {
                driver.Navigate().GoToUrl("http://crossbrowsertesting.github.io/todo-app.html");
                // Check the title
                Console.WriteLine("Clicking Checkbox");
                driver.FindElementByName("todo-4").Click();
                Console.WriteLine("Clicking Checkbox");
                driver.FindElementByName("todo-5").Click();

                // If both clicks worked, then te following List should have length 2
                IList <IWebElement> elems = driver.FindElementsByClassName("done-true");

                Console.WriteLine("Entering Text");
                driver.FindElementById("todotext").SendKeys("Run your first Selenium Test");
                driver.FindElementById("addbutton").Click();


                // lets also assert that the new todo we added is in the list
                string spanText = driver.FindElementByXPath("/html/body/div/div/div/ul/li[6]/span").Text;
                Console.WriteLine("Archiving old todos");
                driver.FindElementByLinkText("archive").Click();

                elems = driver.FindElementsByClassName("done-false");
                Assert.AreEqual(4, elems.Count);
                cbt.TakeSnapshot(driver.SessionId.ToString());
                cbt.SetScore(driver.SessionId.ToString(), "pass");
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                cbt.SetScore(driver.SessionId.ToString(), "fail");
            }
            finally
            {
                driver.Quit();
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            CBTAPI cbt = new CBTAPI(username, authkey);

            Dictionary <string, object> myCaps = new Dictionary <string, object>();

            myCaps.Add("name", "Login Form Example Test");
            myCaps.Add("recordVideo", "false");
            ICapabilities   caps   = cbt.GetCapabilitiesFromBrowserName("internet explorer", "11", "Windows 10", myCaps);
            RemoteWebDriver driver = new RemoteWebDriver(new Uri("https://hub.crossbrowsertesting.com:443/wd/hub"), caps, TimeSpan.FromSeconds(180));

            try
            {
                driver.Navigate().GoToUrl("http://crossbrowsertesting.github.io/login-form.html");
                // Check the title
                Console.WriteLine("Entering username");
                driver.FindElementByName("username").SendKeys("*****@*****.**");

                // then by entering the password
                Console.WriteLine("Entering password");
                driver.FindElementByName("password").SendKeys("test123");

                // then by clicking the login button
                Console.WriteLine("Logging in");
                driver.FindElementByCssSelector("div.form-actions > button").Click();

                // let's wait here to ensure that the page has loaded completely
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
                wait.Until(drv => driver.FindElement(By.XPath("//*[@id=\"logged-in-message\"]/h2")));

                // Let's assert that the welcome message is present on the page.
                // if not, an exception will be raised and we'll set the score to fail in the catch block.
                string welcomeMessage = driver.FindElementByXPath("//*[@id=\"logged-in-message\"]/h2").Text;
                Assert.AreEqual("Welcome [email protected]", welcomeMessage);
                cbt.TakeSnapshot(driver.SessionId.ToString());
                cbt.SetScore(driver.SessionId.ToString(), "pass");
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                cbt.SetScore(driver.SessionId.ToString(), "fail");
            }
            finally
            {
                driver.Quit();
            }
        }