本文整理汇总了C#中OpenQA.Selenium.Firefox.FirefoxDriver.Quit方法的典型用法代码示例。如果您正苦于以下问题:C# FirefoxDriver.Quit方法的具体用法?C# FirefoxDriver.Quit怎么用?C# FirefoxDriver.Quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Firefox.FirefoxDriver
的用法示例。
在下文中一共展示了FirefoxDriver.Quit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DriverTest
private static void DriverTest()
{
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.com/");
// Find the text input element by its name
var query = driver.FindElement(By.Name("q"));
// Enter something to search for
query.SendKeys("Cheese");
// Now submit the form. WebDriver will find the form for us from the element
query.Submit();
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
var wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.ToLower().StartsWith("cheese"); });
// Should see: "Cheese - Google Search"
System.Console.WriteLine("Page title is: " + driver.Title);
//Close the browser
driver.Quit();
}
示例2: Main
static void Main(string[] args)
{
FirefoxDriver driver = new FirefoxDriver();
//напрямую в гугл не пробиться - осядем на вводе капчи изза подозрительной деятельности
//потому пойдем через яндекс
driver.Url = "https://ya.ru";
//ищем гугл
driver.FindElementByXPath("//*[@id='text']").SendKeys("Google" + Keys.Enter);
//теперь переходим по ссылке от яндекса
driver.Url = driver.FindElementByPartialLinkText("google.ru").Text.ToString();
driver.Url = "https://www.google.ru/#newwindow=1&q=zerg+rush";
do
{
try
{
driver.FindElementByXPath(".//*[@class='zr_zergling_container']").Click();
}
catch
{
//если зерглинга еще нет
}
} while (true); //TODO: заменить на число из статистики
Console.ReadKey();
driver.Quit();
}
示例3: Main
static void Main(string[] args)
{
// Compile project
// Copy "index.html" and "lenna.png" into CSFileUpload.exe directory (bin\Debug\)
// Run and enjoy!
// создаём объект WebDriver для браузера FireFox
var driver = new FirefoxDriver();
// открываем страницу с формой загрузки файла
var fileUri = GetUriFromPath(Path.Combine(Environment.CurrentDirectory, "index.html"));
driver.Url = fileUri;
// находим элемент <input type="file">
var txtFileUpload = driver.FindElement(By.Id("file"));
// заполняем элемент путём до загружаемого файла
var sourceFile = Path.Combine(Environment.CurrentDirectory, "lenna.png");
txtFileUpload.SendKeys(sourceFile);
// находим элемент <input type="submit">
var btnSubmit = driver.FindElement(By.Id("submit"));
// нажимаем на элемент (отправляем форму)
btnSubmit.Click();
// закрываем браузер
driver.Quit();
}
示例4: CanBlockInvalidSslCertificates
//[Test]
public void CanBlockInvalidSslCertificates()
{
FirefoxProfile profile = new FirefoxProfile();
profile.AcceptUntrustedCertificates = false;
string url = EnvironmentManager.Instance.UrlBuilder.WhereIsSecure("simpleTest.html");
IWebDriver secondDriver = null;
try
{
secondDriver = new FirefoxDriver(profile);
secondDriver.Url = url;
string gotTitle = secondDriver.Title;
Assert.AreNotEqual("Hello IWebDriver", gotTitle);
}
catch (Exception)
{
Assert.Fail("Creating driver with untrusted certificates set to false failed.");
}
finally
{
if (secondDriver != null)
{
secondDriver.Quit();
}
}
}
示例5: SimpleNavigationTest
public void SimpleNavigationTest()
{
// Create a new instance of the Firefox driver.
// Notice that the remainder of the code relies on the interface,
// not the implementation.
// Further note that other drivers (InternetExplorerDriver,
// ChromeDriver, etc.) will require further configuration
// before this example will work. See the wiki pages for the
// individual drivers at http://code.google.com/p/selenium/wiki
// for further information.
IWebDriver driver = new FirefoxDriver();
//Notice navigation is slightly different than the Java version
//This is because 'get' is a keyword in C#
driver.Navigate().GoToUrl("http://www.google.com/");
// Find the text input element by its name
IWebElement query = driver.FindElement(By.Name("q"));
// Enter something to search for
query.SendKeys("Cheese");
// Now submit the form. WebDriver will find the form for us from the element
query.Submit();
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.ToLower().StartsWith("cheese"); });
//Close the browser
driver.Quit();
}
示例6: testBasketballPage
/// <summary>
/// Test form submission on Krossover basketball page
/// </summary>
public void testBasketballPage(FirefoxDriver driver)
{
//variables to enter in form
string page = "http://www.krossover.com/basketball/";
string name = "Jóhn Dóe"; //international character testing
string teamName = "Test Team";
string city = "New York";
string state = "NY";
string sport = "Football";
string gender = "Male";
string email = "[email protected]";
string phone = "123-456-789";
string day = "Friday";
//fill out all the fields
driver.Navigate().GoToUrl(page);
driver.FindElementByName("Field1").SendKeys(name);
driver.FindElementByName("Field2").SendKeys(teamName);
driver.FindElementByName("Field3").SendKeys(city);
driver.FindElementByName("Field4").SendKeys(state);
driver.FindElementByName("Field6").FindElement(By.XPath(".//option[contains(text(),'" + sport + "')]")).Click();
driver.FindElementByName("Field7").FindElement(By.XPath(".//option[contains(text(),'" + gender + "')]")).Click();
driver.FindElementByName("Field9").SendKeys(email);
driver.FindElementByName("Field11").SendKeys(phone);
driver.FindElementByName("Field14").FindElement(By.XPath(".//option[contains(text(),'" + day + "')]")).Click();
driver.FindElementByName("saveForm").Click(); //submit the form
/*verify the form submission was actually generated by querying the db
* if so, test passes
* else, test fails
*/
driver.Quit();
}
示例7: Providing_correct_credentials_logs_user_on
public void Providing_correct_credentials_logs_user_on()
{
IWebDriver browser = new FirefoxDriver();
browser.Navigate().GoToUrl("http://localhost:3000");
browser.FindElement(By.Id("login_link")).Click();
browser.FindElement(By.Id("username")).SendKeys("testuser");
browser.FindElement(By.Id("password")).SendKeys("abc123");
browser.FindElement(By.Id("login_button")).Click();
WebDriverWait wait =
new WebDriverWait(browser,
TimeSpan.FromSeconds(10));
IWebElement menuElement =
wait.Until<IWebElement>((d) =>
{
return d.FindElement(
By.XPath("id('description')"));
});
string text = browser.FindElement(By.XPath("id('top-menu')/a[3]")).Text;
Assert.AreEqual("Logout", text);
Assert.IsTrue(
browser.FindElement(
By.XPath("id('top-menu')/a[3]")).GetAttribute("href").EndsWith("/logout"));
browser.Quit();
}
示例8: testHomePage
/// <summary>
/// Test all links on the Krossover home page
/// </summary>
public void testHomePage(FirefoxDriver driver)
{
string homePage = "http://www.krossover.com/";
driver.Navigate().GoToUrl(homePage);
Thread.Sleep(1000);
//find all links on the page
IList<IWebElement> links = driver.FindElementsByTagName("a");
//loop through all of the links on the page
foreach (IWebElement link in links)
{
try
{
//check if any of the links return a 404
link.SendKeys(Keys.Control + Keys.Enter);
driver.SwitchTo().Window(driver.WindowHandles.Last());
driver.FindElementByXPath("//div[contains(@class, '404')]");
log(link.GetAttribute("href") + " is broken. Returned 404");
driver.SwitchTo().Window(driver.WindowHandles.First());
}
catch
{
//continue to the next link
continue;
}
}
driver.Quit(); //kill the driver
}
示例9: FirefoxStartup
public void FirefoxStartup()
{
FirefoxDriver dr = new FirefoxDriver();
dr.Manage().Window.Maximize();
dr.Navigate().GoToUrl(url);
dr.Quit();
}
示例10: Parse
public List<FootballItem> Parse() {
List<FootballItem> res = new List<FootballItem>();
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("https://www.marathonbet.com/su/popular/Football/?menu=true#");
ReadOnlyCollection<IWebElement> main = driver.FindElements(By.ClassName("sport-category-container"));
Debug.Assert(main.Count==1);
ReadOnlyCollection<IWebElement> containers = main[0].FindElements(By.ClassName("category-container"));
foreach (IWebElement container in containers) {
ReadOnlyCollection<IWebElement> tables = container.FindElements(By.ClassName("foot-market"));
Debug.Assert(tables.Count==1);
ReadOnlyCollection<IWebElement> tbodys = tables[0].FindElements(By.XPath(".//tbody[@data-event-name]"));
ParseTBody(tbodys, res);
}
/*
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.ToLower().StartsWith("cheese"); });
*/
driver.Close();
driver.Quit();
return res;
}
示例11: Main
static void Main(string[] args)
{
try
{ // Instantiating variables
string[] theURLs = new string[3];
string[] theCriteria = new string[3];
int wi, milsec=2500;
// Instantiating classes
IWebDriver wbDriver = new FirefoxDriver();
TheWebURLs webI=new TheWebURLs();
LoggingStuff logMe = new LoggingStuff();
wbDriver.Manage().Window.Maximize();
// Setting values for variables
theURLs=webI.getTheURLs();
theCriteria=webI.getSearchCiteria();
string logPath = logMe.createLogName().ToString();
/**********************************************/
// Run Test
logMe.writeFile("Selenium Test Log", false, logPath);
for(wi = 0; wi < 3; wi++)
{ // Opens the various web pages
Console.WriteLine(theURLs[wi] + ", " + theCriteria[wi]);
logMe.writeFile(theURLs[wi] + ", " + theCriteria[wi], true, logPath);
wbDriver.Navigate().GoToUrl(theURLs[wi]);
Thread.Sleep(milsec*2);
}
wbDriver.Quit();
}
catch (IOException e3)
{
Console.WriteLine("Failed during Main",e3.Message);
}
}
示例12: CreateExamSchemaTest
public void CreateExamSchemaTest()
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://dev.chd.miraclestudios.us/probo-php/admin/apps/backend/site/login");
driver.FindElement(By.Id("UserLoginForm_username")).Clear();
driver.FindElement(By.Id("UserLoginForm_username")).SendKeys("owner");
driver.FindElement(By.Id("UserLoginForm_password")).Clear();
driver.FindElement(By.Id("UserLoginForm_password")).SendKeys("ZFmS!H3*wJ2~^S_zx");
driver.FindElement(By.Id("login-content-button")).Click();
System.Threading.Thread.Sleep(2000);
driver.FindElement(By.LinkText("Manage Examination")).Click();
driver.FindElement(By.LinkText("Manage Exam Scheme")).Click();
System.Threading.Thread.Sleep(2000);
driver.FindElement(By.LinkText("Create Exam Scheme")).Click();
System.Threading.Thread.Sleep(5000);
Random rnd = new Random();
new SelectElement(driver.FindElement(By.Id("PrbExamScheme_exam_category_id"))).SelectByText("Food Safety");
new SelectElement(driver.FindElement(By.Id("levelid"))).SelectByText("Project Manager3610");
driver.FindElement(By.Id("PrbExamScheme_scheme_name")).Clear();
driver.FindElement(By.Id("PrbExamScheme_scheme_name")).SendKeys("ISO softengineering" + rnd.Next(1, 1000));
driver.FindElement(By.Name("yt0")).Click();
string URL = driver.Url;
Assert.AreNotEqual("http://dev.chd.miraclestudios.us/probo-php/admin/apps/backend/probo/competencyDomain/view/id/", URL.Substring(0, 89));
driver.Quit();
}
示例13: Attack1_Protected
public void Attack1_Protected()
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://localhost/LU.ENGI3675.Project04/StudentInput.aspx");
IWebElement query = driver.FindElement(By.Name("fullName"));
query.SendKeys("a','2.1'); update students * set gpa = 4.0; --");
query = driver.FindElement(By.Name("GPA"));
query.SendKeys("3");
query = driver.FindElement(By.Name("button"));
query.Click();
System.Threading.Thread.Sleep(5000);
List<LU.ENGI3675.Proj04.App_Code.Students> students =
LU.ENGI3675.Proj04.App_Code.DatabaseAccess.Read();
bool allfour = true;
foreach (LU.ENGI3675.Proj04.App_Code.Students temp in students)
{
if (temp.GPA < 4.0) allfour = false;
Debug.Write((string)temp.Name);
Debug.Write(" ");
Debug.WriteLine((double)temp.GPA);
}
Assert.IsFalse(allfour); //if they aren't all 4.0 gpa, then protected against SQL injection
driver.Quit();
}
示例14: WindowProcess_Demo2
public void WindowProcess_Demo2()
{
var articleName = "[小北De编程手记] : Lesson 02 - Selenium For C# 之 核心对象";
_output.WriteLine("Step 01 : 启动浏览器并打开Lesson 01 - Selenium For C#");
IWebDriver driver = new FirefoxDriver();
driver.Url = "http://www.cnblogs.com/NorthAlan/p/5155915.html";
_output.WriteLine("Step 02 : 点击链接打开新页面。");
var lnkArticle02 = driver.FindElement(By.LinkText(articleName));
lnkArticle02.Click();
_output.WriteLine("Step 03 : 根据标题获取新页面的句柄。");
var oldWinHandle = driver.CurrentWindowHandle;
foreach (var winHandle in driver.WindowHandles)
{
driver.SwitchTo().Window(winHandle);
if (driver.Title.Contains(articleName))
{
break;
}
}
_output.WriteLine("Step 04 : 验证新页面标题是否正确。");
var articleTitle = driver.FindElement(By.Id("cb_post_title_url"));
Assert.Equal<string>(articleName, articleTitle.Text);
_output.WriteLine("Step 05 : 关闭浏览器。");
driver.Quit();
}
示例15: startBrowser
public void startBrowser()
{
FirefoxDriver w = new FirefoxDriver();
// Added Comment
w.Url = uploadLocation;
w.Manage().Window.Maximize();
Thread.Sleep(5000);
w.Quit();
}