本文整理汇总了C#中OpenQA.Selenium.Remote.RemoteWebDriver.Quit方法的典型用法代码示例。如果您正苦于以下问题:C# RemoteWebDriver.Quit方法的具体用法?C# RemoteWebDriver.Quit怎么用?C# RemoteWebDriver.Quit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Remote.RemoteWebDriver
的用法示例。
在下文中一共展示了RemoteWebDriver.Quit方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Authenticate
public static IWebDriver Authenticate()
{
string email = "[email protected]";
IWebDriver webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome());
//webDriver.Manage().Window.Maximize();
webDriver.Navigate().GoToUrl("http://dev.icms/Account/Login");
//Enter email address on login page
IWebElement emailLogin = webDriver.FindElement(By.Id("Email"));
emailLogin.Clear();
emailLogin.SendKeys(email);
IWebElement authenticateButton = webDriver.FindElement(By.Id("requestauth"));
authenticateButton.Click();
//this should have sent me an email
//Let's pretend we got the email and check the server for the authtoken and plug it into the URL
string token = HttpUtility.UrlEncode(TestUtilities.AuthenticationUtil.GetAuthToken(email));
string goToUrl = string.Format("http://dev.icms/account/authorize/?authtoken={0}&email={1}&returnUrl=%2f", token, email);
webDriver.Quit();
webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome());
webDriver.Navigate().GoToUrl(goToUrl);
//Check DOM to see if we are logged in
IWebElement elem = webDriver.FindElement(By.CssSelector("h1"));
//webDriver.Quit();
if (elem.Text == "Welcome Admin Development")
{
return webDriver;
}
return null;
}
示例2: ShouldBeAbleToCreateRemoteWebDriverWithNoSlashAtEndOfUri
public void ShouldBeAbleToCreateRemoteWebDriverWithNoSlashAtEndOfUri()
{
Environment.EnvironmentManager.Instance.CloseCurrentDriver();
RemoteWebDriver noSlashDriver = new RemoteWebDriver(new Uri("http://127.0.0.1:6000/wd/hub"), DesiredCapabilities.InternetExplorer());
noSlashDriver.Url = javascriptPage;
noSlashDriver.Quit();
}
示例3: FindPrice
public void FindPrice()
{
IWebDriver driver_ = new RemoteWebDriver(new Uri("http://192.168.1.4:4444/wd/hub"), DesiredCapabilities.Firefox());
driver_.Navigate().GoToUrl("http://www.momoshop.com.tw");
driver_.FindElement(By.CssSelector("#keyword")).SendKeys(this.SearchKeyWord_);
driver_.FindElement(By.CssSelector(".inputbtn")).Click();
Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>> info = new Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>>();
try
{
if (driver_.FindElements(By.XPath("//*[@id=\"BodyBase\"]/form[1]/div/div[2]/div[5]/ul/li")).ToList().Count == 0)
{
ReadProductDetail(driver_.Url, ref info);
}
else
{
var PageCount = driver_.FindElements(By.XPath("//*[@id=\"BodyBase\"]/form[1]/div/div[2]/div[5]/ul/li")).ToList().Count;
for (var CurrentPage = 1; CurrentPage <= PageCount;)
{
List<IWebElement> products = driver_.FindElements(By.XPath("//*[@id=\"chessboard\"]/li/a")).ToList();
foreach (var product in products)
{
ReadProductDetail(product.GetAttribute("href"), ref info);
}
//Last Page
if (CurrentPage == PageCount)
{
break;
}
//Next Page
++CurrentPage;
driver_.FindElement(By.XPath(string.Format("//*[@id=\"BodyBase\"]/form[1]/div/div[2]/div[5]/ul/li[{0}]/a", CurrentPage))).Click();
}
}
}
catch (NoSuchElementException)
{
}
this.ProductDetail_.Add("momo", info);
driver_.Quit();
if (LocalDriver_ != null)
{
LocalDriver_.Quit();
}
return;
}
示例4: CheckDriverThenClose
private void CheckDriverThenClose(RemoteWebDriver driver)
{
try
{
Assert.IsNotNull(driver);
driver.Navigate().GoToUrl("http://google.com");
Log.Debug(GetUserAgent(driver));
}
finally
{
driver.Quit();
}
}
示例5: UnitTest
public void UnitTest()
{
//IWebDriver wd = new RemoteWebDriver(DesiredCapabilities.Firefox());
//wd.Navigate().GoToUrl("http://113.128.163.253/securepay/account/login.aspx");
DesiredCapabilities caps = DesiredCapabilities.InternetExplorer();
caps.SetCapability("browser", "IE");
caps.SetCapability("browser_version", "11.0");
caps.SetCapability("os", "Windows");
caps.SetCapability("os_version", "10");
caps.SetCapability("resolution", "1024x768");
IWebDriver wd = new RemoteWebDriver(new Uri("http://113.128.163.253/securepay/account/login.aspx"), caps);
try
{
wd.FindElement(By.Id("MainContent_UserName")).Click();
wd.FindElement(By.Id("MainContent_UserName")).Clear();
wd.FindElement(By.Id("MainContent_UserName")).SendKeys("Sudhakar");
wd.FindElement(By.Id("MainContent_Password")).Click();
wd.FindElement(By.Id("MainContent_Password")).Clear();
wd.FindElement(By.Id("MainContent_Password")).SendKeys("sudhakar");
wd.FindElement(By.Id("MainContent_UserEntry")).Click();
wd.FindElement(By.Id("MainContent_UserEntry")).Clear();
wd.FindElement(By.Id("MainContent_UserEntry")).SendKeys("646F2");
wd.FindElement(By.Id("MainContent_LoginButton")).Click();
wd.FindElement(By.LinkText("Virtual Card")).Click();
wd.FindElement(By.Id("ContentPlaceHolder1_btnAddNew")).Click();
wd.FindElement(By.Id("ContentPlaceHolder1_txtCardNumber")).Click();
wd.FindElement(By.Id("ContentPlaceHolder1_txtCardNumber")).Clear();
wd.FindElement(By.Id("ContentPlaceHolder1_txtCardNumber")).SendKeys("4566882593");
wd.FindElement(By.XPath("//div[@id='ContentPlaceHolder1_divAddCard']/table/tbody/tr[1]/td[5]")).Click();
wd.FindElement(By.Id("ContentPlaceHolder1_txtNameonCard")).Click();
wd.FindElement(By.Id("ContentPlaceHolder1_txtNameonCard")).Clear();
wd.FindElement(By.Id("ContentPlaceHolder1_txtNameonCard")).SendKeys("Sudhakar");
wd.FindElement(By.Id("ContentPlaceHolder1_txtPriority")).Click();
wd.FindElement(By.Id("ContentPlaceHolder1_txtPriority")).Clear();
wd.FindElement(By.Id("ContentPlaceHolder1_txtPriority")).SendKeys("2");
wd.FindElement(By.Id("ContentPlaceHolder1_txtPercentage")).Click();
wd.FindElement(By.Id("ContentPlaceHolder1_txtPercentage")).Clear();
wd.FindElement(By.Id("ContentPlaceHolder1_txtPercentage")).SendKeys("20");
if (!wd.FindElement(By.Id("ContentPlaceHolder1_chkConfirm")).Selected)
{
wd.FindElement(By.Id("ContentPlaceHolder1_chkConfirm")).Click();
}
wd.FindElement(By.Id("ContentPlaceHolder1_btnSubmit")).Click();
wd.FindElement(By.LinkText("Products")).Click();
}
finally { wd.Quit(); }
}
示例6: Main
public static void Main(string[] args)
{
// find the test application
Console.WriteLine("Finding Test App");
string appPath = _GetTestAppPath();
Console.WriteLine("Using Test App @ \"" + appPath + "\"");
// set up the remote web driver
Console.WriteLine("Connecting to Appium server");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("browserName", "iOS");
capabilities.SetCapability("platform", "Mac");
capabilities.SetCapability("version", "6.0");
capabilities.SetCapability("app", appPath);
RemoteWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
// enter random numbers in all text fields
Console.WriteLine("Entering addends");
List<int> addends = new List<int>();
Random randomNumberGenerator = new Random();
var elements = driver.FindElementsByTagName("textField");
foreach(var element in elements)
{
int randomNumber = randomNumberGenerator.Next(0,10);
element.SendKeys(randomNumber.ToString());
addends.Add(randomNumber);
}
// calculate the expected result
int expectedResult = 0;
foreach(int i in addends)
expectedResult += i;
Console.WriteLine("Submitting the form");
// submit for computation
var buttons = driver.FindElementsByTagName("button");
buttons[0].Click();
// validate the computation
var staticTexts = driver.FindElementsByTagName("staticText");
int actualResult = int.Parse(staticTexts[0].Text);
bool pass = expectedResult == actualResult;
_LogWithColor(pass, "EXPECTED: " + expectedResult.ToString() + " ACTUAL: " + actualResult.ToString());
// shutdown
driver.Quit();
}
示例7: OpenHtmlUnitDriver
public static void OpenHtmlUnitDriver()
{
// initialize a WebDriver instance
//IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), DesiredCapabilities.HtmlUnit());
IWebDriver driver = new RemoteWebDriver(DesiredCapabilities.HtmlUnit());
// load google search page
driver.Navigate().GoToUrl("https://www.google.ca");
// print title
Console.WriteLine("Page title: " + driver.Title);
// enter search word and submit
IWebElement element = driver.FindElement(By.Name("q"));
element.SendKeys("Cheese");
element.Submit();
// print title
Console.WriteLine("Page title: " + driver.Title);
// quit the driver
driver.Quit();
}
示例8: Main
static void Main(string[] args)
{
Local local = new Local();
List<KeyValuePair<string, string>> options = new List<KeyValuePair<string, string>>() {
new KeyValuePair<string, string>("key", BROWSERSTACK_ACCESS_KEY),
//new KeyValuePair<string, string>("localIdentifier", "identifier"),
//new KeyValuePair<string, string>("f", "C:\\Users\\Admin\\Desktop\\"),
new KeyValuePair<string, string>("onlyAutomate", "true"),
new KeyValuePair<string, string>("verbose", "true"),
new KeyValuePair<string, string>("forcelocal", "true"),
new KeyValuePair<string, string>("binarypath", "C:\\Users\\Admin\\Desktop\\BrowserStackLocal.exe"),
new KeyValuePair<string, string>("logfile", "C:\\Users\\Admin\\Desktop\\local.log"),
};
local.start(options);
// Run WebDriver Tests
IWebDriver driver;
DesiredCapabilities capability = DesiredCapabilities.Firefox();
capability.SetCapability("browserstack.user", BROWSERSTACK_USERNAME);
capability.SetCapability("browserstack.key", BROWSERSTACK_ACCESS_KEY);
//capability.SetCapability("browserstack.localIdentifier", "identifier");
capability.SetCapability("browserstack.local", true);
capability.SetCapability("build", "build");
driver = new RemoteWebDriver(
new Uri("http://hub.browserstack.com/wd/hub/"), capability
);
driver.Navigate().GoToUrl("http://www.google.com");
Console.WriteLine(driver.Title);
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Browserstack");
query.Submit();
Console.WriteLine(driver.Title);
driver.Quit();
local.stop();
Console.WriteLine("Test Completed.");
Console.ReadLine();
}
示例9: CrawlFirstPage
private static void CrawlFirstPage(Uri startUrl)
{
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--user-agent=" + _options.UserAgent);
var _driver = new RemoteWebDriver(_options.RemoteHubUrl, chromeOptions.ToCapabilities());
try
{
_driver.Navigate().GoToUrl(startUrl);
SaveHtmlAndScreenShot(startUrl, _driver);
pageVisitedURLMapping.TryAdd(startUrl, startUrl);
_driver.Close();
_driver.Quit();
}
catch (Exception ex)
{
logger.Info(" Thread : " + startUrl.PathAndQuery + " Error at " + ex.StackTrace);
_driver.Close();
_driver.Quit();
}
}
示例10: FindPrice
public void FindPrice()
{
IWebDriver driver = new RemoteWebDriver(new Uri("http://192.168.1.4:4444/wd/hub"), DesiredCapabilities.Firefox());
driver.Navigate().GoToUrl("http://www.pcstore.com.tw/");
Thread.Sleep(1000);
//#id_search_word
driver.FindElement(By.CssSelector("#id_search_word")).SendKeys(this.SearchKeyWord_);
driver.FindElement(By.XPath("//*[@id=\"top-search\"]/img")).Click();
Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>> info = new Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>>();
for (; ; )
{
List<IWebElement> ProductList = driver.FindElements(By.XPath("//*[@id=\"keyad-pro-right3\"]/div[1]/a")).ToList();
foreach (var product in ProductList)
{
ReadProductDetail(product.GetAttribute("href"), ref info);
}
try
{
driver.FindElement(By.XPath("//*[@id=\"container\"]/div[10]/table[1]/tbody/tr/td[5]/a")).Click();
Thread.Sleep(1000);
}
catch (System.Exception)
{
break;
}
}
this.ProductDetail_.Add("PcHome", info);
if (LocalDriver_ != null)
{
LocalDriver_.Quit();
}
driver.Quit();
return;
}
示例11: CrawlPage
public static void CrawlPage(Uri startUrl)
{
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--user-agent=" + _options.UserAgent);
chromeOptions.AddArgument("user-data-dir=C:/Debug/" + startUrl.AbsolutePath);
var _driver = new RemoteWebDriver(_options.RemoteHubUrl, chromeOptions.ToCapabilities());
try
{
ConcurrentDictionary<Uri, Uri> pageToVisit = new ConcurrentDictionary<Uri, Uri>();
ConcurrentDictionary<Uri, Uri> PartThreading;
pageToVisit.TryAdd(startUrl, null);
while (true && pageToVisit.Count > 0)
{
PartThreading = new ConcurrentDictionary<Uri, Uri>();
logger.Info(_options.Name + " Thread : " + startUrl.PathAndQuery + " Page To Visit Size :{0}", pageToVisit.Count + " SessionId" + _driver.SessionId );
foreach (var pTV in pageToVisit)
{
PartThreading.TryAdd(pTV.Key, pTV.Value);
Uri value;
pageToVisit.TryRemove(pTV.Key, out value);
}
foreach (var Key in PartThreading.Keys)
{
_driver.Navigate().GoToUrl(Key);
SaveHtmlAndScreenShot(Key, _driver);
pageToVisit = GetUnvisitedLinks(_driver, Key, _driver.Url, PartThreading, pageToVisit, startUrl);
pageVisitedURLMapping.TryAdd(Key, PartThreading[Key]);
ValidatePage(_driver, Key, PartThreading[Key]);
}
logger.Info(" Thread : " + startUrl.PathAndQuery + " Page Finish Visit Size :{0}", pageVisitedURLMapping.Count);
}
_driver.Close();
_driver.Quit();
}
catch (Exception ex)
{
logger.Info(" Thread : " + startUrl.PathAndQuery + " Error at " + ex.StackTrace);
_driver.Close();
_driver.Quit();
}
}
示例12: FindPrice
public void FindPrice()
{
IWebDriver driver = new RemoteWebDriver(new Uri("http://192.168.1.4:4444/wd/hub"), DesiredCapabilities.Firefox());
//超級商城
driver.Navigate().GoToUrl("https://tw.mall.yahoo.com/");
driver.FindElement(By.XPath("//*[@id=\"srp-ac-bar\"]")).SendKeys(this.SearchKeyWord_);
driver.FindElement(By.XPath("//*[@id=\"UHSearchProperty\"]")).Click();
Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>> info = new Dictionary<string, Dictionary<ProductInfo.ProductInfo, string>>();
for (; ; )
{
List<IWebElement> products = driver.FindElements(By.XPath("//*[@id=\"srp_result_list\"]/div/div/div[1]/a")).ToList();
foreach (var product in products)
{
ReadProductDetailMail(product.GetAttribute("href"), ref info);
}
try
{
if (driver.FindElement(By.XPath("//*[@id=\"srp_sl_result\"]/div[3]/ul")).FindElements(
By.XPath(".//li/a")).ToList().Last().Text == "下一頁")
{
driver.FindElement(By.XPath("//*[@id=\"srp_sl_result\"]/div[3]/ul")).FindElements(
By.XPath(".//li/a")).ToList().Last().Click();
}
else
{
break;
}
products.Clear();
Thread.Sleep(1000);
}
catch (NoSuchElementException e)
{
break;
}
}
//購物中心
driver.Navigate().GoToUrl("https://tw.buy.yahoo.com/");
driver.FindElement(By.XPath("//*[@id=\"srp-ac-bar\"]")).SendKeys(this.SearchKeyWord_);
driver.FindElement(By.XPath("//*[@id=\"UHSearchProperty\"]")).Click();
List<IWebElement> buyproducts = driver.FindElements(By.XPath("//*[@id=\"srp_result_list\"]/div/div/div[1]/a")).ToList();
for (; ; )
{
List<IWebElement> products = driver.FindElements(By.XPath("//*[@id=\"srp_result_list\"]/div/div/div[1]/a")).ToList();
foreach (var product in buyproducts)
{
ReadProductDetailBuy(product.GetAttribute("href"), ref info);
}
try
{
if (driver.FindElement(By.XPath("//*[@id=\"srp_sl_result\"]/div[3]/ul")).FindElements(
By.XPath(".//li/a")).ToList().Last().Text == "下一頁")
{
driver.FindElement(By.XPath("//*[@id=\"srp_sl_result\"]/div[3]/ul")).FindElements(
By.XPath(".//li/a")).ToList().Last().Click();
}
else
{
break;
}
Thread.Sleep(1000);
}
catch (NoSuchElementException e)
{
break;
}
}
this.ProductDetail_.Add("Yahoo", info);
driver.Quit();
if (LocalDriver_ != null)
{
LocalDriver_.Quit();
}
return;
}
示例13: BVT_BrowserStack
public void BVT_BrowserStack()
{
IWebDriver driver;
driver = new RemoteWebDriver(
new Uri("http://hub.browserstack.com/wd/hub/"), base.BrowserCapabilities);
driver.Navigate().GoToUrl("http://www.google.com/ncr");
Console.WriteLine(driver.Title);
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Browserstack");
query.Submit();
Console.WriteLine(driver.Title);
if (false == driver.Title.Contains("Google")) {
Assert.Fail("Expected: '{0}' and Actual: '{1}'", "Google", driver.Title);
} else {
Console.WriteLine("Expected: '{0}' and Actual: '{1}'", "Google", driver.Title);
}
driver.Quit();
}