예제 #1
0
        public void FoundByClass()
        {
            string url       = "http://testing.todvachev.com/selectors/class-name/";
            string ClassName = "testClass";

            try
            {
                driver.Navigate().GoToUrl(url);
                IWebElement element = driver.FindElement(By.ClassName(ClassName));
                if (element.Displayed)
                {
                    mColor.GreenMessage("Found the element By class " + ClassName + "");
                    mColor.GreenMessage(element.Text);
                }
            }
            catch (NoSuchElementException)
            {
                mColor.ReadMessage("Element via this className does not exist");
            }
        }
예제 #2
0
        public void checkInbox()
        {
            string       url     = "http://testing.todvachev.com/special-elements/text-input-field/";
            string       name    = "username";
            IWebDriver   driver1 = new ChromeDriver();
            MessageColor mColor  = new MessageColor();

            driver1.Navigate().GoToUrl(url);
            try
            {
                IWebElement elment = driver1.FindElement(By.Name(name));
                elment.SendKeys("Hello here is texts");
                Thread.Sleep(5000);
                mColor.GreenMessage(elment.Text);
                mColor.GreenMessage("The maxlength of the Input field == " + elment.GetAttribute("maxlength"));
                driver1.Quit();
            }
            catch (NoSuchElementException) {
                mColor.GreenMessage("The elwmwnt is not present on the page. :(");
                driver1.Quit();
            }
        }