本文整理汇总了C#中OpenQA.Selenium.Firefox.FirefoxProfile类的典型用法代码示例。如果您正苦于以下问题:C# FirefoxProfile类的具体用法?C# FirefoxProfile怎么用?C# FirefoxProfile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FirefoxProfile类属于OpenQA.Selenium.Firefox命名空间,在下文中一共展示了FirefoxProfile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LaunchBrowser
/// <summary>
/// Launches the Selenium WebDriver driven browser specified in the Environments.cs file
/// </summary>
public IWebDriver LaunchBrowser(IWebDriver driver)
{
switch(this.environment.browser)
{
case "*firefox":
_ffp = new FirefoxProfile();
_ffp.AcceptUntrustedCertificates = true;
driver = new FirefoxDriver(_ffp);
break;
case "*iexplore":
driver = new InternetExplorerDriver();
break;
case "*googlechrome":
driver = new ChromeDriver();
break;
case "Android":
capabilities = new DesiredCapabilities("android", "", null);
capabilities.IsJavaScriptEnabled = true;
driver = new RemoteWebDriver(new Uri(string.Format("http://{0}:{1}/hub", environment.host, environment.port)), capabilities);
break;
case "RemoteWebDriver":
capabilities = DesiredCapabilities.Firefox();
var remoteAddress = new Uri(string.Format("http://{0}:{1}/wd/hub", environment.host, environment.port));
driver = new RemoteWebDriver(remoteAddress, capabilities);
break;
}
return driver;
}
示例2: 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;
}
示例3: GetLocalDriver
/// <summary>
/// ‘абричный метод
/// </summary>
/// <param name="browser"></param>
/// <returns></returns>
public static RemoteWebDriver GetLocalDriver(string browser)
{
InternetExplorerOptions internetExplorerOptions;
switch (browser)
{
case "Chrome":
return new ChromeDriver(PathToDriver);
case "Firefox":
var profile = new FirefoxProfile();
//profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", ConfigurationManager.AppSettings["SiteIP"]);
return new FirefoxDriver(profile);
case "IE":
internetExplorerOptions = new InternetExplorerOptions
{
IntroduceInstabilityByIgnoringProtectedModeSettings = true,
EnableNativeEvents = true
};
return new InternetExplorerDriver(
PathToDriver,
internetExplorerOptions);
default:
internetExplorerOptions = new InternetExplorerOptions
{
IntroduceInstabilityByIgnoringProtectedModeSettings = true,
EnableNativeEvents = true
};
return new InternetExplorerDriver(
PathToDriver,
internetExplorerOptions);
}
}
示例4: GetDriver
//Start the browser depending on the setting
public void GetDriver(WebBrowsers webBrws)
{
WebBrws = webBrws;
if (webBrws == WebBrowsers.Ie)
{
//Secutiry setting for IE
var capabilitiesInternet = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true };
Driver = new InternetExplorerDriver(capabilitiesInternet);
}
else
if (webBrws == WebBrowsers.FireFox)
{
//FirefoxBinary binary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe");
FirefoxProfile profile = new FirefoxProfile();
// profile.SetPreference("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
Driver = new FirefoxDriver(profile);
}
else
if (webBrws == WebBrowsers.Chrome)
{
//Chrome driver requires the ChromeDriver.exe
Driver = new ChromeDriver(@"..\..\..\lib\BrowserDriver\Chrome");
}
else { throw new WebDriverException(); }
Selenium = new WebDriverBackedSelenium(Driver, BaseUrl);
}
示例5: CanBlockInvalidSslCertificates
//[Test]
public void CanBlockInvalidSslCertificates()
{
FirefoxProfile profile = new FirefoxProfile();
profile.AcceptUntrustedCertificates = false;
string url = EnvironmentManager.Instance.UrlBuilder.WhereIsSecure("simpleTest.html");
IWebDriver secondDriver = null;
try
{
secondDriver = new FirefoxDriver(profile);
secondDriver.Url = url;
string gotTitle = secondDriver.Title;
Assert.AreNotEqual("Hello IWebDriver", gotTitle);
}
catch (Exception)
{
Assert.Fail("Creating driver with untrusted certificates set to false failed.");
}
finally
{
if (secondDriver != null)
{
secondDriver.Quit();
}
}
}
示例6: TearUp
public void TearUp()
{
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("dom.forms.number", false);
ff = new FirefoxDriver(profile);
ff.Navigate().GoToUrl(SITE_PATH);
}
示例7: InitScenario
public void InitScenario()
{
FirefoxOptions options = new FirefoxOptions();
var profile = new FirefoxProfile();
var binary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe");
driver = new FirefoxDriver(binary, profile);
}
示例8: CreateWebDriver
private static IWebDriver CreateWebDriver()
{
IWebDriver driver = null;
var type = ConfigurationManager.AppSettings["WebDriver"];
switch (type)
{
case "Firefox":
{
var profile = new FirefoxProfile
{
AcceptUntrustedCertificates = true,
EnableNativeEvents = true
};
driver = new FirefoxDriver(profile);
break;
}
case "InternetExplorer":
{
// Currently not working
var options = new InternetExplorerOptions
{
IgnoreZoomLevel = true
};
driver = new InternetExplorerDriver(options);
break;
}
case "Chrome":
default:
throw new NotSupportedException();
}
return driver;
}
示例9: 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);
}
示例10: 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;
}
示例11: CreateWebDriver
private static IWebDriver CreateWebDriver()
{
IWebDriver driver = null;
var type = ConfigurationManager.AppSettings["WebDriver"];
switch (type)
{
case "Firefox":
{
var firefoxProfile = new FirefoxProfile
{
AcceptUntrustedCertificates = true,
EnableNativeEvents = true
};
driver = new FirefoxDriver(firefoxProfile);
break;
}
case "Chrome":
case "InternetExplorer":
// TODO
break;
default:
throw new NotSupportedException();
}
return driver;
}
示例12: StartDriver
public static IWebDriver StartDriver (string browserType)
{
Trace.WriteLine("Start browser: '" + browserType + "'");
IWebDriver driver = null;
switch (browserType)
{
case "ie":
{
driver = new InternetExplorerDriver("Drivers");
break;
}
case "firefox":
{
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.EnableNativeEvents = true;
firefoxProfile.AcceptUntrustedCertificates = true;
driver = new FirefoxDriver(firefoxProfile);
break;
}
case "chrome":
{
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--disable-keep-alive");
driver = new ChromeDriver("Drivers", chromeOptions);
break;
}
}
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
driver.Manage().Window.Maximize();
return driver;
}
示例13: GetFirefoxOptions
private static FirefoxProfile GetFirefoxOptions()
{
FirefoxProfile profile = new FirefoxProfile();
FirefoxProfileManager manager = new FirefoxProfileManager();
profile = manager.GetProfile("default");
return profile;
}
示例14: selects_moved_to_single_method
public void selects_moved_to_single_method()
{
var profile = new FirefoxProfile();
var exe = new FirefoxBinary(@"D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
browser = new FirefoxDriver(exe, profile);
wait = new WebDriverWait(browser,TimeSpan.FromSeconds(10));
//browser.Navigate().GoToUrl("http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx");
browser.Navigate().GoToUrl("http://localhost/AJAXDemos/CascadingDropDown/CascadingDropDown.aspx");
wait_on_menu_item(1, "Acura");
select_menu_item(1, "Acura");
wait_on_menu_item(2, "Integra");
select_menu_item(2, "Integra");
wait_on_menu_item(3, "Sea Green");
select_menu_item(3, "Sea Green");
wait.Until(
ExpectedConditions.ElementExists(
By.XPath("//span[@id='ctl00_SampleContent_Label1' and text()='You have chosen a Sea Green Acura Integra. Nice car!']")));
browser.Quit();
}
示例15: GetDriver
public static IWebDriver GetDriver(DriverType typeOfDriver)
{
IWebDriver browser;
switch (typeOfDriver)
{
// NOTE REMOTE DRIVER IS NOT SUPPORTED
case DriverType.Chrome:
ChromeOptions co = new ChromeOptions();
browser = new ChromeDriver();
break;
case DriverType.IE:
InternetExplorerOptions ieo = new InternetExplorerOptions();
browser = new InternetExplorerDriver();
break;
case DriverType.Firefox:
default:
FirefoxProfile ffp = new FirefoxProfile();
ffp.AcceptUntrustedCertificates = true;
ffp.Port = 8181;
browser = new FirefoxDriver(ffp);
break;
}
return browser;
}