本文整理汇总了C#中OpenQA.Selenium.Firefox.FirefoxProfile.SetPreference方法的典型用法代码示例。如果您正苦于以下问题:C# FirefoxProfile.SetPreference方法的具体用法?C# FirefoxProfile.SetPreference怎么用?C# FirefoxProfile.SetPreference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Firefox.FirefoxProfile
的用法示例。
在下文中一共展示了FirefoxProfile.SetPreference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCommandExecutor
private static ICommandExecutor CreateCommandExecutor(FirefoxBinary binary, FirefoxProfile profile, int port)
{
profile.SetPreference("marionette.defaultPrefs.enabled", true);
profile.SetPreference("marionette.defaultPrefs.port", port);
profile.SetPreference("browser.warnOnQuit", false);
return new MarionetteCommandExecutor(binary, profile);
}
示例2: Driver
public Driver()
{
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("browser.download.dir", @"C:\selenium_report\");
profile.SetPreference("browser.download.folderList", 2);
profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip");
_driver = new FirefoxDriver(profile);
}
示例3: GetFirefoxBrowser
private static IWebDriver GetFirefoxBrowser()
{
var profile = new FirefoxProfile();
profile.AcceptUntrustedCertificates = true;
profile.SetPreference("browser.download.folderList", 2);
profile.SetPreference("browser.download.dir", Path.GetFullPath(Constants.WallpapersDirectory));
profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", Constants.ImageMimeTypes);
var browser = new FirefoxDriver(profile);
return browser;
}
示例4: StartBrowser
internal IWebDriver StartBrowser(string browserType)
{
if (_driver != null)
{
_driver.Quit();
}
switch (browserType)
{
case "ie":
{
_driver = new InternetExplorerDriver();
break;
}
case "firefox":
{
const string fileFirebug = "E:/DotNetNuke/Selenium/firebug-1.11.1-fx.xpi";
const string fileNetExport = "E:/DotNetNuke/Selenium/netExport-0.9b3.xpi";
const string resultDir = "E:/DotNetNuke/Results";
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.AcceptUntrustedCertificates = true;
firefoxProfile.AddExtension(fileFirebug);
firefoxProfile.AddExtension(fileNetExport);
firefoxProfile.SetPreference("extensions.firebug.currentVersion", "1.11.1"); // Avoid startup screen
firefoxProfile.SetPreference("extensions.firebug.previousPlacement", 1); //Previous Firebug UI placement within the browser (0-unknown, 1-in browser, 2-in a new window, 3-minimized
firefoxProfile.SetPreference("extensions.firebug.onByDefault", true);
firefoxProfile.SetPreference("extensions.firebug.defaultPanelName", "net"); //Panel shown by default; "console", "html", "stylesheet", "script", "dom", "net" + Panels from extensions
firefoxProfile.SetPreference("extensions.firebug.netexport.alwaysEnableAutoExport", true);
firefoxProfile.SetPreference("extensions.firebug.netexport.defaultLogDir", resultDir);
firefoxProfile.SetPreference("extensions.firebug.netexport.showPreview", false);
firefoxProfile.SetPreference("extensions.firebug.allPagesActivation", "on"); //Specifies whether Firebug shall be enabled by default for all websites
firefoxProfile.SetPreference("extensions.firebug.net.enableSites", true); //Specifies whether the Net Panel is enabled
_driver = new FirefoxDriver(firefoxProfile);
break;
}
case "chrome":
{
_driver = new ChromeDriver();
break;
}
}
_driver.Manage().Window.Maximize();
return _driver;
}
示例5: GetDriver
public static IWebDriver GetDriver(string driver, Devices device)
{
DeviceModel model = Device.Get(device);
IWebDriver webDriver;
switch (driver.ToLower())
{
case "safari":
webDriver = new SafariDriver();
break;
case "chrome":
webDriver = new ChromeDriver();
break;
case "ie":
webDriver = new InternetExplorerDriver();
break;
//case "firefox":
default:
var profile = new FirefoxProfile();
profile.SetPreference("general.useragent.override", model.UserAgent);
webDriver = new FirefoxDriver(profile);
webDriver.Manage().Window.Size = model.ScreenSize;
break;
}
return webDriver;
}
示例6: Firefox
private static FirefoxDriver Firefox(NavigatorSessionParameters session)
{
var profile = new FirefoxProfile { AcceptUntrustedCertificates = session.AcceptUntrustedCertificates };
profile.SetPreference("browser.startup.homepage", "about:blank");
return new FirefoxDriver(profile);
}
示例7: SetupTest
public void SetupTest()
{
//TODO update me to match your path
var torBinaryPath = @"C:\Source\Github\Tor\TorTest\Drivers\Browser\firefox.exe";
TorProcess = new Process();
TorProcess.StartInfo.FileName = torBinaryPath;
TorProcess.StartInfo.Arguments = "-n";
TorProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
TorProcess.Start();
var profile = new FirefoxProfile();
profile.SetPreference("network.proxy.type", 1);
profile.SetPreference("network.proxy.socks", "127.0.0.1");
profile.SetPreference("network.proxy.socks_port", 9150);
Driver = new FirefoxDriver(profile);
}
示例8: switch
/// <summary>
/// Get a RemoteWebDriver
/// </summary>
/// <param name="browser">the Browser to test on</param>
/// <param name="languageCode">The language that the browser should accept.</param>
/// <returns>a IWebDriver</returns>
IWebDriver IWebDriverFactory.GetWebDriver(Browser browser, string languageCode)
{
//What browser to test on?s
IWebDriver webDriver;
switch (browser.Browserstring.ToLowerInvariant())
{
case "firefox":
var firefoxProfile = new FirefoxProfile();
firefoxProfile.SetPreference("intl.accept_languages", languageCode);
webDriver = new FirefoxDriver(firefoxProfile);
break;
case "chrome":
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("--test-type", "--disable-hang-monitor", "--new-window", "--no-sandbox", "--lang=" + languageCode);
webDriver = new ChromeDriver(chromeOptions);
break;
case "internet explorer":
webDriver = new InternetExplorerDriver(new InternetExplorerOptions { BrowserCommandLineArguments = "singleWindow=true", IntroduceInstabilityByIgnoringProtectedModeSettings = true, EnsureCleanSession = true, EnablePersistentHover = false });
break;
case "phantomjs":
webDriver = new PhantomJSDriver(new PhantomJSOptions() {});
break;
default:
throw new NotSupportedException("Not supported browser");
}
return webDriver;
}
示例9: TearUp
public void TearUp()
{
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("dom.forms.number", false);
ff = new FirefoxDriver(profile);
ff.Navigate().GoToUrl(SITE_PATH);
}
示例10: getFirefoxDriver
public static IWebDriver getFirefoxDriver()
{
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.proxy.type", 0);
IWebDriver driver = new FirefoxDriver(profile);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(waitsec));
return driver;
}
示例11: SetupTest
public void SetupTest()
{
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
// You should set here the path to your Tor browser exe. Mine was installed on my desktop because of that I'm using the below path.
String torBinaryPath = string.Concat(desktopPath, @"\Tor Browser\Browser\firefox.exe");
this.TorProcess = new Process();
this.TorProcess.StartInfo.FileName = torBinaryPath;
this.TorProcess.StartInfo.Arguments = "-n";
this.TorProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
this.TorProcess.Start();
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.proxy.type", 1);
profile.SetPreference("network.proxy.socks", "127.0.0.1");
profile.SetPreference("network.proxy.socks_port", 9150);
this.Driver = new FirefoxDriver(profile);
this.Wait = new WebDriverWait(this.Driver, TimeSpan.FromSeconds(60));
}
示例12: OpenPage
private RemoteWebDriver OpenPage(string url)
{
var profile = new FirefoxProfile();
profile.AddExtension("firebug-1.6.2.xpi");
profile.SetPreference("extensions.firebug.currentVersion", "9.99");
RemoteWebDriver driver = new FirefoxDriver(profile);
driver.Navigate().GoToUrl(url);
return driver;
}
示例13: SetupTest
public void SetupTest()
{
profile = new FirefoxProfile();
profile.SetPreference("Browser.link.open_newwindow", 3);
driver = new FirefoxDriver(profile);
//driver.Manage().Window.Maximize();
baseURL = WebDriverExtension.BASE_URL;
verificationErrors = new StringBuilder();
}
示例14: EndToEnd
public void EndToEnd()
{
const string iisexpress = "iisexpress";
Process iis = null;
var iises = Process.GetProcessesByName(iisexpress);
while (iises.Length > 0)
{
iis = iises[0];
iis.Kill();
iis.WaitForExit();
iises = Process.GetProcessesByName(iisexpress);
}
iis = new Process();
try
{
iis.StartInfo.FileName = @"C:\Program Files\IIS Express\iisexpress.exe";
iis.StartInfo.Arguments = "/site:Website1";
iis.Start();
using (var driver = new ChromeDriver())
{
EndToEnd(driver);
}
using (var driver = new FirefoxDriver())
{
EndToEnd(driver);
}
var profile = new FirefoxProfile();
profile.SetPreference
(
"general.useragent.override",
"Mozilla/5.0 (iPhone; CPU iPhone OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) GSA/8.0.57838 Mobile/12H321 Safari/600.1.4"
);
using (var driver = new FirefoxDriver(profile))
{
var options = driver.Manage();
options.Window.Size = new Size { Width = 100, Height = 550};
driver.Url = url;
TestNavigationMobile(driver, instructions, howToUse);
TestNavigationMobile(driver, home, enterNumber);
TestNavigation(driver, nsc, enterNumber);
TestCalc(driver);
TestNavigationMobile(driver, contact, contactDetails);
}
using (var driver = new InternetExplorerDriver())
{
EndToEnd(driver);
}
}
finally
{
iis.CloseMainWindow();
}
}
示例15: DriverFixture
// called before every test class
public DriverFixture()
{
//var service = PhantomJSDriverService.CreateDefaultService();
//service.IgnoreSslErrors = true;
//service.WebSecurity = false;
//Driver = new PhantomJSDriver(service, new PhantomJSOptions(), TimeSpan.FromSeconds(15)); // headless browser testing
//var service = FirefoxDriverService.CreateDefaultService();
//service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
//service.HideCommandPromptWindow = true;
//service.SuppressInitialDiagnosticInformation = true;
//Driver = new FirefoxDriver(service, new FirefoxOptions(), TimeSpan.FromSeconds(15));
//Driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 0, 5));
var profile = new FirefoxProfile();
profile.SetPreference("webdriver.log.browser.ignore", true);
profile.SetPreference("webdriver.log.driver.ignore", true);
profile.SetPreference("webdriver.log.profiler.ignore", true);
profile.SetPreference("webdriver.log.init", false);
profile.SetPreference("webdriver.log.driver.level", "OFF");
Driver = new FirefoxDriver(profile);
}