/// <summary> /// Returns DesiredCapabilities for Firefox with these options included as /// capabilities. This does not copy the options. Further changes will be /// reflected in the returned capabilities. /// </summary> /// <returns>The DesiredCapabilities for Firefox with these options.</returns> public override ICapabilities ToCapabilities() { DesiredCapabilities capabilities = new DesiredCapabilities(BrowserName, string.Empty, new Platform(PlatformType.Any)); if (this.isMarionette) { ISpecificationCompliant specCompliantCapabilities = capabilities as ISpecificationCompliant; specCompliantCapabilities.IsSpecificationCompliant = true; if (this.proxy != null) { Dictionary <string, object> proxyCapabiity = this.proxy.ToCapability(); if (proxyCapabiity != null) { capabilities.SetCapability(CapabilityType.Proxy, proxyCapabiity); } } Dictionary <string, object> firefoxOptions = this.GenerateFirefoxOptionsDictionary(); capabilities.SetCapability(FirefoxOptionsCapability, firefoxOptions); } else { if (this.profile != null) { if (this.proxy != null) { this.profile.InternalSetProxyPreferences(this.proxy); } capabilities.SetCapability(FirefoxProfileCapability, this.profile.ToBase64String()); } if (!string.IsNullOrEmpty(this.browserBinaryLocation)) { capabilities.SetCapability(FirefoxBinaryCapability, this.browserBinaryLocation); } else { using (FirefoxBinary executablePathBinary = new FirefoxBinary()) { string executablePath = executablePathBinary.BinaryExecutable.ExecutablePath; capabilities.SetCapability(FirefoxBinaryCapability, executablePath); } } } foreach (KeyValuePair <string, object> pair in this.additionalCapabilities) { capabilities.SetCapability(pair.Key, pair.Value); } return(capabilities); }
protected DesiredCapabilities GenerateDesiredCapabilities(bool isSpecificationCompliant) { DesiredCapabilities capabilities = new DesiredCapabilities(); ISpecificationCompliant specificationCompliantCapabilities = capabilities as ISpecificationCompliant; if (specificationCompliantCapabilities != null) { specificationCompliantCapabilities.IsSpecificationCompliant = isSpecificationCompliant; } if (!string.IsNullOrEmpty(this.browserName)) { capabilities.SetCapability(CapabilityType.BrowserName, this.browserName); } if (!string.IsNullOrEmpty(this.browserVersion)) { capabilities.SetCapability(CapabilityType.BrowserVersion, this.browserVersion); } if (!string.IsNullOrEmpty(this.platformName)) { capabilities.SetCapability(CapabilityType.PlatformName, this.platformName); } if (this.acceptInsecureCertificates.HasValue) { capabilities.SetCapability(CapabilityType.AcceptInsecureCertificates, this.acceptInsecureCertificates); } if (this.pageLoadStrategy != PageLoadStrategy.Default) { string pageLoadStrategySetting = "normal"; switch (this.pageLoadStrategy) { case PageLoadStrategy.Eager: pageLoadStrategySetting = "eager"; break; case PageLoadStrategy.None: pageLoadStrategySetting = "none"; break; } capabilities.SetCapability(CapabilityType.PageLoadStrategy, pageLoadStrategySetting); } if (this.UnhandledPromptBehavior != UnhandledPromptBehavior.Default) { string unhandledPropmtBehaviorSetting = "ignore"; switch (this.UnhandledPromptBehavior) { case UnhandledPromptBehavior.Accept: unhandledPropmtBehaviorSetting = "accept"; break; case UnhandledPromptBehavior.Dismiss: unhandledPropmtBehaviorSetting = "dismiss"; break; case UnhandledPromptBehavior.AcceptAndNotify: unhandledPropmtBehaviorSetting = "accept and notify"; break; case UnhandledPromptBehavior.DismissAndNotify: unhandledPropmtBehaviorSetting = "dismiss and notify"; break; } capabilities.SetCapability(CapabilityType.UnhandledPromptBehavior, unhandledPropmtBehaviorSetting); } if (this.Proxy != null) { Dictionary <string, object> proxyCapability = this.Proxy.ToCapability(); if (proxyCapability != null) { capabilities.SetCapability(CapabilityType.Proxy, proxyCapability); } } return(capabilities); }