本文整理汇总了C#中OpenQA.Selenium.IE.InternetExplorerDriver.Quit方法的典型用法代码示例。如果您正苦于以下问题:C# InternetExplorerDriver.Quit方法的具体用法?C# InternetExplorerDriver.Quit怎么用?C# InternetExplorerDriver.Quit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.IE.InternetExplorerDriver
的用法示例。
在下文中一共展示了InternetExplorerDriver.Quit方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_page_through_items_in_IE
public void Should_page_through_items_in_IE()
{
IWebDriver ieDriver = new InternetExplorerDriver();
ieDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
ieDriver.Navigate().GoToUrl("http://localhost:1392/");
Login(ieDriver);
ieDriver.FindElement(By.LinkText("Orders")).Click();
for (int i = 0; i < 20; i++)
{
IWebElement nextButton = ieDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_ImageButtonNext"));
nextButton.Click();
IWebElement pageCount = ieDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_TextBoxPage"));
int pageNumber = int.Parse(pageCount.GetAttribute("value"));
Assert.AreEqual(i + 2, pageNumber);
}
ieDriver.FindElement(By.Id("LoginStatus1")).Click();
ieDriver.Quit();
}
示例2: TestIE
public void TestIE()
{
driver = new InternetExplorerDriver();
//OpenPage needs to run twice because of an initialization bug with the IE driver
OpenPage<GoogleHomePage>("http://www.google.com/");
OpenPage<GoogleHomePage>("http://www.google.com/");
driver.Quit();
}
示例3: ShouldBeAbleToCallQuitConsecutively
public void ShouldBeAbleToCallQuitConsecutively()
{
driver.Url = simpleTestPage;
driver.Quit();
driver.Quit();
driver = new InternetExplorerDriver();
driver.Url = xhtmlTestPage;
driver.Quit();
}
示例4: ShouldBeAbleToCallQuitAfterCallingCloseOnOnlyOpenWindow
public void ShouldBeAbleToCallQuitAfterCallingCloseOnOnlyOpenWindow()
{
EnvironmentManager.Instance.CloseCurrentDriver();
IWebDriver testDriver = new InternetExplorerDriver();
testDriver.Url = simpleTestPage;
testDriver.Close();
testDriver.Quit();
testDriver = new InternetExplorerDriver();
testDriver.Url = xhtmlTestPage;
Assert.AreEqual("XHTML Test Page", testDriver.Title);
testDriver.Quit();
}
示例5: OpenGoogle
public void OpenGoogle()
{
IWebDriver driver = new InternetExplorerDriver();
//IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.com/");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Cheese");
System.Console.WriteLine("Page title is: " + driver.Title);
// TODO add wait
driver.Quit();
}
示例6: ShouldBeAbleToStartMoreThanOneInstanceOfTheIEDriverSimultaneously
public void ShouldBeAbleToStartMoreThanOneInstanceOfTheIEDriverSimultaneously()
{
IWebDriver secondDriver = new InternetExplorerDriver();
driver.Url = xhtmlTestPage;
secondDriver.Url = formsPage;
Assert.AreEqual("XHTML Test Page", driver.Title);
Assert.AreEqual("We Leave From Here", secondDriver.Title);
// We only need to quit the second driver if the test passes
secondDriver.Quit();
}
示例7: Main
static void Main(string[] args)
{
IWebDriver driver = new InternetExplorerDriver();
driver.Navigate().GoToUrl("http://www.google.com");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("google test");
query.Submit();
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(t => t.Title.ToLower().StartsWith("google test"));
System.Console.WriteLine(string.Format("Page title is: {0}", driver.Title));
driver.Quit();
}
示例8: Main
static void Main(string[] args)
{
NavigationData data = new NavigationData();
MenuFilterSection menu = MenuFilterSection.GetConfig();
List<string> ids = menu.GetItemsToBeRemove();
string filter = string.Join(",", ids.ToArray());
MenuOrderSection menuOrder = MenuOrderSection.GetConfig();
List<SAMenuItemDTO> menuItems = data.GetAllUsedDiagrams(filter);
List<string> errorUrls = new List<string>();
foreach (var item in menuItems)
{
foreach (var item2 in item.ChildItems)
{
InternetExplorerDriver driver = new InternetExplorerDriver();
string url = string.Format("http://wpsa1/tobe_ea/Default.aspx?id={0}", item2.Key);
driver.Url = url;
var sc = driver.GetScreenshot();
sc.SaveAsFile(item2.Key.ToString() + ".jpg", ImageFormat.Jpeg);
//Thread.Sleep(100000);
var x = driver.FindElementById("reportId");
if (x == null)
{
errorUrls.Add(url);
}
driver.Quit();
}
}
File.WriteAllLines(@"BrokenPages.txt", errorUrls.ToArray());
Console.ReadLine();
}
示例9: TestIE
public void TestIE()
{
driver = new InternetExplorerDriver();
OpenPage<GoogleHomePage>("http://www.google.com/");
driver.Quit();
}
示例10: TestMethod1
public void TestMethod1()
{
//RemoteWebDriver Driver = new InternetExplorerDriver();
RemoteWebDriver Driver = new InternetExplorerDriver();
//Driver.Url = "www.football.ua";
Driver.Navigate().GoToUrl(@"http://en.wikipedia.org/");
//Driver.Manage().Window.Maximize();
var lnkSupportUs = Driver.FindElementByCssSelector(@"a[title = 'Support us']");
lnkSupportUs.Click();
// Cannot find with this locator!
var radio50UAH = Driver.FindElementByXPath("/html/body/div[3]/div[2]/div[3]/table/tbody/tr/td[2]/form/div/div[3]/table/tbody/tr[1]/td[1]/label");//Driver.FindElementById("input_amount_0");// Driver.FindElementByCssSelector(@"#input_amount_0[value='50']");
radio50UAH.Click();
var btnDonate = Driver.FindElement(By.ClassName("payment-method-button"));
btnDonate.Click();
var txtFirstName = Driver.FindElementById("fname");
var txtlastName = Driver.FindElementById("lname");
var txtEmail = Driver.FindElementById("emailAdd");
var radioCardType = Driver.FindElementById("cc-visa");
txtFirstName.Clear();
txtFirstName.SendKeys("Vasya");
txtlastName.Clear();
txtlastName.SendKeys("Poopkin");
txtEmail.Clear();
txtEmail.SendKeys("[email protected]");
radioCardType.Click();
var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(6));
var txtCreditCardNum = Driver.FindElementByName("CREDITCARDNU");
var selectExpMonth = new SelectElement(Driver.FindElementById("F1010_MM"));
var selectExpYear = new SelectElement(Driver.FindElementById("F1010_YY"));
var txtCVV = Driver.FindElementById(@"F1136");
var btnSubmit = Driver.FindElementById(@"btnSubmit");
txtCreditCardNum.Clear();
txtCreditCardNum.SendKeys("8975397698238467");
selectExpMonth.SelectByText("02");
selectExpYear.SelectByText("15");
txtCVV.Clear();
txtCVV.SendKeys("836");
btnSubmit.SendKeys(Keys.Enter);
Driver.SwitchTo().DefaultContent();
// On Donate results page
string headerSelector = @"h1.firstHeading";
var headingElement = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(headerSelector)));
Assert.AreEqual("Donate-error", headingElement.Text);
Driver.Quit();
Driver.Dispose();
}
示例11: Softuni_OpenSoftUniWebsite_ShouldPassTest
public void Softuni_OpenSoftUniWebsite_ShouldPassTest()
{
using (IWebDriver wdriver = new InternetExplorerDriver())
{
wdriver.Navigate().GoToUrl("https://softuni.bg/trainings/1175/High-Quality-Code-July-2015");
wdriver.FindElement(By.TagName("body")).Click();
string actualLinkText = wdriver.FindElement(By.LinkText("Предишни инстанции на курса")).Text;
wdriver.Quit();
}
}
示例12: GetBillAmount
//.........这里部分代码省略.........
driver.Navigate().GoToUrl("https://account.windowsazure.com/Subscriptions");
IWebElement usernameTB = null;
IWebElement pwTB = null;
try
{
usernameTB = driver.FindElement(By.Id("i0116"));
}
catch
{
retVal = "Username input not found.";
}
if (usernameTB != null)
{
usernameTB.SendKeys(userName);
try
{
pwTB = driver.FindElement(By.Id("i0118"));
}
catch
{
retVal = "Password input not found.";
}
if (pwTB != null)
{
pwTB.SendKeys(TickerEncryption.Utility.Decrypt(password, Properties.Settings.Default.Thumb1, Properties.Settings.Default.Thumb2));
System.Threading.Thread.Sleep(5000);
IWebElement loginBtn = driver.FindElement(By.Id("idSIButton9"));
loginBtn.Click();
bool loggedInSuccessfully = false;
int iterationCount = 1;
System.Threading.Thread.Sleep(2000);
while (loggedInSuccessfully == false && iterationCount <= 5)
{
try
{
IWebElement subscriptionContent = driver.FindElement(By.Id("subscriptions-list"));
IWebElement firstSubscriptionLink = subscriptionContent.FindElement(By.TagName("a"));
firstSubscriptionLink.Click();
IWebElement charged = driver.FindElement(By.ClassName("subscription-estimated-cost"));
retVal = charged.Text;
loggedInSuccessfully = true;
NetUtil.AddEventLogEntry("BillProvider", "Application", "Account balance populated - " + userName + ".");
System.Threading.Thread.Sleep(2000);
try
{
IWebElement logoutBtn = driver.FindElement(By.Id("header-sign-in"));
logoutBtn.Click();
}
catch
{
NetUtil.AddEventLogEntry("BillProvider", "Application", "Unable to click logout button - " + userName + ".");
}
}
catch
{
//Exception here means login button is still processing, subscription info not loaded. Try clicking login button again.
loginBtn.Click();
System.Threading.Thread.Sleep(2000);
IWebElement subscriptionContent = driver.FindElement(By.Id("subscriptions-list"));
IWebElement firstSubscriptionLink = subscriptionContent.FindElement(By.TagName("a"));
firstSubscriptionLink.Click();
IWebElement charged = driver.FindElement(By.ClassName("subscription-estimated-cost"));
retVal = charged.Text;
loggedInSuccessfully = true;
NetUtil.AddEventLogEntry("BillProvider", "Application", "Account balance populated - " + userName + ".");
try
{
IWebElement logoutBtn = driver.FindElement(By.Id("header-sign-in"));
logoutBtn.Click();
}
catch
{
NetUtil.AddEventLogEntry("BillProvider", "Application", "Unable to click logout button - " + userName + ".");
}
}
iterationCount++;
}
if (!loggedInSuccessfully)
{
retVal = "Error loading subscription information.";
NetUtil.AddEventLogEntry("BillProvider", "Application", "Error loading subscription balance after retry - " + userName + ".");
}
}
}
driver.Quit();
}
}
catch(Exception ex)
{
NetUtil.AddEventLogEntry("BillProvider", "Application", "Unable start IE driver: " + ex.Message);
}
return retVal;
}
示例13: GetDriver
/// <summary>
/// Возвращает драйвер браузера с настройками прокси на актуальный сервер
/// </summary>
/// <returns></returns>
public IWebDriver GetDriver(bool useProxy)
{
IWebDriver driver = null;
if (useProxy)
{
Random r = new Random(DateTime.Now.Millisecond);
bool workedProxyIsFound = false;
//выбираем случайный прокси из списка адресов в конфиге до тех пор, пока не найдем рабочий
do
{
int proxyIndex = r.Next(document["settings"]["proxies"].ChildNodes.Count);
string PROXY = document["settings"]["proxies"].ChildNodes[proxyIndex].Attributes[0].Value;
Proxy proxy = new Proxy();
proxy.HttpProxy = PROXY;
proxy.FtpProxy = PROXY;
proxy.SslProxy = PROXY;
switch (document["settings"]["driver"].GetAttribute("name"))
{
case "GoogleChrome":
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.Proxy = proxy;
driver = new ChromeDriver(document["settings"]["driver"].GetAttribute("path"), chromeOptions, TimeSpan.FromSeconds(300));
break;
case "Firefox":
FirefoxProfile profile = new FirefoxProfile();
profile.SetProxyPreferences(proxy);
driver = new FirefoxDriver(new FirefoxBinary(), profile, TimeSpan.FromSeconds(300));
break;
case "Opera":
OperaOptions operaOptions = new OperaOptions();
operaOptions.Proxy = proxy;
driver = new OperaDriver(document["settings"]["driver"].GetAttribute("path"), operaOptions, TimeSpan.FromSeconds(300));
break;
case "IE":
InternetExplorerOptions IEOptions = new InternetExplorerOptions();
IEOptions.Proxy = proxy;
driver = new InternetExplorerDriver(document["settings"]["driver"].GetAttribute("path"), IEOptions, TimeSpan.FromSeconds(300));
break;
}
//Проверяем работу прокси обращаясь к гуглу
driver.Navigate().GoToUrl("http://www.google.ru/");
Thread.Sleep(10000);
workedProxyIsFound = driver.Title == "Google";
if (!workedProxyIsFound)
driver.Quit();
}
while (!workedProxyIsFound);
}
else
{
switch (document["settings"]["driver"].GetAttribute("name"))
{
case "GoogleChrome":
driver = new ChromeDriver(document["settings"]["driver"].GetAttribute("path"));
break;
case "Firefox":
driver = new FirefoxDriver(new FirefoxBinary(), new FirefoxProfile(), TimeSpan.FromSeconds(120));
break;
case "Opera":
driver = new OperaDriver(document["settings"]["driver"].GetAttribute("path"));
break;
case "IE":
driver = new InternetExplorerDriver(document["settings"]["driver"].GetAttribute("path"));
break;
}
}
return driver;
}
示例14: Main
//.........这里部分代码省略.........
//
// CONFIGURE SIMULATOR
//
try
{
/// AIRPORT
// Change the value of the airport selector
UIHelper.ChangeDropDownByValue(ref driver, "selAirport", args[1]);
/// IATA Preference
if (Boolean.Parse(args[2]))
{
UIHelper.ChangeRadioByValue(ref driver, "rdoICAOorIATA", "IATA");
}
/// WIND DIRECTION
// Get element for wind direction
UIHelper.ChangeDropDownByValue(ref driver, "WindChance", args[3]);
// REALISM
string playMoveValue;
switch (args[4])
{
case "easy":
playMoveValue = "1";
break;
case "arrivals":
playMoveValue = "2";
break;
case "departures":
playMoveValue = "3";
break;
default:
playMoveValue = "0";
break;
}
UIHelper.ChangeDropDownByValue(ref driver, "PlayMode", playMoveValue);
/// SCALE MARKERS
/// We change this automatically, no option provided to end-user
UIHelper.ChangeDropDownByValue(ref driver, "ScaleMarks", "2");
// Submit form
Console.WriteLine("\nSubmitting settings form...");
UIHelper.SubmitForm(ref driver, "frmOptions");
Console.WriteLine("Loading radar scope...");
// Wait for the new page to load
wait.Until((d) =>
{
try
{
return (d.FindElement(By.Name("frmClearance")) != null);
}
catch (NoSuchElementException)
{
// Do nothing, keep waiting
return false;
}
});
}
catch (NoSuchElementException ex)
{
Console.Error.WriteLine("FATAL: One or more required form elements could not be found. Cannot proceed.");
Console.Error.WriteLine("Additional information: " + ex.Message + "\n");
return;
}
catch (Exception ex)
{
Console.Error.WriteLine("FATAL: A general exception has occurred. Cannot continue.");
Console.Error.WriteLine("Additional information: " + ex.Message + "\n");
return;
}
// Start controller
Controller controller = new Controller(driver);
controller.Run();
// One Run() has finished, exit
driver.Quit();
Console.WriteLine("\n--Disconnected--");
}
else
{
// Output usage options
Console.WriteLine("Usage:\n\tAIRPORT AIRLINEIATAOPT WIND REALISM\n\t(All arguments required)");
Console.WriteLine("Arguments:");
Console.WriteLine("\tAIRPORT - ICAO Code for Target Airport (See website for list)");
Console.WriteLine("\tAIRLINEIATAOPT - Use IATA Codes for Airlines (True or False)");
Console.WriteLine("\tWIND - Wind Change Frequency (0, 10, 25, 50, 75, 100)");
Console.WriteLine("\tREALISM - Realism Settings (normal, easy, arrivals, departures)");
return;
}
}