本文整理匯總了C#中OpenQA.Selenium.Firefox.FirefoxProfile.ToBase64String方法的典型用法代碼示例。如果您正苦於以下問題:C# FirefoxProfile.ToBase64String方法的具體用法?C# FirefoxProfile.ToBase64String怎麽用?C# FirefoxProfile.ToBase64String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OpenQA.Selenium.Firefox.FirefoxProfile
的用法示例。
在下文中一共展示了FirefoxProfile.ToBase64String方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DoCreate
protected override Browser DoCreate(Configuration cfg)
{
if (cfg == null)
{
cfg = new Configuration();
}
string name = cfg.Get("PiroPiro.Selenium.Driver");
if (string.IsNullOrEmpty(name))
{
throw new Exception("PiroPiro.Selenium.Driver setting is required");
}
string remoteAddress = cfg.Get("PiroPiro.Selenium.Remote.Address", false);
RemoteWebDriver driver = null;
bool isLocal = true;
if (string.IsNullOrEmpty(remoteAddress))
{
// use a browser in the local machine
switch (name.ToLower())
{
case "ie":
case "internetexplorer":
case "internet explorer":
driver = new InternetExplorerDriver();
break;
case "firefox":
case "ff":
FirefoxProfile ffp = new FirefoxProfile
{
AcceptUntrustedCertificates = true,
AlwaysLoadNoFocusLibrary = true,
EnableNativeEvents = true,
};
string authDomains = cfg.Get("PiroPiro.TrustedAuthDomains", false);
if (string.IsNullOrEmpty(authDomains))
{
authDomains = "localhost";
}
ffp.SetPreference("browser.sessionstore.enabled", false);
ffp.SetPreference("browser.sessionstore.resume_from_crash", false);
ffp.SetPreference("network.automatic-ntlm-auth.trusted-uris", authDomains);
driver = new FirefoxDriver(ffp);
break;
case "chrome":
driver = new ChromeDriver(GetChromeDriverDir(cfg));
break;
default:
throw new Exception("Selenium Driver not supported: " + name);
}
}
else
{
// use a browser in a remote machine
isLocal = false;
string version = cfg.Get("PiroPiro.Selenium.Remote.Version", false);
if (string.IsNullOrEmpty(version))
{
version = null;
}
string platform = cfg.Get("PiroPiro.Selenium.Remote.Platform", false);
if (string.IsNullOrEmpty(platform))
{
platform = "Any";
}
if (name.ToLower().Trim() == "htmlunit" && string.IsNullOrWhiteSpace(version))
{
// tell htmlunit by default to behave like firefox
version = "firefox";
}
DesiredCapabilities cap = new OpenQA.Selenium.Remote.DesiredCapabilities(name, version, new Platform((PlatformType)Enum.Parse(typeof(PlatformType), platform)));
// enable javascript by default
cap.IsJavaScriptEnabled = true;
if (name.ToLower().Trim() == "firefox")
{
// if firefox, add some preferences
string authDomains = cfg.Get("PiroPiro.TrustedAuthDomains", false);
if (string.IsNullOrEmpty(authDomains))
{
authDomains = "localhost";
}
FirefoxProfile ffp = new FirefoxProfile();
ffp.SetPreference("browser.sessionstore.enabled", false);
ffp.SetPreference("browser.sessionstore.resume_from_crash", false);
ffp.SetPreference("network.automatic-ntlm-auth.trusted-uris", authDomains);
cap.SetCapability(FirefoxDriver.ProfileCapabilityName, ffp.ToBase64String());
}
//.........這裏部分代碼省略.........