本文整理汇总了C#中OpenQA.Selenium.Firefox.FirefoxDriver.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# FirefoxDriver.Dispose方法的具体用法?C# FirefoxDriver.Dispose怎么用?C# FirefoxDriver.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Firefox.FirefoxDriver
的用法示例。
在下文中一共展示了FirefoxDriver.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
FirefoxOptions option = new FirefoxOptions();
ICapabilities cap = option.ToCapabilities();
FirefoxProfileManager mangage = new FirefoxProfileManager();
FirefoxProfile profile = mangage.GetProfile(mangage.ExistingProfiles[0]);
IWebDriver driver = new FirefoxDriver(profile);
driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(60));
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("https://www.baidu.com/");
IWebElement input = driver.FindElement(By.Id("kw"));
input.SendKeys("shinetech");
IWebElement search = driver.FindElement(By.Id("su"));
search.Click();
IWebElement shinetech = driver.FindElement(By.XPath("//div[@id='1']/h3/a"));
if(shinetech!=null)
{
if(shinetech.Text.Contains("盛安德"))
{
Console.WriteLine("Find shinetech, test passed");
}
else
{
Console.WriteLine("Cannot find Shinetech, test case failed");
}
}
else
{
Console.WriteLine("Cannot find Shinetech, test case failed");
}
shinetech.Click();
driver.Dispose();
}
示例2: Button4_Click
//.........这里部分代码省略.........
wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@id='content_0_grdSiteList']//tr[@class='rgRow']//u")));
wait.Until(ExpectedConditions.ElementExists(By.XPath("//div[@id='content_0_grdSiteList']//tr[@class='rgRow']//u")));
IList<IWebElement> lst_places = driver.FindElements(By.XPath(".//div[@id='content_0_grdSiteList']//tr[@class='rgRow']//u"));
if (lst_places == null)
continue;
int count = 0;
foreach (IWebElement place in lst_places)
{
// if (count1!= -1)
// {
try
{
dr = dt.NewRow();
Thread.Sleep(200);
dr["Scenic_Place_Name"] = place.Text;
IEnumerable<Address> addresses = geocoder.Geocode(place.Text + "," + zipcode[0]);
string place_addr = null;
Location ltng = null;
foreach (Address adr in addresses)
{
if (count == 0)
{
place_addr = adr.FormattedAddress;
ltng = adr.Coordinates;
dr["Address"] = place_addr;
break;
}
}
dr["Latitude"] = ltng.Latitude;
dr["Longitude"] = ltng.Longitude;
//tokenize place address
string[] array = place_addr.Split(',');
string[] waypoints = place_addr.Split(','); ///////*******************
string zip = array[array.Length - 2];
string[] arr = zip.Trim().Split(' ');
string webservicezip = null;
if (arr.Length == 1)
{
dr["Zipcode"] = zipcode[1];
webservicezip = zipcode[1];
}
else if (Regex.IsMatch(place_addr, @"\d"))
{
arr = zip.Trim().Split(' ');
dr["Zipcode"] = arr[1].Trim();
webservicezip = arr[1].Trim();
}
//weather update
WeatherReference.WeatherReturn weather_of_place = weather.GetCityWeatherByZIP(webservicezip); // arr[1].Trim()
dr["Weather"] = weather_of_place.Description;
dr["Temperature"] = weather_of_place.Temperature;
Random rnd = new Random();
dr["Traffic"] = rnd.Next(2, 5);
dr["Safety"] = rnd.Next(60, 100);
dt.Rows.Add(dr);
//break;
}
catch (Exception ex)
{
Console.WriteLine(ex);
continue;
}
}
}
finally
{
ds.Tables.Add(dt);
}
}
finally
{
driver.Close();
driver.Dispose();
}
}
WriteDataToDATABASE(ds);
string[] scenic_places = CreateListScenicPlaces();
// DrawScenicDirection();
foreach (string s in scenic_places)
{
ClientScript.RegisterArrayDeclaration("scenic_places", "\"" + s + "\"");
}
ClientScript.RegisterStartupScript(Page.GetType(), "Scenic", "scenic_route();", true);
}
示例3: Main
static int Main(string[] args)
{
string usrName = "";
string usrPasswd = "";
IWebDriver driver = new FirefoxDriver();
//simple usage
if(args.Length < 1)
{
Console.WriteLine("usage: <username> <passwd>");
driver.Dispose();
return(0);
}
else if ((args.Length > 0) && (args[0].ToString().ToLower() == "help"))
{
Console.WriteLine("usage: <username> <passwd>");
driver.Dispose();
return (0);
}
else if (args.Length == 2)
{
usrName = args[0];
usrPasswd = args[1];
}
else
{
Console.WriteLine("usage: <username> <passwd>");
driver.Dispose();
return (0);
}
Console.WriteLine("Initializing...");
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30)); //Make the findelements try finding for up to 30 seconds before failing--helps to resolve some timing issues
driver.Navigate().GoToUrl(url);
//checks
Console.WriteLine("Validating site...");
if(validateBasePage(driver))
{
Console.WriteLine("\t->Pass");
}
else
{
Console.WriteLine("\t->Fail");
}
Console.WriteLine("Logging in...");
try
{
if (logIn(driver, usrName, usrPasswd))
{
Console.WriteLine("\t->Pass");
}
else
{
Console.WriteLine("\t->Fail");
return (0);
}
}
catch
{
}
System.Threading.Thread.Sleep(500);
Console.WriteLine("Validating Page after login");
try
{
if (validatePostLoginPage(driver))
{
Console.WriteLine("\t->Pass");
}
else
{
Console.WriteLine("\t->Fail");
return (0);
}
}
catch (Exception)
{
driver.Dispose();
return (0);
}
Console.WriteLine("Navigating to Profile link");
try
{
if (LoadProfile_Link(driver))
{
Console.WriteLine("\t->Pass");
}
else
{
Console.WriteLine("\t->Fail");
return (0);
}
}
catch
//.........这里部分代码省略.........