當前位置: 首頁>>代碼示例>>C#>>正文


C# InternetExplorerDriver.FindElementByClassName方法代碼示例

本文整理匯總了C#中OpenQA.Selenium.IE.InternetExplorerDriver.FindElementByClassName方法的典型用法代碼示例。如果您正苦於以下問題:C# InternetExplorerDriver.FindElementByClassName方法的具體用法?C# InternetExplorerDriver.FindElementByClassName怎麽用?C# InternetExplorerDriver.FindElementByClassName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenQA.Selenium.IE.InternetExplorerDriver的用法示例。


在下文中一共展示了InternetExplorerDriver.FindElementByClassName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestBookSearch

        public void TestBookSearch()
        {
            //First step is browse to website and go to search page.
            System.IO.File.WriteAllText("result.txt","");
            driver = new InternetExplorerDriver();
            driver.Manage().Window.Maximize();
            driver.Navigate().GoToUrl("paratabplus.cloudapp.net");
            driver.FindElementByClassName("menulist").FindElement(By.CssSelector("li a[href=\"/BookSearch/\"]")).Click();
            Assert.AreEqual("Search", driver.Title);
            IWebElement form;
            //-----------------------------------
            /* Next step is find book from define keywords then submit
             * measure time from result that display in grey character on find result(if search result is found.)
             * record it and use these measure data to summarize.
             */
            driver.FindElementByName("Keyword").Clear();
            driver.FindElementByName("Keyword").SendKeys("COM-FL2-2812");
            driver.FindElementByTagName("select").Click();
            driver.Keyboard.SendKeys(Keys.Down);
            driver.Keyboard.SendKeys(Keys.Enter);
            form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
            form.Submit();
            AssertSearchResult("Call no:COM-FL2-2812");

            driver.FindElementByName("Keyword").Clear();
            driver.FindElementByName("Keyword").SendKeys("Computer");
            driver.FindElementByTagName("select").Click();
            driver.Keyboard.SendKeys(Keys.Down);
            driver.Keyboard.SendKeys(Keys.Enter);
            form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
            form.Submit();
            AssertSearchResult("Bookname:Computer");

            driver.FindElementByName("Keyword").Clear();
            driver.FindElementByName("Keyword").SendKeys("James");
            driver.FindElementByTagName("select").Click();
            driver.Keyboard.SendKeys(Keys.Down);
            driver.Keyboard.SendKeys(Keys.Enter);
            form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
            form.Submit();
            AssertSearchResult("Author:James");

            driver.FindElementByName("Keyword").Clear();
            driver.FindElementByName("Keyword").SendKeys("shogakukan");
            driver.FindElementByTagName("select").Click();
            driver.Keyboard.SendKeys(Keys.Down);
            driver.Keyboard.SendKeys(Keys.Enter);
            form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
            form.Submit();
            AssertSearchResult("Publisher:shogakukan");

            driver.FindElementByName("Keyword").Clear();
            driver.FindElementByName("Keyword").SendKeys("1995");
            driver.FindElementByTagName("select").Click();
            driver.Keyboard.SendKeys(Keys.Down);
            driver.Keyboard.SendKeys(Keys.Enter);
            form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
            form.Submit();
            AssertSearchResult("Year:1995");

            //-----------------------------------
            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("NOV");
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("Sword Art Online Aincrad");
            driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").SendKeys("Reki Kawahara");
            driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").SendKeys("Zenshu");
            driver.FindElementByCssSelector("form[action=\"/BookSearch/Advance\"] input[type=\"submit\"]").Click();
            AssertSearchResult("\r\nCall no:NOV\r\nBookname:Sword Art Online Aincrad\r\nAuthor:Reki Kawahara\r\n" +
                "Publisher:Zenshu\r\nYear:null");

            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").Clear();
            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("PE-FL1-0005");
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("Football training");
            driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").SendKeys("Graham Taylor");
            driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").SendKeys("Leopard Books");
            driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").SendKeys("1995");
            driver.FindElementByCssSelector("form[action=\"/BookSearch/Advance\"] input[type=\"submit\"]").Click();
            AssertSearchResult("\r\nCall no:PE-FL1-0005\r\nBookname:Football training\r\nAuthor:Graham Taylor\r\n" +
                "Publisher:Leopard Books\r\nYear:1995");

            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").Clear();
            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("MAT");
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("Theory of computation");
            driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").SendKeys("รศ.ดร.เกียรติกูล เจียรนัยธนะกิจ");
            driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").SendKeys("2009");
            driver.FindElementByCssSelector("form[action=\"/BookSearch/Advance\"] input[type=\"submit\"]").Click();
            AssertSearchResult("\r\nCall no:MAT\r\nBookname:Theory of computation\r\nAuthor:รศ.ดร.เกียรติกูล เจียรนัยธนะกิจ\r\n" +
                "Publisher:null\r\nYear:2009");

            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").Clear();
            driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("NOV");
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").Clear();
            driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("นิทาน");
//.........這裏部分代碼省略.........
開發者ID:worldeditor1,項目名稱:Lib_booksys,代碼行數:101,代碼來源:BookSearchEvaluation.cs


注:本文中的OpenQA.Selenium.IE.InternetExplorerDriver.FindElementByClassName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。