当前位置: 首页>>代码示例>>C#>>正文


C# ChromeDriver.Close方法代码示例

本文整理汇总了C#中OpenQA.Selenium.Chrome.ChromeDriver.Close方法的典型用法代码示例。如果您正苦于以下问题:C# ChromeDriver.Close方法的具体用法?C# ChromeDriver.Close怎么用?C# ChromeDriver.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenQA.Selenium.Chrome.ChromeDriver的用法示例。


在下文中一共展示了ChromeDriver.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestWithImplicitWait

        public void TestWithImplicitWait()
        {
            //Go to the Demo AjAX Application
            IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver");
            driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/AjaxDemo.html");

            //Set the Implicit Wait time Out to 10 Seconds
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

             		    try {

             			    //Get link for Page 4 and click on it
             			    IWebElement page4button = driver.FindElement(By.LinkText("Page 4"));
             			    page4button.Click();

             			    //Get an element with id page4 and verify it's text
             			    IWebElement message = driver.FindElement(By.Id("page4"));
             			    Assert.IsTrue(message.Text.Contains("Nunc nibh tortor"));
             		    }
            catch (NoSuchElementException e)
            {
             			    Assert.Fail("Element not found!!");
             		    }
            finally
            {
                driver.Close();
             		    }
        }
开发者ID:vikramuk,项目名称:Selenium,代码行数:28,代码来源:ImplicitWaitTest.cs

示例2: TestExplicitWait

        public void TestExplicitWait()
        {
            IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver");
            driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/AjaxDemo.html");

            try
            {
             			    IWebElement page4button = driver.FindElement(By.LinkText("Page 4"));
             			    page4button.Click();

               WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
               IWebElement message = wait.Until<IWebElement>((d) =>
               {
                    return d.FindElement(By.Id("page4"));
               });

             			    Assert.IsTrue(message.Text.Contains("Nunc nibh tortor"));

             		    }
            catch (NoSuchElementException e)
            {
             			    Assert.Fail("Element not found!!");
             		    } finally {
             			    driver.Close();
             		    }
        }
开发者ID:oluk68,项目名称:SELENIUM2,代码行数:26,代码来源:ExplicitWaitTests.cs

示例3: HomepageLoads_CalendarIsReachable

        public void HomepageLoads_CalendarIsReachable()
        {
            // Instantiate a new web driver to run the test

            //Implicit Path (Default)
            IWebDriver driver = new ChromeDriver();

            //Explicit Path
            //IWebDriver driver = new ChromeDriver("\\\\psf\\Home\\Documents\\GitHubVisualStudio\\imentor\\UnitTests\\");

            // Instruct the driver to throw an error if it has to wait more than 5 seconds for retrieval, then go to URL
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
            driver.Navigate().GoToUrl("https://imast.azurewebsites.net");

            // To verify that the homepage is online and reachable, we save the url after navigating and check it
            String HomeUrl = driver.Url;
            Assert.AreEqual("https://imast.azurewebsites.net/#!/", HomeUrl);

            // Our home page is the Listings page. Test that it has loaded by comparing the title element to "Listings"
            String PrimaryHeader = driver.FindElement(By.ClassName("im-form-label")).Text;
            Assert.AreEqual("Upcoming Events", PrimaryHeader);

            // Our home page also has a collection of filters. Test that they have loaded by checking their text tags.

            String FilterHeader = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[1]/div")).Text;
            String FilterMath = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[2]/div/div[1]")).Text;
            String FilterScience = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[3]/div/div")).Text;
            String FilterHistory = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[4]/div/div")).Text;
            String FilterReading = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[5]/div/div")).Text;
            String FilterCompSci = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[6]/div/div")).Text;

            // Assert that all the text tags are correct.
            Assert.AreEqual("Subjects", FilterHeader);
            Assert.AreEqual("Math", FilterMath);
            Assert.AreEqual("Science", FilterScience);
            Assert.AreEqual("History", FilterHistory);
            Assert.AreEqual("Reading", FilterReading);
            Assert.AreEqual("Computer Science", FilterCompSci);

            // Next we find the Calendar Button and click it to navigate to the Calendar
            IWebElement CalendarButton = driver.FindElement(By.ClassName("glyphicon-calendar"));
            CalendarButton.Click();

            // To verify that the calendar loaded, we check the "today button"
            String Today = driver.FindElement(By.ClassName("fc-today-button")).Text;
            Assert.AreEqual("today", Today);

            // Also verify the other calendar buttons, month, week, and day.
            String Month = driver.FindElement(By.ClassName("fc-month-button")).Text;
            Assert.AreEqual("month", Month);

            String Week = driver.FindElement(By.ClassName("fc-basicWeek-button")).Text;
            Assert.AreEqual("week", Week);

            String Day = driver.FindElement(By.ClassName("fc-basicDay-button")).Text;
            Assert.AreEqual("day", Day);

            // End the test by closing the browser
            driver.Close();
        }
