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; }
/// <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; }
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; }
/// <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; }
/// <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); } }
//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); }
//[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(); } } }
public void TearUp() { FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("dom.forms.number", false); ff = new FirefoxDriver(profile); ff.Navigate().GoToUrl(SITE_PATH); }
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); }
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; }
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; }
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(); }
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; }
private static FirefoxProfile GetFirefoxOptions() { FirefoxProfile profile = new FirefoxProfile(); FirefoxProfileManager manager = new FirefoxProfileManager(); profile = manager.GetProfile("default"); return 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 IWebDriver StartBrowser() { WebBrowser = ConfigurationManager.AppSettings["Settings_Browser"]; switch (WebBrowser) { case "firefox": _ffp = new FirefoxProfile(); _ffp.AcceptUntrustedCertificates = true; _driver = new FirefoxDriver(_ffp); break; case "iexplore": _driver = new InternetExplorerDriver(); break; case "chrome": _driver = new ChromeDriver(); break; } string timeoutSeconds = ConfigurationManager.AppSettings["Settings_Timeout"]; int iTimeoutSeconds; if (Int32.TryParse(timeoutSeconds, out iTimeoutSeconds)) { DriverTimeout = new TimeSpan(0,0,0,iTimeoutSeconds); } _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(DriverTimeout.TotalSeconds)); 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 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 TestInitialize() { var firefoxProfile = new FirefoxProfile(); this.browser = new FirefoxDriver(firefoxProfile); this.intGeneratorPage = new IntegersGeneratorPage(); this.resultPage = new ResultPage(); this.homePage = new HomePage(); }
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); }
public WebTestContext() { FirefoxOptions options = new FirefoxOptions(); var profile = new FirefoxProfile(); var binary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"); if (Driver == null) Driver = new FirefoxDriver(binary, profile); }
public void ShouldRemoveProfileAfterExit() { FirefoxProfile profile = new FirefoxProfile(); IWebDriver firefox = new FirefoxDriver(profile); string profileLocation = profile.ProfileDirectory; firefox.Quit(); Assert.IsFalse(Directory.Exists(profileLocation)); }
protected FirefoxProfile CreateProfile() { var profile = new FirefoxProfile(ProfileDirectoryPath); profile.EnableNativeEvents = true; profile.DeleteAfterUse = true; profile.AcceptUntrustedCertificates = true; return profile; }
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(); }
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; }
public void TestInitialize() { this.profile = new FirefoxProfile(); this.profile.SetPreference("javascript.enabled", false); var driver = new FirefoxDriver(profile); base.BaseTestInitialize(driver, BaseUrl, 20); this.loginPage = new LoginPage(driver); this.profilePage = new ProfilePage(driver); this.yourAccountPage = new YourAccountPage(driver); }
public IWebDriver StartBrowser() { Common.WebBrowser = System.Configuration.ConfigurationSettings.AppSettings["Browser"].ToLower(); string driverDir = System.Configuration.ConfigurationSettings.AppSettings["DriverDir"]; string driverPath = ""; switch (Common.WebBrowser.ToLower()) { case "firefox": _cap = DesiredCapabilities.Firefox(); _cap.SetCapability(CapabilityType.AcceptSslCertificates, true); _ffp = new FirefoxProfile(); _ffp.AcceptUntrustedCertificates = true; _driver = new FirefoxDriver(_ffp); break; case "iexplore": _cap = DesiredCapabilities.InternetExplorer(); _cap.SetCapability(CapabilityType.AcceptSslCertificates, true); _ie = new InternetExplorerOptions(); _ie.IgnoreZoomLevel = true; _ie.IntroduceInstabilityByIgnoringProtectedModeSettings = true; switch (OS.IsOS64Bit()) { case true: Console.WriteLine("Running the test on 64 bit Operating System."); driverPath = driverDir + "\\x64_IE_driver"; Console.WriteLine("test"); Common.OSbit = 64; break; case false: Console.WriteLine("Running the test on 32 bit Operating System."); driverPath = driverDir + "\\Win32_IE_driver"; Common.OSbit = 32; break; } _driver = new InternetExplorerDriver(driverPath, _ie, Common.DriverTimeout); break; case "chrome": driverPath = driverDir + "\\Chrome"; _cap = DesiredCapabilities.Chrome(); _cap.SetCapability(CapabilityType.AcceptSslCertificates, true); _chrome = new ChromeOptions(); //_chrome.AddArgument("--new-window"); //_chrome.AddArguments("-user-data-dir=c:\\chrome --new-window %1"); _driver = new ChromeDriver(driverPath, _chrome, Common.DriverTimeout); break; } _driver.Manage().Cookies.DeleteAllCookies(); _driver.Manage().Window.Maximize(); //navigateToApplication(); return _driver; }
public void run_once_before_anything() { 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"); }
public void Run_once_before_anything() { var profile = new FirefoxProfile(); profile.Clean(); var exe = new FirefoxBinary(); browser = new FirefoxDriver(exe, profile); wait = new WebDriverWait(browser, TimeSpan.FromSeconds(10)); }
/// <summary> /// Initializes the binary with the specified profile. /// </summary> /// <param name="profile">The <see cref="FirefoxProfile"/> to use to initialize the binary.</param> public void Clean(FirefoxProfile profile) { if (profile == null) { throw new ArgumentNullException("profile", "profile cannot be null"); } this.StartProfile(profile, "-silent"); try { this.WaitForProcessExit(); } catch (ThreadInterruptedException e) { throw new WebDriverException("Thread was interrupted", e); } }
/// <summary> /// Starts Firefox using the specified profile and command-line arguments. /// </summary> /// <param name="profile">The <see cref="FirefoxProfile"/> to use with this instance of Firefox.</param> /// <param name="commandLineArguments">The command-line arguments to use in starting Firefox.</param> public void StartProfile(FirefoxProfile profile, string[] commandLineArguments) { if (commandLineArguments == null) { commandLineArguments = new string[] { }; } string profileAbsPath = profile.ProfileDirectory; SetEnvironmentProperty("XRE_PROFILE_PATH", profileAbsPath); SetEnvironmentProperty("MOZ_NO_REMOTE", "1"); if (IsOnLinux && (profile.EnableNativeEvents || profile.AlwaysLoadNoFocusLibrary)) { ModifyLinkLibraryPath(profile); } StringBuilder commandLineArgs = new StringBuilder("--verbose"); foreach (string commandLineArg in commandLineArguments) { commandLineArgs.Append(" ").Append(commandLineArg); } Process builder = new Process(); builder.StartInfo.FileName = BinaryExecutable.ExecutablePath; builder.StartInfo.Arguments = commandLineArgs.ToString(); builder.StartInfo.UseShellExecute = false; builder.StartInfo.RedirectStandardError = true; builder.StartInfo.RedirectStandardOutput = true; foreach (string environmentVar in extraEnv.Keys) { builder.StartInfo.EnvironmentVariables.Add(environmentVar, extraEnv[environmentVar]); } BinaryExecutable.SetLibraryPath(builder); StartFirefoxProcess(builder); CopeWithTheStrangenessOfTheMac(builder); // startOutputWatcher(); }
public FirefoxDriverServer(FirefoxBinary binary, FirefoxProfile profile, string host) { this.host = host; if (profile == null) { this.profile = new FirefoxProfile(); } else { this.profile = profile; } if (binary == null) { this.process = new FirefoxBinary(); return; } this.process = binary; }
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 a <see cref="FirefoxProfile"/> with a given name. /// </summary> /// <param name="profileName">The name of the profile to get.</param> /// <returns>A <see cref="FirefoxProfile"/> with a given name. /// Returns <see langword="null"/> if no profile with the given name exists.</returns> public FirefoxProfile GetProfile(string profileName) { FirefoxProfile profile = null; if (!string.IsNullOrEmpty(profileName)) { if (this.profiles.ContainsKey(profileName)) { profile = new FirefoxProfile(this.profiles[profileName]); if (profile.Port == 0) { profile.Port = FirefoxDriver.DefaultPort; } } } return(profile); }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxOptions"/> class for the given profile and binary. /// </summary> /// <param name="profile">The <see cref="FirefoxProfile"/> to use in the options.</param> /// <param name="binary">The <see cref="FirefoxBinary"/> to use in the options.</param> /// <param name="capabilities">The <see cref="DesiredCapabilities"/> to copy into the options.</param> internal FirefoxOptions(FirefoxProfile profile, FirefoxBinary binary, DesiredCapabilities capabilities) { this.BrowserName = BrowserNameValue; if (profile != null) { this.profile = profile; } if (binary != null) { this.browserBinaryLocation = binary.BinaryExecutable.ExecutablePath; } if (capabilities != null) { this.ImportCapabilities(capabilities); } }
private static ICommandExecutor CreateExtensionConnection(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout) { FirefoxProfile profileToUse = profile; string suggestedProfile = Environment.GetEnvironmentVariable("webdriver.firefox.profile"); if (profileToUse == null && suggestedProfile != null) { profileToUse = new FirefoxProfileManager().GetProfile(suggestedProfile); } else if (profileToUse == null) { profileToUse = new FirefoxProfile(); } FirefoxDriverCommandExecutor executor = new FirefoxDriverCommandExecutor(binary, profileToUse, "localhost", commandTimeout); return(executor); }
private static FirefoxOptions CreateOptionsFromCapabilities(ICapabilities capabilities) { // This is awkward and hacky. To be removed when the legacy driver is retired. FirefoxBinary binary = ExtractBinary(capabilities); FirefoxProfile profile = ExtractProfile(capabilities); DesiredCapabilities desiredCaps = RemoveUnneededCapabilities(capabilities) as DesiredCapabilities; FirefoxOptions options = new FirefoxOptions(profile, binary); if (desiredCaps != null) { Dictionary <string, object> capsDictionary = desiredCaps.ToDictionary(); foreach (KeyValuePair <string, object> capability in capsDictionary) { options.AddAdditionalCapability(capability.Key, capability.Value); } } return(options); }
private void ModifyLinkLibraryPath(FirefoxProfile profile) { // Extract x_ignore_nofocus.so from x86, amd64 directories inside // the jar into a real place in the filesystem and change LD_LIBRARY_PATH // to reflect that. string existingLdLibPath = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH"); // The returned new ld lib path is terminated with ':' string newLdLibPath = ExtractAndCheck(profile, NoFocusLibraryName, "x86", "amd64"); if (!string.IsNullOrEmpty(existingLdLibPath)) { newLdLibPath += existingLdLibPath; } this.SetEnvironmentProperty("LD_LIBRARY_PATH", newLdLibPath); // Set LD_PRELOAD to x_ignore_nofocus.so - this will be taken automagically // from the LD_LIBRARY_PATH this.SetEnvironmentProperty("LD_PRELOAD", NoFocusLibraryName); }
private static string ExtractAndCheck(FirefoxProfile profile, string noFocusSoName, string libraryPath32Bit, string libraryPath64Bit) { List <string> list = new List <string>(); list.Add(libraryPath32Bit); list.Add(libraryPath64Bit); StringBuilder stringBuilder = new StringBuilder(); foreach (string current in list) { string text = Path.Combine(profile.ProfileDirectory, current); string path = Path.Combine(text, noFocusSoName); string resourceId = string.Format(CultureInfo.InvariantCulture, "WebDriver.FirefoxNoFocus.{0}.dll", new object[] { current }); if (ResourceUtilities.IsValidResourceName(resourceId)) { using (Stream resourceStream = ResourceUtilities.GetResourceStream(noFocusSoName, resourceId)) { Directory.CreateDirectory(text); using (FileStream fileStream = File.Create(path)) { byte[] array = new byte[1000]; for (int i = resourceStream.Read(array, 0, array.Length); i > 0; i = resourceStream.Read(array, 0, array.Length)) { fileStream.Write(array, 0, i); } } } } if (!File.Exists(path)) { throw new WebDriverException("Could not locate " + current + ": native events will not work."); } stringBuilder.Append(text).Append(Path.PathSeparator); } return(stringBuilder.ToString()); }
private static ExtensionConnection CreateExtensionConnection(FirefoxBinary binary, FirefoxProfile profile) { FirefoxProfile profileToUse = profile; string suggestedProfile = Environment.GetEnvironmentVariable("webdriver.firefox.profile"); if (profileToUse == null && suggestedProfile != null) { profileToUse = new FirefoxProfileManager().GetProfile(suggestedProfile); } else if (profileToUse == null) { profileToUse = new FirefoxProfile(); profileToUse.AddExtension(false); } else { profileToUse.AddExtension(false); } ExtensionConnection extension = ConnectTo(binary, profileToUse, "localhost"); return(extension); }
public FirefoxDriver(FirefoxProfile profile) : this(new FirefoxOptions(profile, null)) { }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxDriver"/> class for a given profile, binary environment, and timeout value. /// </summary> /// <param name="binary">A <see cref="FirefoxBinary"/> object representing the operating system /// environmental settings used when running Firefox.</param> /// <param name="profile">A <see cref="FirefoxProfile"/> object representing the profile settings /// to be used in starting Firefox.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout) : this(binary, profile, DesiredCapabilities.Firefox(), commandTimeout) { }
private FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, ICapabilities capabilities, TimeSpan commandTimeout) : base(CreateExtensionConnection(binary, profile, commandTimeout), RemoveUnneededCapabilities(capabilities)) { this.binary = binary; this.profile = profile; }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxDriver"/> class for a given profile. /// </summary> /// <param name="profile">A <see cref="FirefoxProfile"/> object representing the profile settings /// to be used in starting Firefox.</param> public FirefoxDriver(FirefoxProfile profile) : this(new FirefoxBinary(), profile) { }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxDriver"/> class for a given profile and binary environment. /// </summary> /// <param name="binary">A <see cref="FirefoxBinary"/> object representing the operating system /// environmental settings used when running Firefox.</param> /// <param name="profile">A <see cref="FirefoxProfile"/> object representing the profile settings /// to be used in starting Firefox.</param> public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile) : this(binary, profile, RemoteWebDriver.DefaultCommandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxDriver"/> class for a given profile, binary environment, and timeout value. /// </summary> /// <param name="binary">A <see cref="FirefoxBinary"/> object representing the operating system /// environmental settings used when running Firefox.</param> /// <param name="profile">A <see cref="FirefoxProfile"/> object representing the profile settings /// to be used in starting Firefox.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout) : base(CreateExtensionConnection(binary, profile, commandTimeout), DesiredCapabilities.Firefox()) { this.binary = binary; this.profile = profile; }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxProfile"/> class. /// </summary> public FirefoxProfile() : this(Directory.CreateDirectory(FirefoxProfile.GenerateProfileDirectoryName()).FullName) { }
/// <summary> /// Connects the <see cref="FirefoxDriver"/> to a running instance of the WebDriver Firefox extension. /// </summary> /// <param name="binary">The <see cref="FirefoxBinary"/> to use to connect to the extension.</param> /// <param name="profile">The <see cref="FirefoxProfile"/> to use to connect to the extension.</param> /// <param name="host">The host name of the computer running the Firefox browser extension (usually "localhost").</param> /// <returns>A <see cref="ExtensionConnection"/> to the currently running Firefox extension.</returns> internal static ExtensionConnection ConnectTo(FirefoxBinary binary, FirefoxProfile profile, string host) { return(ExtensionConnectionFactory.ConnectTo(binary, profile, host)); }
private void ImportCapabilities(DesiredCapabilities capabilities) { foreach (KeyValuePair <string, object> pair in capabilities.CapabilitiesDictionary) { if (pair.Key == CapabilityType.BrowserName) { } else if (pair.Key == CapabilityType.BrowserVersion) { this.BrowserVersion = pair.Value.ToString(); } else if (pair.Key == CapabilityType.PlatformName) { this.PlatformName = pair.Value.ToString(); } else if (pair.Key == CapabilityType.Proxy) { this.Proxy = new Proxy(pair.Value as Dictionary <string, object>); } else if (pair.Key == CapabilityType.UnhandledPromptBehavior) { this.UnhandledPromptBehavior = (UnhandledPromptBehavior)Enum.Parse(typeof(UnhandledPromptBehavior), pair.Value.ToString(), true); } else if (pair.Key == CapabilityType.PageLoadStrategy) { this.PageLoadStrategy = (PageLoadStrategy)Enum.Parse(typeof(PageLoadStrategy), pair.Value.ToString(), true); } else if (pair.Key == FirefoxOptionsCapability) { Dictionary <string, object> mozFirefoxOptions = pair.Value as Dictionary <string, object>; foreach (KeyValuePair <string, object> option in mozFirefoxOptions) { if (option.Key == FirefoxArgumentsCapability) { object[] args = option.Value as object[]; for (int i = 0; i < args.Length; i++) { this.firefoxArguments.Add(args[i].ToString()); } } else if (option.Key == FirefoxPrefsCapability) { this.profilePreferences = option.Value as Dictionary <string, object>; } else if (option.Key == FirefoxLogCapability) { Dictionary <string, object> logDictionary = option.Value as Dictionary <string, object>; if (logDictionary.ContainsKey("level")) { this.logLevel = (FirefoxDriverLogLevel)Enum.Parse(typeof(FirefoxDriverLogLevel), logDictionary["level"].ToString(), true); } } else if (option.Key == FirefoxBinaryCapability) { this.browserBinaryLocation = option.Value.ToString(); } else if (option.Key == FirefoxProfileCapability) { this.profile = FirefoxProfile.FromBase64String(option.Value.ToString()); } else { this.AddAdditionalCapability(option.Key, option.Value); } } } else { this.AddAdditionalCapability(pair.Key, pair.Value, true); } } }
public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile) : this(new FirefoxOptions(profile, binary)) { }
public void ShouldReturnNullForInvalidProfileName() { FirefoxProfile profile = manager.GetProfile("ThisIsMyBogusProfileName"); Assert.IsNull(profile); }
private static ExtensionConnection CreateExtensionConnection(FirefoxBinary binary, FirefoxProfile profile) { FirefoxProfile profileToUse = profile; // TODO (JimEvans): Provide a "named profile" override. // string suggestedProfile = System.getProperty("webdriver.firefox.profile"); string suggestedProfile = null; if (profileToUse == null && suggestedProfile != null) { profileToUse = new FirefoxProfileManager().GetProfile(suggestedProfile); } else if (profileToUse == null) { profileToUse = new FirefoxProfile(); profileToUse.AddExtension(false); } else { profileToUse.AddExtension(false); } ExtensionConnection extension = ConnectTo(binary, profileToUse, "localhost"); return(extension); }
public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout) : this((FirefoxDriverService)null, new FirefoxOptions(profile, binary), commandTimeout) { }
public void SetUp() { profile = new FirefoxProfile(); }
public void ShouldGetNamedProfile() { FirefoxProfile profile = manager.GetProfile("default"); Assert.IsNotNull(profile); }
public MarionetteDriver(FirefoxBinary binary, FirefoxProfile profile, int port) : base(CreateCommandExecutor(binary, profile, port), DesiredCapabilities.Firefox()) { }
public void ShouldReturnNullForNullProfileName() { FirefoxProfile profile = manager.GetProfile(null); Assert.IsNull(profile); }
public void ShouldReturnNullForEmptyProfileName() { FirefoxProfile profile = manager.GetProfile(string.Empty); Assert.IsNull(profile); }
/// <summary> /// Initializes a new instance of the <see cref="FirefoxDriverCommandExecutor"/> class. /// </summary> /// <param name="binary">The <see cref="FirefoxBinary"/> on which to make the connection.</param> /// <param name="profile">The <see cref="FirefoxProfile"/> creating the connection.</param> /// <param name="host">The name of the host on which to connect to the Firefox extension (usually "localhost").</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public FirefoxDriverCommandExecutor(FirefoxBinary binary, FirefoxProfile profile, string host, TimeSpan commandTimeout) { this.server = new FirefoxDriverServer(binary, profile, host); this.commandTimeout = commandTimeout; }
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; }