public SetPreference ( string name, bool value ) : void | ||
name | string | The name of the preference to add. |
value | bool | A |
return | void |
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; }
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)); }
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); }
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); }
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; }
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; }
private static FirefoxDriver Firefox(NavigatorSessionParameters session) { var profile = new FirefoxProfile { AcceptUntrustedCertificates = session.AcceptUntrustedCertificates }; profile.SetPreference("browser.startup.homepage", "about:blank"); return new FirefoxDriver(profile); }
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); }
/// <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; }
public void TearUp() { FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("dom.forms.number", false); ff = new FirefoxDriver(profile); ff.Navigate().GoToUrl(SITE_PATH); }
public void ShouldQuoteStringsWhenSettingStringProperties() { profile.SetPreference("cheese", "brie"); List <string> props = ReadGeneratedProperties(); bool seenCheese = false; foreach (string line in props) { if (line.Contains("cheese") && line.Contains("\"brie\"")) { seenCheese = true; break; } } Assert.IsTrue(seenCheese); }
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; }
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)); }
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(); }
public void ShouldAllowUserToSuccessfullyOverrideTheHomePage() { FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("browser.startup.page", "1"); profile.SetPreference("browser.startup.homepage", javascriptPage); IWebDriver driver2 = new FirefoxDriver(profile); try { Assert.AreEqual(javascriptPage, driver2.Url); } finally { driver2.Quit(); } }
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(); } }
// 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); }
public Crawler(CrawlerOptions options) { _options = options; pagesVisited = new HashSet<Uri>(); pagesToVisit = new List<Uri>(); _watch = new Stopwatch(); logger = LogManager.GetCurrentClassLogger(); FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("general.useragent.override", _options.UserAgent); _driver = new FirefoxDriver(profile); //var chromeOptions = new ChromeOptions(); //chromeOptions.AddArgument("--user-agent=" + _options.UserAgent); //_driver = new ChromeDriver(chromeOptions); }
/// <summary> /// Initiates the testing environment /// </summary> public TestBaidu() { if (!usingDriver) { if (selenium == null) { selenium = new DefaultSelenium(localIPAddress, port, targetExplorer, tagetURL); } } else { fp = new FirefoxProfile(); fp.SetPreference("dom.disable_open_during_load", false); driver = new FirefoxDriver(fp); } }
public void SetupTest() { string pathToCurrentUserProfiles = Environment.ExpandEnvironmentVariables("%APPDATA%") + @"\Mozilla\Firefox\Profiles"; // Path to profile string[] pathsToProfiles = Directory.GetDirectories(pathToCurrentUserProfiles, "*.default", SearchOption.TopDirectoryOnly); if (pathsToProfiles.Length != 0) { FirefoxProfile profile = new FirefoxProfile(pathsToProfiles[0]); profile.SetPreference("browser.tabs.loadInBackground", false); // set preferences you need driver = new FirefoxDriver(new FirefoxBinary(), profile, TimeSpan.FromSeconds(3000)); } else { driver = new FirefoxDriver(); } driver.Url = "http://norigin-test.noriginmedia.com/norigin/"; Thread.Sleep(3000); ControlAccessMethods.LogIn(driver, "nortest1", "nortest1"); Thread.Sleep(3000); }
private IWebDriver BuildFFDriver() { FirefoxProfile ffProfile = new FirefoxProfile(); JavaScriptError.AddExtension(ffProfile); ffProfile.AddExtension(SaveBinaryResource("firebug-2.0.8-fx.xpi", TestResources.firebug_2_0_8_fx)); ffProfile.SetPreference("extensions.firebug.showStackTrace", "true"); ffProfile.SetPreference("extensions.firebug.delayLoad", "false"); ffProfile.SetPreference("extensions.firebug.showFirstRunPage", "false"); ffProfile.SetPreference("extensions.firebug.allPagesActivation", "on"); ffProfile.SetPreference("extensions.firebug.console.enableSites", "true"); ffProfile.SetPreference("extensions.firebug.defaultPanelName", "console"); return new FirefoxDriver(ffProfile); }
public WebHostDriver(string browserName) { switch (browserName) { case "Internet Explorer": Value = new InternetExplorerDriver(); break; case "Mozilla Firefox": FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", "localhost"); Value = new FirefoxDriver(profile); break; case "Google Chrome": Value = new ChromeDriver(); break; case "PhantomJS": Value = new PhantomJSDriver(); break; default: throw new ArgumentException(string.Format("Browser '{0}' not supported.", browserName)); } Value.Manage().Window.Maximize(); Value.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, MaximumWaitInSecondsWhenFindingPageContent)); }
public void Execute() { FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("browser.helperApps.alwaysAsk.force", false); profile.SetPreference("browser.download.folderList", 2); profile.SetPreference("browser.download.dir", Directory.GetCurrentDirectory()); profile.SetPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false); profile.SetPreference("browser.download.useDownloadDir", true); profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/csv"); driver = new FirefoxDriver(profile); baseURL = ""; verificationErrors = new StringBuilder(); driver.Navigate().GoToUrl(baseURL + "/"); driver.FindElement(By.LinkText("Classic Login")).Click(); driver.FindElement(By.Name("uname")).Clear(); driver.FindElement(By.Name("uname")).SendKeys(""); driver.FindElement(By.Name("pword")).Clear(); driver.FindElement(By.Name("pword")).SendKeys(""); driver.FindElement(By.CssSelector("input[type=\"submit\"]")).Click(); driver.FindElement(By.LinkText("Submit File for Analysis")).Click(); driver.FindElement(By.LinkText("History of Submissions")).Click(); driver.FindElement(By.LinkText("X12out_final.txt")).Click(); driver.FindElement(By.XPath("//input[@value='csv']")).Click(); driver.FindElement(By.Name("report")).Click(); Console.WriteLine("Run autoit"); RunSaveProc(); Console.WriteLine("Will wait for 15 sec"); Thread.Sleep(12000); Console.WriteLine("Logging out"); driver.FindElement(By.LinkText("Logout")).Click(); driver.Quit(); }
/// <summary> /// Gets the proxy profile. /// </summary> /// <returns></returns> private FirefoxProfile GetProxyProfile() { var settings = UserSettingsHelper.GlobalUserSettings; var useProxy = settings.useProxy; if (!useProxy) { return new FirefoxProfile(); } var proxy = new Proxy(); var proxyType = settings.proxyType; var port = settings.proxyPort; var ip = settings.proxyIp; if (ip.IsNullOrBlank() || port.IsNullOrBlank()) { return new FirefoxProfile(); } ip += ":" + port; var user = settings.proxyUser; var pass = settings.proxyPass; proxy.Kind = ProxyKind.Manual; //HTTP PROXY if (proxyType == 0) { proxy.HttpProxy = ip; } else { proxy.SocksProxy = ip; } proxy.SslProxy = ip; proxy.FtpProxy = ip; proxy.SocksUserName = user; proxy.SocksPassword = pass; var fp = new FirefoxProfile(); fp.SetProxyPreferences(proxy); fp.SetPreference("network.websocket.enabled", "false"); return fp; }
public void TheCandidateTestJavascriptDisabled() { Random gen = new Random(); FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("javascript.enabled", false); driver = new FirefoxDriver(profile); verificationErrors = new StringBuilder(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); driver.Navigate().GoToUrl("http://test.telerikacademy.com/SoftwareAcademy/Candidate"); driver.FindElement(By.Id("UsernameOrEmail")).Clear(); driver.FindElement(By.Id("UsernameOrEmail")).SendKeys("qaacademy2013"); driver.FindElement(By.Id("Password")).Clear(); driver.FindElement(By.Id("Password")).SendKeys("qastudent"); driver.FindElement(By.CssSelector("input.submit-button")).Click(); driver.FindElement(By.Id("FirstName")).Clear(); driver.FindElement(By.Id("FirstName")).SendKeys("QA"); driver.FindElement(By.Id("SecondName")).Clear(); driver.FindElement(By.Id("SecondName")).SendKeys("QA"); driver.FindElement(By.Id("LastName")).Clear(); driver.FindElement(By.Id("LastName")).SendKeys("QA"); driver.FindElement(By.CssSelector("input#BirthDay.date-picker")).Clear(); driver.FindElement(By.CssSelector("input#BirthDay.date-picker")).SendKeys("01/01/1900"); driver.FindElement(By.Id("SchoolName")).Click(); driver.FindElement(By.Id("SchoolName")).Clear(); driver.FindElement(By.Id("SchoolName")).SendKeys("mySchool"); driver.FindElement(By.Id("Email")).Clear(); driver.FindElement(By.Id("Email")).SendKeys(""); driver.FindElement(By.Id("Phone")).Clear(); driver.FindElement(By.Id("Phone")).SendKeys("0888123456"); driver.FindElement(By.Id("SendButton")).Click(); try { Assert.IsTrue(IsElementPresent(By.CssSelector("span.field-validation-error > span"))); } catch (AssertFailedException e) { verificationErrors.Append(e.Message); } driver.FindElement(By.Id("Email")).Click(); string email = "qastudent" + gen.Next(1, 100000) + "@abv.bg"; driver.FindElement(By.Id("Email")).Click(); driver.FindElement(By.Id("Email")).SendKeys(email); driver.Manage().Cookies.DeleteCookieNamed("ASPXAUTH"); try { Assert.IsTrue(Regex.IsMatch(driver.FindElement(By.Id("Email")).Text, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$")); } catch (AssertFailedException e) { verificationErrors.Append(e.Message); } try { Assert.IsTrue(!IsElementPresent(By.CssSelector("span.field-validation-error > span"))); } catch (AssertFailedException e) { verificationErrors.Append(e.Message); } try { Assert.IsFalse(Regex.IsMatch(driver.FindElement(By.CssSelector("BODY")).Text, "^[\\s\\S]*Имейл адресът е задължителен\\.[\\s\\S]*$")); } catch (AssertFailedException e) { verificationErrors.Append(e.Message); } driver.FindElement(By.Id("Email")).Clear(); driver.FindElement(By.Id("Email")).SendKeys("abv.bg"); try { Assert.AreEqual("Моля въведете валиден e-mail адрес.", driver.FindElement(By.XPath("//fieldset[@id='PersonalData']/div[12]/span")).Text); } catch (AssertFailedException e) { verificationErrors.Append(e.Message); } driver.FindElement(By.Id("ExitMI")).Click(); driver.Close(); driver.Quit(); }
private static FirefoxProfile CreateFirefoxProfile() { var firefoxProfile = new FirefoxProfile(); firefoxProfile.SetPreference("network.automatic-ntlm-auth.trusted-uris", "http://localhost:4444/wd/hub"); return firefoxProfile; }
private FirefoxProfile RemoteFirefoxProfile() { FirefoxProfile remoteProfile = new FirefoxProfile(); remoteProfile.SetPreference("webdriver_assume_untrusted_issuer", false); remoteProfile.AcceptUntrustedCertificates = true; remoteProfile.EnableNativeEvents = false; // For running firefox on linux return remoteProfile; }
public void SetupTest() { FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.SetPreference("browser.private.browsing.autostart", true); driver = new FirefoxDriver(firefoxProfile); driver.Manage().Cookies.DeleteAllCookies(); verificationErrors = new StringBuilder(); }
private static void SetupFirefoxDriver() { var profile = new FirefoxProfile(); profile.SetPreference("network.proxy.type", 4); // profile.SetPreference("network.proxy.http", "192.168.34.82"); // profile.SetPreference("network.proxy.http_port", "3182"); Driver = new FirefoxDriver(profile); }
public void ShouldAllowUserToSuccessfullyOverrideTheHomePage() { FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("browser.startup.page", "1"); profile.SetPreference("browser.startup.homepage", javascriptPage); IWebDriver driver2 = new FirefoxDriver(profile); try { Assert.AreEqual(javascriptPage, driver2.Url); } finally { driver2.Quit(); } }
/// <summary> /// Gets the FireFox driver. /// </summary> /// <param name="browserFactoryConfiguration">The browser factory configuration.</param> /// <returns>The configured web driver.</returns> private static IWebDriver GetFireFoxDriver(BrowserFactoryConfigurationElement browserFactoryConfiguration) { IWebDriver driver; if (browserFactoryConfiguration.Settings != null && browserFactoryConfiguration.Settings.Count > 0) { var ffprofile = new FirefoxProfile(); foreach (NameValueConfigurationElement configurationElement in browserFactoryConfiguration.Settings) { // Removed debug lines but left in comments for future logger support // Debug.WriteLine("SpecBind.Selenium.SeleniumBrowserFactory.GetFireFoxDriver: Setting firefox profile setting:{0} with value: {1}", configurationElement.Name, configurationElement.Value); bool boolValue; int intValue; if (int.TryParse(configurationElement.Value, out intValue)) { // Debug.WriteLine("SpecBind.Selenium.SeleniumBrowserFactory.GetFireFoxDriver: Setting firefox profile setting with int value: '{0}'", configurationElement.Name); ffprofile.SetPreference(configurationElement.Name, intValue); } else if (bool.TryParse(configurationElement.Value, out boolValue)) { // Debug.WriteLine("SpecBind.Selenium.SeleniumBrowserFactory.GetFireFoxDriver: Setting firefox profile setting with bool value: '{0}'", configurationElement.Name); ffprofile.SetPreference(configurationElement.Name, boolValue); } else { // Debug.WriteLine("SpecBind.Selenium.SeleniumBrowserFactory.GetFireFoxDriver: Setting firefox profile setting with string value: '{0}'", configurationElement.Name); ffprofile.SetPreference(configurationElement.Name, configurationElement.Value); } } driver = new FirefoxDriver(ffprofile); } else { driver = new FirefoxDriver(); } if (browserFactoryConfiguration.EnsureCleanSession) { driver.Manage().Cookies.DeleteAllCookies(); } return driver; }
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()); } driver = new RemoteWebDriver(new Uri(remoteAddress), cap); } return new SeleniumBrowser(driver, isLocal, cfg); }
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; }