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


C# ChromeDriver.Quit方法代码示例

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


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

示例1: CheckParkCostandTimeCase1

        public void CheckParkCostandTimeCase1()
        {
            IWebDriver Driver = new ChromeDriver(@"C:\Users\Rebecca\Documents\Visual Studio 2015\Chrome Driver");

            Driver.Navigate().GoToUrl("http://adam.goucher.ca/parkcalc/index.php");
            Thread.Sleep(2000);

            // Select Short-term Parking from Lot drop down menu
            SelectElement Lot = new SelectElement(Driver.FindElement(By.Id("Lot")));
            Lot.SelectByValue("STP");

            // Enter 10:00 PM in Entry Time, select PM in radio button
            Driver.FindElement(By.Id("EntryTime")).Clear();
            Driver.FindElement(By.Id("EntryTime")).SendKeys("10:00");

            Driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[2]/td[2]/font/input[3]")).Click();


            //Enter date as 01/01/2014 In Entry Date
            Driver.FindElement(By.Id("EntryDate")).Clear();
            Driver.FindElement(By.Id("EntryDate")).SendKeys("01/01/2014");

            // Enter 11:00 in Exit Time, select PM in radio button
            Driver.FindElement(By.Id("ExitTime")).Clear();
            Driver.FindElement(By.Id("ExitTime")).SendKeys("11:00");

            Driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[3]/td[2]/font/input[3]")).Click();

            //Enter date as 01/01/2014 In Exit Date
            Driver.FindElement(By.Id("ExitDate")).Clear();
            Driver.FindElement(By.Id("ExitDate")).SendKeys("01/01/2014");

            //Click calculate button, Check cost is equal to $ 2.00, Check duration of stay is (0 Days, 1 Hours, 0 Minutes)
            Driver.FindElement(By.XPath("/html/body/form/input[2]")).Click();
            Thread.Sleep(2000);

            try
            {
                Assert.AreEqual("$ 2.00", Driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[4]/td[2]/span[1]/font/b")).Text);
            }
            catch (Exception ex)
            {
                Driver.Quit();
                Assert.Fail();
            }

            try
            {
                Assert.AreEqual("(0 Days, 1 Hours, 0 Minutes)", Driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[4]/td[2]/span[2]/font/b")).Text.Trim());
            }
            catch (Exception ex)
            {
                Driver.Quit();
                Assert.Fail();
            }

            // Quit Chrome
            Driver.Quit();
        }
开发者ID:rsweaver,项目名称:Mindbody-Interview-Assignment-,代码行数:59,代码来源:UnitTest1.cs

示例2: Search_BestValue

		public void Search_BestValue()
		{
			IWebDriver driver = new ChromeDriver();
			
			driver.Navigate().GoToUrl("http://www.markandspencer.com");
			
            IWebElement globalSearch = driver.FindElement(By.Id("global-search"));
			globalSearch.SendKeys("Malbec");
			globalSearch.SendKeys(Keys.Enter);
			
			IList<IWebElement> elements = driver.FindElements(By.Xpath("//dd[@class='price1']"));
			
			string price = ""; 
			double min = Double.parseDouble(elements[0].getText().replace("£","").replace(",",""));
			foreach (IWebElement child in elements)
			{
				price = child.getText().replace("£","").replace(",","");
				double childPrice = Double.parseDouble(price);
				if(childPrice < min)
				{
					min = childPrice;
				}
			}
			
			System.out.println("best value wine: " + min);
			driver.Quit();
		}
开发者ID:pierVCS,项目名称:MSWineSearch_Pedro_Pascasio,代码行数:27,代码来源:MSTest.cs

示例3: CanLoadWebPageTest

        public void CanLoadWebPageTest()
        {
            // add the directory containing chromedriver.exe to PATH
            var driver = new ChromeDriver();

            var baseURL = "http://localhost:6917/";
            try
            {
                driver.Navigate().GoToUrl(baseURL + "/");
                driver.FindElement(By.Id("Name")).Clear();
                driver.FindElement(By.Id("Name")).SendKeys("Test");
                new SelectElement(driver.FindElement(By.Id("Color"))).SelectByText("Red");
                driver.FindElement(By.CssSelector("option[value=\"Red\"]")).Click();
                driver.FindElement(By.CssSelector("input.btn")).Click();
                var element = driver.FindElement(By.Name("PreviousNames[0].FirstName"), 3);
                element.Clear();
                driver.FindElement(By.Name("PreviousNames[0].FirstName")).SendKeys("ONe");
                driver.FindElement(By.Name("PreviousNames[0].Surname")).Clear();
                driver.FindElement(By.Name("PreviousNames[0].Surname")).SendKeys("Two");
                var screenshot = driver.GetScreenshot();
                screenshot.SaveAsFile("screenshot.png", ImageFormat.Png);
                driver.FindElement(By.CssSelector("input.btn.btn-success")).Click();
            }
            catch (Exception)
            {
                Screenshot screenshot = driver.GetScreenshot();
                screenshot.SaveAsFile("screenshot-error.png", ImageFormat.Png);
                throw;
            }
            driver.Quit();
        }
开发者ID:linal,项目名称:ValidationPOC,代码行数:31,代码来源:BasicTests.cs

示例4: TestWTCDateTimePicker

        public void TestWTCDateTimePicker()
        {
            IWebDriver driver = new ChromeDriver();
            driver.Navigate().GoToUrl("http://www.wtc.nl/");

            SeleniumSetMethods.EnterText(driver, "arrival1", "santiago", By.Name);
            SeleniumSetMethods.EnterText(driver, "arrival1", Keys.Tab, By.Name);

            SeleniumSetMethods.Click(driver, "departureDate1", "Id");
            var test = driver.FindElement(By.ClassName("ui-datepicker-calendar"));
            var tds = test.FindElements(By.TagName("td"));

            var departureDate = tds.Where(td => td.Text == "25").FirstOrDefault();
            departureDate.Click();
            Thread.Sleep(1000);

            SeleniumSetMethods.Click(driver, "departureDate2", "Id");
            var calendar2 = driver.FindElement(By.ClassName("ui-datepicker-calendar"));
            tds = calendar2.FindElements(By.TagName("td"));
            var returnDate = tds.Where(td => td.Text == "30").LastOrDefault();
            returnDate.Click();

            Thread.Sleep(1000);

            SeleniumSetMethods.Click(driver, "search_btn", "Id");

            Thread.Sleep(30000);

            //todo maak get methodes, om validaties te controleren
            driver.Quit();
        }      
开发者ID:RemkoTestProject,项目名称:SeleniumDemo,代码行数:31,代码来源:Program.cs

示例5: Cannot_Register_User_With_Empty_Username

        public void Cannot_Register_User_With_Empty_Username()
        {
            string chromeDriverDirectory = string.Format(@"{0}\..\..\..\tools", Directory.GetCurrentDirectory());

            IWebDriver driver = new ChromeDriver(chromeDriverDirectory);
            driver.Navigate().GoToUrl("http://localhost:64872/Account/Register");

            IWebElement passwordField = driver.FindElement(By.Id("Password"));
            passwordField.SendKeys("[email protected]");

            IWebElement confirmPassword = driver.FindElement(By.Id("ConfirmPassword"));
            confirmPassword.SendKeys("[email protected]");

            IWebElement registerButton = driver.FindElement(By.ClassName("btn"));
            registerButton.Click();

            ReadOnlyCollection<IWebElement> errorMessages = driver.FindElements(By.XPath("//div[@class='validation-summary-errors']/ul/li"));

            IWebElement errorMessage = errorMessages.FirstOrDefault();

            Assert.IsNotNull(errorMessage);
            Assert.AreEqual("The User name field is required.", errorMessage.Text);

            driver.Quit();
        }
开发者ID:petekcchen,项目名称:blog,代码行数:25,代码来源:AccountTests.cs

示例6: 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

示例7: RlfpAutomation_When_RegisterAndAddIncome_Then_WeHaveAChartWithIncomeOnIt

        public void RlfpAutomation_When_RegisterAndAddIncome_Then_WeHaveAChartWithIncomeOnIt()
        {
            var name = "WebDriverTester";
            var emailAddress = string.Format("WebDriverTester+{0}@nickmeldrum.com", Guid.NewGuid());

            using (var browser = new ChromeDriver()) {

                // arrange
                var loginPage = RlfpPageFactory.Get<RlfpLoginPage>(browser);
                loginPage.Browse();

                // act
                loginPage.BuildPlanPanelForm.Name = name;
                loginPage.BuildPlanPanelForm.Gender = Gender.Male;
                loginPage.BuildPlanPanelForm.MonthOfBirth = Month.January;
                loginPage.BuildPlanPanelForm.YearOfBirth = 1980;

                var registerPage = loginPage.BuildPlanPanelForm.Submit();

                registerPage.EmailAddress = emailAddress;
                registerPage.ConfirmEmailAddress = emailAddress;
                registerPage.Password = "password";
                registerPage.TermsAndConditionsAccepted = true;

                var financialFuturePage = registerPage.Submit();

                // assert
                Assert.That(financialFuturePage.WelcomeMessage.ToLower(CultureInfo.InvariantCulture),
                    Is.EqualTo(string.Format("Welcome {0}", name).ToLower(CultureInfo.InvariantCulture)));

                browser.Quit();
            }
        }
开发者ID:nickmeldrum,项目名称:selenium-ide-scripts,代码行数:33,代码来源:RLFPWebDriverAutomationFixture.cs

示例8: Should_page_through_items_in_chrome

        public void Should_page_through_items_in_chrome()
        {
            IWebDriver chromeDriver = new ChromeDriver(TestContext.CurrentContext.TestDirectory);
            chromeDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

            chromeDriver.Navigate().GoToUrl("http://localhost:1392/");
            Login(chromeDriver);

            chromeDriver.FindElement(By.LinkText("Orders")).Click();

            for (int i = 0; i < 82; i++)
            {
                IWebElement nextButton = chromeDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_ImageButtonNext"));

                nextButton.Click();

                IWebElement pageCount = chromeDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_TextBoxPage"));

                int pageNumber = int.Parse(pageCount.GetAttribute("value"));

                Assert.AreEqual(i + 2, pageNumber);
            }

            chromeDriver.FindElement(By.Id("LoginStatus1")).Click(); ;
            chromeDriver.Quit();
        }
开发者ID:NathanGloyn,项目名称:Selenium-UI-Testing,代码行数:26,代码来源:When_using_other_browsers.cs

示例9: Should_navigate_to_google

 public void Should_navigate_to_google()
 {
     var ieDriver = new ChromeDriver(); //@"C:\Users\Jeroen van Menen\AppData\Local\Google\Chrome\Application");
     ieDriver.Navigate().GoToUrl("http://www.google.com");
     ieDriver.FindElement(By.Name("q")).SendKeys("WatiN meets WebDriver");
     ieDriver.FindElement(By.Name("btnG")).Click();
     ieDriver.Quit();
 }
开发者ID:exaphaser,项目名称:WatiN,代码行数:8,代码来源:WebDriverTests.cs

示例10: FindLinkByLinkTextTest

        public void FindLinkByLinkTextTest()
        {
            using (IWebDriver wdriver = new ChromeDriver(@"dependencies"))
            {
                wdriver.Navigate().GoToUrl("https://softuni.bg/trainings/1175/High-Quality-Code-July-2015");
                IWebElement firstLink = wdriver.FindElement(By.LinkText("Предишни инстанции на курса"));

                Assert.AreEqual("https://softuni.bg/courses/high-quality-code/", firstLink.GetAttribute("href"));
                wdriver.Quit();
            }
        }
开发者ID:KatyaMarincheva,项目名称:Selenium-Tests,代码行数:11,代码来源:WebDriverTests.cs

示例11: RedirectToApplyBySignInPage

        public void RedirectToApplyBySignInPage()
        {
            using (IWebDriver wdriver = new ChromeDriver(@"dependencies"))
            {
                wdriver.Navigate().GoToUrl("https://softuni.bg/account/authenticate");
                wdriver.FindElement(By.LinkText("Кандидатствай")).Click();

                Assert.AreEqual(wdriver.Url, "https://softuni.bg/account/authenticate?returnUrl=%2Fusers%2Fcandidate%2Fregister");
                wdriver.Quit();
            }
        }
开发者ID:KatyaMarincheva,项目名称:Selenium-Tests,代码行数:11,代码来源:WebDriverTests.cs

示例12: RedirectToLoginFromHomePage

        public void RedirectToLoginFromHomePage()
        {
            using (IWebDriver wdriver = new ChromeDriver(@"dependencies"))
            {
                wdriver.Navigate().GoToUrl("https://softuni.bg");
                wdriver.Manage().Window.Maximize();
                wdriver.FindElement(By.Id("loginLink")).Click();

                Assert.AreEqual(wdriver.Url, "https://softuni.bg/account/authenticate");
                wdriver.Quit();
            }
        }
开发者ID:KatyaMarincheva,项目名称:Selenium-Tests,代码行数:12,代码来源:WebDriverTests.cs

示例13: 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

示例14: GettingStarted

        public void GettingStarted()
        {
            //var driver = new FirefoxDriver();
            //var driver = new InternetExplorerDriver();
            var driver = new ChromeDriver();
            driver.Url = "http://www.google.com";

            driver.Navigate();

            Assert.AreEqual("Google", driver.Title);

            driver.Quit();
        }
开发者ID:snahider,项目名称:Test-Automation-NET,代码行数:13,代码来源:TranslatorTests.cs

示例15: TestTable

        public void TestTable()
        {
            using (IWebDriver wdriver = new ChromeDriver(@"dependencies"))
            {
                wdriver.Navigate().GoToUrl("https://softuni.bg/trainings/1175/High-Quality-Code-July-2015");
                IWebElement simpleTable = wdriver.FindElement(By.Id("lectures-table"));

                // Get all rows
                IList rows = simpleTable.FindElements(By.TagName("tr"));
                Assert.AreEqual(30, rows.Count);
                wdriver.Quit();
            }
        }
开发者ID:KatyaMarincheva,项目名称:Selenium-Tests,代码行数:13,代码来源:WebDriverTests.cs


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