开发者ID:SCCapstone,项目名称:imentor,代码行数:60,代码来源:PageBehaviorTests.cs

示例4: Main

        static void Main(string[] args)
        {
            // create an instance of webdriver
            IWebDriver driver = new ChromeDriver();

            // go to web page
            driver.Navigate().GoToUrl("http://www.thetestroom.com/webapp");

            // click on the about link
            driver.FindElement(By.Id("about_link")).Click();

            // check that the about page has the about zoo title
            String title = driver.Title;

            if (title.Equals("About Zoo"))
            {
                Console.WriteLine("Found the about page with the value of " + title);
            }
            else
            {
                Console.WriteLine("Instead found page with: " + title);
            }

            // close the driver
            driver.Close();
        }
开发者ID:fergonus,项目名称:java-unit-csharp,代码行数:26,代码来源:Program.cs

示例5: GetData

         //碳结圆钢价格行情
         public static void GetData(string linkName, int marketId)
         { 
             IWebDriver driver = new ChromeDriver();
             try
             {
                 driver.Manage().Window.Maximize();
                 driver.Navigate().GoToUrl("http://www.mysteel.com/");
                 var userName = driver.FindElement(By.Name("my_username"));
                 userName.SendKeys("tx6215");
                 var password = driver.FindElement(By.Name("my_password"));
                 password.SendKeys("tx6215");
                 userName.Submit();
                 var steel = driver.FindElement(By.LinkText("结构钢"));
                 driver.Navigate().GoToUrl(steel.GetAttribute("href"));
                 Thread.Sleep(2000);

                 var carbonRound = driver.FindElement(By.LinkText("碳圆"));
                 driver.Navigate().GoToUrl(carbonRound.GetAttribute("href"));
                 Thread.Sleep(2000);
                 var date = DateTime.Now.Day + "日";
                 GetPage(driver, linkName, marketId);
             }
             finally
             {
                 driver.Close();
                 driver.Quit();
             }
         }
开发者ID:jesusblessf6,项目名称:AutoPrice,代码行数:29,代码来源:CarbonRoundBase.cs

示例6: TestJavaScript

        public void TestJavaScript()
        {
            IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver\");
            driver.Navigate().GoToUrl("http://www.google.com");

            Screenshot screenshot = ((ITakesScreenshot)driver).GetScreenshot();
            screenshot.SaveAsFile(@"c:\temp\main_page.png", System.Drawing.Imaging.ImageFormat.Png);

            driver.Close();
        }
开发者ID:oluk68,项目名称:SELENIUM2,代码行数:10,代码来源:ScreenShotTest.cs

