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


C# FirefoxDriver.ClickButton方法代码示例

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


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

示例1: AddTwoPublicationsToCartInFirefox

        public void AddTwoPublicationsToCartInFirefox()
        {
            //open Firefox
            var driver = new FirefoxDriver();

            //go to course information page
            driver.Navigate().GoToUrl(TestDomain+"/publications/pubs/plants-common-on-sand-dunes.aspx");

            //select submit button for booking option
            IWebElement button1 = driver.FindElement(By.Id("addToOrderButton"));
            //click button (and execute jQuery to add booking option to basket)
            driver.ClickButton(button1);

            //wait for JQuery to complete
            waitForJQuery(driver);

            //go to basket page
            driver.Navigate().GoToUrl(TestDomain + "publications/your-publications.aspx");
            IWebElement cartTotal = driver.FindElement(By.ClassName("paymentSubTotal"));

            //check that cart total is £3.50
            Assert.IsTrue(cartTotal.Text == "£2.75");

            //check that discount is £0
            IWebElement cartDiscount = driver.FindElement(By.ClassName("orderDiscountTotal"));
            Assert.IsTrue(cartDiscount.Text == "-£0.00");

            //check that delivery is £1
            IWebElement cartPostage = driver.FindElement(By.ClassName("orderShippingTotal"));
            Assert.IsTrue(cartPostage.Text == "£1.00");

            //check that overall total is £1
            IWebElement cartOverallTotal = driver.FindElement(By.ClassName("paymentTotal"));
            Assert.IsTrue(cartOverallTotal.Text == "£3.75");

            driver.Navigate().GoToUrl(TestDomain + "publications/pubs/using-digital-maps-and-gps-in-fieldwork-a-practical-guide-for-teachers.aspx");

            IWebElement button2 = driver.FindElement(By.Id("addToOrderButton"));
            //click button (and execute jQuery to add booking option to basket)
            driver.ClickButton(button2);

            //wait for JQuery to complete
            waitForJQuery(driver);

            //go to basket page
            driver.Navigate().GoToUrl(TestDomain + "publications/your-publications.aspx");
            cartTotal = driver.FindElement(By.ClassName("paymentSubTotal"));

            //check that cart total is £7.75
            Assert.IsTrue(cartTotal.Text == "£7.75");

            //check that discount is £0
            cartDiscount = driver.FindElement(By.ClassName("orderDiscountTotal"));
            Assert.IsTrue(cartDiscount.Text == "-£0.00");

            //check that delivery is £1
            cartPostage = driver.FindElement(By.ClassName("orderShippingTotal"));
            Assert.IsTrue(cartPostage.Text == "£2.00");

            //check that overall total is £1
            cartOverallTotal = driver.FindElement(By.ClassName("paymentTotal"));
            Assert.IsTrue(cartOverallTotal.Text == "£9.75");

            //go to checkout
            IWebElement checkoutButton = driver.FindElement(By.Id("CheckoutButton"));
            driver.ClickButton(checkoutButton);

            //find username field
            IWebElement userNameTextBox = driver.FindElement(By.Id("Login_Email"), 10);
            userNameTextBox.SendKeys("[email protected]");

            //find password field
            IWebElement passwordTextBox = driver.FindElement(By.Id("Login_Password"));
            passwordTextBox.SendKeys("123");

            //click login button
            IWebElement loginButton = driver.FindElement(By.Id("LoginButton"));
            driver.ClickButton(loginButton);

            cartTotal = driver.FindElement(By.ClassName("paymentTotal"), 10);
            //check that cart total is £282
            Assert.IsTrue(cartTotal.Text == "£11.75");

            driver.Quit();
        }
开发者ID:jamesdrever,项目名称:cpx,代码行数:85,代码来源:SeleniumTests.cs

示例2: ShouldAddTwoBookingsToOrderInFirefox

        public void ShouldAddTwoBookingsToOrderInFirefox()
        {
            //open Firefox
            var driver = new FirefoxDriver();

            //first delete any existing orders
            driver.Navigate().GoToUrl(TestDomain + "individuals-and-families/your-courses.aspx");

            var deleteButtons=driver.FindElementsByClassName("deleteOrderLineButton");

            foreach (var deleteButton in deleteButtons)
            {
                deleteButton.Click();
            }

            //go to course information page
            driver.Navigate().GoToUrl(TestDomain+"individuals-and-families/courses/2013/fm/identifying-clovers,-medicks-and-vetches-40531.aspx");

            //select submit button for booking option
            IWebElement button1 = driver.FindElement(By.Name("24789"));
            //click button (and execute jQuery to add booking option to basket)
            driver.ClickButton(button1);

            //wait for JQuery to complete
            waitForJQuery(driver);

            //go to basket page
            driver.Navigate().GoToUrl(TestDomain+"individuals-and-families/your-courses.aspx");
            IWebElement orderTotal = driver.FindElement(By.ClassName("paymentTotal"));

            //check that cart total is £248
            Assert.IsTrue(orderTotal.Text == "£248.00");

            driver.Navigate().GoToUrl(TestDomain+"individuals-and-families/courses/2013/rc/walking-hidden-wales-40889.aspx");

            IWebElement button2 = driver.FindElement(By.Id("25039"));
            //click button (and execute jQuery to add booking option to basket)
            driver.ClickButton(button2);

            //wait for JQuery to complete
            waitForJQuery(driver);

            //go to basket page
            driver.Navigate().GoToUrl(TestDomain+"individuals-and-families/your-courses.aspx");
            orderTotal = driver.FindElement(By.ClassName("paymentTotal"));

            //check that cart total is £282
            Assert.IsTrue(orderTotal.Text == "£658.00");

            //find Special Requirements textbox
            IWebElement specialRequirementsTextBox = driver.FindElement(By.Id("specialRequirements"));
            specialRequirementsTextBox.Clear();
            specialRequirementsTextBox.SendKeys("These are my special requirements");

            //submit special requirements
            IWebElement specialRequirementsButton = driver.FindElement(By.ClassName("updateSpecialRequirements"));
            driver.ClickButton(specialRequirementsButton);

            //IWebElement infoBox = driver.FindElement(By.ClassName("info-box"), 10);
            //Assert.IsTrue(infoBox.Text == "You have successfully updated your special requirements!");

            //specialRequirementsTextBox = driver.FindElement(By.Id("specialRequirements"));
            //Assert.IsTrue(specialRequirementsTextBox.Text == "These are my special requirements");

            //go to checkout
            IWebElement checkoutButton = driver.FindElement(By.Id("CheckoutButton"));
            driver.ClickButton(checkoutButton);

            //find username field
            IWebElement userNameTextBox = driver.FindElement(By.Id("Login_Email"), 10);
            userNameTextBox.SendKeys("[email protected]");

            //find password field
            IWebElement passwordTextBox = driver.FindElement(By.Id("Login_Password"));
            passwordTextBox.SendKeys("123");

            //click login button
            IWebElement loginButton = driver.FindElement(By.Id("LoginButton"));
            driver.ClickButton(loginButton);

            orderTotal = driver.FindElement(By.ClassName("paymentTotal"), 10);
            //check that cart total is £658
            Assert.IsTrue(orderTotal.Text == "£658.00");

            specialRequirementsTextBox = driver.FindElement(By.Id("specialRequirements"));

            Assert.IsTrue(specialRequirementsTextBox.Text == "These are my special requirements");

            driver.Quit();
        }
开发者ID:jamesdrever,项目名称:cpx,代码行数:90,代码来源:SeleniumTests.cs


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