本文整理汇总了C#中OpenQA.Selenium.Remote.RemoteWebDriver.Close方法的典型用法代码示例。如果您正苦于以下问题:C# RemoteWebDriver.Close方法的具体用法?C# RemoteWebDriver.Close怎么用?C# RemoteWebDriver.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Remote.RemoteWebDriver
的用法示例。
在下文中一共展示了RemoteWebDriver.Close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CloseBrowser
public static void CloseBrowser(RemoteWebDriver browser)
{
if (browser != null)
{
browser.Close();
browser.Dispose();
browser = null;
}
}
示例2: 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();
}
}
示例3: 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();
}
}
示例4: Execute
//.........这里部分代码省略.........
driver = new InternetExplorerDriver();
break;
case "htmlunit":
driver = new RemoteWebDriver(DesiredCapabilities.HtmlUnitWithJavaScript());
break;
default:
driver = new RemoteWebDriver(DesiredCapabilities.HtmlUnit());
break;
}
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 20));
new Utility().ResizeTest(driver);
var usedData = new Dictionary<string, int>();
foreach (var sequence in testcase.Value.CommandGroups.Sequences)
{
var commandContainer = new UICommandContainer();
commandContainer.Name = sequence.Value.Name;
Console.WriteLine(string.Format(" {0}", sequence.Value.Name));
if (!usedData.ContainsKey(sequence.Value.Name))
{
usedData.Add(sequence.Value.Name, 1);
}
else
{
usedData[sequence.Value.Name]++;
}
var dataName = usedData[sequence.Value.Name] > 1
? string.Format("{0}({1})", sequence.Value.Name.ToLower(), usedData[sequence.Value.Name])
: sequence.Value.Name.ToLower();
// check if sequence uses a list table
if (dataBucket.DataTables.ContainsKey(dataName))
{
var table = dataBucket.DataTables[dataName];
foreach (var dataValue in table)
{
foreach (var command in sequence.Value.Commands)
{
var c = new UICommand()
{
CommandName = command.CommandName,
Description = command.Description ?? string.Empty,
Target = command.Target ?? string.Empty,
Value = command.Value ?? string.Empty
};
var cmd = PrepareCommand(c, dataValue, uiMap);
Console.WriteLine(string.Format(" {0} {1} {2}",
cmd.CommandName,
cmd.Target,
cmd.Value));
string className = "WebAuto.Commands." + Utility.UppercaseFirst(cmd.CommandName) + "Command";
Type t = assembly.GetType(className);
var cmd2 = (WebAuto.Interfaces.Command)Activator.CreateInstance(t);
cmd2.CommandName = cmd.CommandName;
cmd2.Description = cmd.Description;
cmd2.Target = cmd.Target;
cmd2.Value = cmd.Value;
((ICommand) cmd2).Execute(driver);
}
}
}
else
{
foreach (var command in sequence.Value.Commands)
{
var c = new UICommand()
{
CommandName = command.CommandName,
Description = command.Description ?? string.Empty,
Target = command.Target ?? string.Empty,
Value = command.Value ?? string.Empty
};
var cmd = PrepareCommand(command, dataBucket.DataValues[dataName], uiMap);
Console.WriteLine(string.Format(" {0} {1} {2}",
cmd.CommandName,
cmd.Target,
cmd.Value));
string className = "WebAuto.Commands." + Utility.UppercaseFirst(cmd.CommandName) + "Command";
Type t = assembly.GetType(className);
var cmd2 = (WebAuto.Interfaces.Command)Activator.CreateInstance(t);
cmd2.CommandName = cmd.CommandName;
cmd2.Description = cmd.Description;
cmd2.Target = cmd.Target;
cmd2.Value = cmd.Value;
((ICommand)cmd2).Execute(driver);
}
}
}
driver.Close();
}
}
return result;
}