本文整理汇总了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();
}
示例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();
}