public void SetName()
        {
            if (SeleniumConfig.GetBrowserName().Equals("Remote", System.StringComparison.CurrentCultureIgnoreCase))
            {
                try
                {
                    string name = TestContext.FullyQualifiedTestClassName + "." + TestContext.TestName;

                    RemoteBrowserType           remoteBrowser        = SeleniumConfig.GetRemoteBrowserType();
                    string                      remotePlatform       = SeleniumConfig.GetRemotePlatform();
                    string                      remoteBrowserVersion = SeleniumConfig.GetRemoteBrowserVersion();
                    Dictionary <string, object> capabilities         = SeleniumConfig.GetRemoteCapabilitiesAsObjects();
                    capabilities.Add("build", Environment.GetEnvironmentVariable("SAUCE_BUILD_NAME"));
                    capabilities.Add("name", name);
                    capabilities.Add("extendedDebugging", Config.GetValueForSection(ConfigSection.SeleniumMaqs, "extendedDebugging"));

                    var options = WebDriverFactory.GetRemoteOptions(remoteBrowser, remotePlatform, remoteBrowserVersion, capabilities);

                    this.WebDriver = new RemoteWebDriver(SeleniumConfig.GetHubUri(), options.ToCapabilities(), SeleniumConfig.GetCommandTimeout());
                }
                catch (Exception e)
                {
                    Log.LogMessage(MessageType.WARNING, "Failed to set Sauce name because: " + e.Message);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Get the default remote driver options - Default values are pulled from the configuration
        /// </summary>
        /// <returns>The remote driver options</returns>
        public static DriverOptions GetDefaultRemoteOptions()
        {
            RemoteBrowserType           remoteBrowser        = SeleniumConfig.GetRemoteBrowserType();
            string                      remotePlatform       = SeleniumConfig.GetRemotePlatform();
            string                      remoteBrowserVersion = SeleniumConfig.GetRemoteBrowserVersion();
            Dictionary <string, object> capabilities         = SeleniumConfig.GetRemoteCapabilitiesAsObjects();

            return(GetRemoteOptions(remoteBrowser, remotePlatform, remoteBrowserVersion, capabilities));
        }
Example #3
0
        /// <summary>
        /// Get the remote driver options
        /// </summary>
        /// <param name="remoteBrowser">The remote browser type</param>
        /// <param name="remotePlatform">The remote platform</param>
        /// <param name="remoteBrowserVersion">The remote browser version</param>
        /// <param name="remoteCapabilities">Additional remote capabilities</param>
        /// <returns>The remote driver options</returns>
        public static DriverOptions GetRemoteOptions(RemoteBrowserType remoteBrowser, string remotePlatform, string remoteBrowserVersion, Dictionary <string, object> remoteCapabilities)
        {
            DriverOptions options = null;

            switch (remoteBrowser)
            {
            case RemoteBrowserType.IE:
                options = new InternetExplorerOptions();
                break;

            case RemoteBrowserType.Firefox:
                options = new FirefoxOptions();
                break;

            case RemoteBrowserType.Chrome:
                options = new ChromeOptions();
                break;

            case RemoteBrowserType.Edge:
                options = new EdgeOptions();
                break;

            case RemoteBrowserType.Safari:
                options = new SafariOptions();
                break;

            default:
                throw new ArgumentException(StringProcessor.SafeFormatter("Remote browser type '{0}' is not supported", remoteBrowser));
            }

            // Make sure the remote capabilities dictonary exists
            if (remoteCapabilities == null)
            {
                remoteCapabilities = new Dictionary <string, object>();
            }

            // Add a platform setting if one was provided
            if (!string.IsNullOrEmpty(remotePlatform) && !remoteCapabilities.ContainsKey("platform"))
            {
                remoteCapabilities.Add("platform", remotePlatform);
            }

            // Add a remote browser setting if one was provided
            if (!string.IsNullOrEmpty(remoteBrowserVersion) && !remoteCapabilities.ContainsKey("version"))
            {
                remoteCapabilities.Add("version", remoteBrowserVersion);
            }

            // Add additional capabilities to the driver options
            options.SetDriverOptions(remoteCapabilities);

            return(options);
        }
Example #4
0
        /// <summary>
        /// Get the remote driver options
        /// </summary>
        /// <param name="remoteBrowser">The remote browser type</param>
        /// <param name="remotePlatform">The remote platform</param>
        /// <param name="remoteBrowserVersion">The remote browser version</param>
        /// <param name="remoteCapabilities">Additional remote capabilities</param>
        /// <returns>The remote driver options</returns>
        public static DriverOptions GetRemoteOptions(RemoteBrowserType remoteBrowser, string remotePlatform, string remoteBrowserVersion, Dictionary <string, string> remoteCapabilities)
        {
            Dictionary <string, object> capabilities;

            if (remoteCapabilities != null)
            {
                capabilities = remoteCapabilities.ToDictionary(pair => pair.Key, pair => (object)pair.Value);
            }
            else
            {
                capabilities = new Dictionary <string, object>();
            }
            return(GetRemoteOptions(remoteBrowser, remotePlatform, remoteBrowserVersion, capabilities));
        }
Example #5
0
 /// <summary>
 /// Get the remote driver options
 /// </summary>
 /// <param name="remoteBrowser">The remote browser type</param>
 /// <param name="remoteCapabilities">Additional remote capabilities</param>
 /// <returns>The remote driver options</returns>
 public static DriverOptions GetRemoteOptions(RemoteBrowserType remoteBrowser, Dictionary <string, object> remoteCapabilities)
 {
     return(GetRemoteOptions(remoteBrowser, string.Empty, string.Empty, remoteCapabilities));
 }
Example #6
0
 /// <summary>
 /// Get the remote driver options
 /// </summary>
 /// <param name="remoteBrowser">The remote browser type</param>
 /// <returns>The remote driver options</returns>
 public static DriverOptions GetRemoteOptions(RemoteBrowserType remoteBrowser)
 {
     return(GetRemoteOptions(remoteBrowser, string.Empty, string.Empty, new Dictionary <string, string>()));
 }