示例7: SimpleLoginTest

        public void SimpleLoginTest()
        {
            IWebDriver driver;
                //driver = new FirefoxDriver();

                //internet explorer needs the path to it's
                //helper executable ...but don't worry, you won't
                //want to use IE for reasons that'll become very
                //evident...!
                //driver = new InternetExplorerDriver(@"c:\grid2");

                //chrome needs chromedriver.exe ... parameter is the PATH
                //to wherever the .exe is...
                driver = new ChromeDriver(@"c:\grid2");

                #region waitforit..
                //sometimes selenium jumps the gun and declares an element isn't available
                //when, if it'd just wait a second (or 10) the element would be available.
                //here we tell selenium to hold it's horses and wait a cotton pickin' minute
                //if it can't find something, wait up to 10 seconds for it to appear
                //driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
                #endregion //waitforit..

                driver.Url = "http://localhost:54836";
                driver.Navigate();

                var loginLink = driver.FindElement(By.LinkText("Log On"));

                Assert.IsNotNull(loginLink);

                #region i can haz login?
                /*loginLink.Click();
                var usernameEntry = driver.FindElement(By.Id("UserName"));
                var passwordEntry = driver.FindElement(By.Id("Password"));
                var logOnButton = driver.FindElement(By.XPath("//input[@value='Log On']"));

                Assert.NotNull(usernameEntry);
                Assert.NotNull(passwordEntry);
                Assert.NotNull(logOnButton);

                usernameEntry.SendKeys("test002");
                passwordEntry.SendKeys("test002");
                logOnButton.Click();

                var logoffLink = driver.FindElement(By.LinkText("Log Off"));
                Assert.NotNull(logoffLink,"log off element not found");
            */
                #endregion i can haz login?

                driver.Close();
                driver.Quit();
        }
开发者ID:adbacker,项目名称:selenium2_quickstarts,代码行数:52,代码来源:LoginTest.cs

示例8: TestExplicitWaitByTitle

        public void TestExplicitWaitByTitle()
        {
            IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver");
            driver.Navigate().GoToUrl("http://www.google.com");
            IWebElement query = driver.FindElement(By.Name("q"));
            query.SendKeys("selenium");
            query.Submit();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            wait.Until((d) => { return d.Title.ToLower().StartsWith("selenium"); });
            Assert.IsTrue(driver.Title.ToLower().StartsWith("selenium"));
            driver.Close();
        }
开发者ID:oluk68,项目名称:SELENIUM2,代码行数:13,代码来源:ExplicitWaitTests.cs

示例9: ExecuteTest

        public void ExecuteTest()
        {
            IWebDriver driver = new ChromeDriver();
            driver.Navigate().GoToUrl("http://google.com");

            IWebElement element = driver.FindElement(By.Name("q"));

            element.SendKeys("selenium example using c#");

            Console.WriteLine("Executed Test");

            driver.Close();
            driver.Quit();
        }  
开发者ID:RemkoTestProject,项目名称:SeleniumDemo,代码行数:14,代码来源:Program.cs

示例10: TestDragDrop

        public void TestDragDrop()
        {
            IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver\");
            driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/DragDropDemo.html");

            IWebElement source = driver.FindElement(By.Id("draggable"));
            IWebElement target = driver.FindElement(By.Id("droppable"));

            Actions builder = new Actions(driver);
            builder.DragAndDrop(source, target).Perform();
            Assert.AreEqual("Dropped!", target.Text);

            driver.Close();
        }
开发者ID:vikramuk,项目名称:Selenium,代码行数:14,代码来源:DragDropTest.cs

示例11: TestThatGoogleFindsJavaNotCsharp

 public void TestThatGoogleFindsJavaNotCsharp()
 {
     ChromeOptions options = new ChromeOptions();
     options.AddArgument("--no-sandbox");
     options.AddArgument("--disable-extensions");
     options.AddArgument("--start-maximized");
     IWebDriver driver = new ChromeDriver(options);
     driver.Navigate().GoToUrl("http://google.com");
     driver.FindElement(By.Id("lst-ib")).SendKeys("Java");
     driver.FindElement(By.Name("btnK")).Submit();
     Thread.Sleep(1000);
     Assert.IsTrue(driver.FindElement(By.CssSelector("#rso > div > div:nth-child(1) > div > h3 > a")).Text.Contains("Java"));
     Assert.IsFalse(driver.FindElement(By.CssSelector("#rso > div > div:nth-child(1) > div > h3 > a")).Text.Contains("C#"));
     driver.Close();
 }
开发者ID:Lampart071,项目名称:FirstTestSolved,代码行数:15,代码来源:GoogleTests.cs

示例12: TestJavaScript

        public void TestJavaScript()
        {
            IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver\");
            driver.Navigate().GoToUrl("http://www.google.com");

            IJavaScriptExecutor js = (IJavaScriptExecutor) driver;

            String title = (String)js.ExecuteScript("return document.title");
            Assert.AreEqual("Google", title);

            long links = (long)js.ExecuteScript("var links = document.getElementsByTagName('A'); return links.length");
            Assert.AreEqual(41, links); //Count of links may change

            driver.Close();
        }
开发者ID:oluk68,项目名称:SELENIUM2,代码行数:15,代码来源:JavaScriptTest.cs

示例13: Manipulate

        public void Manipulate()
        {
            ChromeDriver driver = new ChromeDriver();
            HelpFunctions H = new HelpFunctions();

             H.Navigate("http://us14.chatzy.com/37785015405504", driver);
            H.Navigate("http://us14.chatzy.com", driver);
            driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 100));
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
            IWebElement element = null;
               //= wait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("X967")));

            H.Button("//*[@id='X313']", driver);//Login/SignUp
            driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
            element = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@id='X603']")));

            H.InputInfo("//*[@id='X603']", "[email protected]", driver);//add email
            driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));

            H.Button("//*[@id='X6001']", driver); // choose the "I am regitered user"
            driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));

            H.InputInfo("//*[@id='X604']", "Amber001", driver); //Enter in the password
            driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));

            H.Button("//*[@id='X593']", driver); //click the ok button

            element = wait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("X967")));
            H.Navigate("http://us14.chatzy.com/37785015405504", driver);

            H.Button("//*[@id='X593']", driver); //click the enter room button
            H.Button("//*[@id='X1049']", driver);

            var chat = driver.FindElementById("X184");
               // System.Collections.ObjectModel.ReadOnlyCollection<IWebElement> chat = driver.FindElementsByClassName("a");
               // chat.ToString();

            List<string> Temp = new List<string>();
            Temp.Add(chat.Text);
            System.IO.File.AppendAllLines(@"OUTPUT3.txt", Temp);
            string[] t = System.IO.File.ReadAllLines(@"OUTPUT3.txt");
            t.ToList();

             //   string s = chat.Text;
            //    string[] words = Regex.Split(s, "\r\n");
            driver.Close();
        }
开发者ID:jamesa8,项目名称:Chatzy,代码行数:47,代码来源:ManipulateChatzy.cs

示例14: SuccessfulLogin

 public void SuccessfulLogin()
 {
     ChromeOptions options = new ChromeOptions();
     options.AddArgument("--no-sandbox");
     options.AddArgument("--disable-extensions");
     options.AddArgument("--start-maximized");
     IWebDriver driver = new ChromeDriver(options);
     driver.Navigate().GoToUrl("http://www.qa.way2automation.com/");
     driver.FindElement(By.CssSelector("#load_form > h3"));
     driver.FindElement(By.CssSelector("#load_form > div > div.span_3_of_4 > p > a[href='#login']")).Click();
     driver.FindElement(By.CssSelector("#load_form > fieldset:nth-child(5) > input[name='username']")).SendKeys("j2bwebdriver");
     driver.FindElement(By.CssSelector("#load_form > fieldset:nth-child(6) > input[name='password']")).SendKeys("j2bwebdriver");
     driver.FindElements(By.CssSelector("#load_form > div > div.span_1_of_4 > input"))[1].Submit();
     Thread.Sleep(3000);
     Assert.IsFalse(driver.FindElement(By.CssSelector("body")).Text.Contains("Username"));
     Assert.IsFalse(driver.FindElement(By.CssSelector("body")).Text.Contains("Password"));
     driver.Close();
 }
开发者ID:Lampart071,项目名称:FirstTestSolved,代码行数:18,代码来源:LoginTests.cs

示例15: TestDoubleClick

        public void TestDoubleClick()
        {
            IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver\");
            driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/DoubleClickDemo.html");

            IWebElement message = driver.FindElement(By.Id("message"));

            //Verify color is Blue
            Assert.AreEqual("rgba(0, 0, 255, 1)",message.GetCssValue("background-color").ToString());

            Actions builder = new Actions(driver);
            builder.DoubleClick(message).Build().Perform();

            //Verify Color is Yellow
            Assert.AreEqual("rgba(255, 255, 0, 1)",message.GetCssValue("background-color").ToString());

            driver.Close();
        }
开发者ID:vikramuk,项目名称:Selenium,代码行数:18,代码来源:DoubleClickTest.cs


注:本文中的OpenQA.Selenium.Chrome.ChromeDriver.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。