/// <summary>
        /// Registers the node. Will over-write the
        /// <c>SeleniumNodeOptions.Hub</c> property with the hubs
        /// 'register node' url.
        /// </summary>
        /// <param name="seleniumNodeOptions">The selenium node.</param>
        /// <returns>The created selenium node.</returns>
        public SeleniumNode RegisterNode(SeleniumNodeOptions seleniumNodeOptions)
        {
            if (seleniumNodeOptions == null)
            {
                throw new ArgumentNullException(nameof(seleniumNodeOptions));
            }
            else if (WrappedProcess == null)
            {
                throw new Exception("Hub hasn't been started yet.");
            }

            // Assign the register url to the hub property.
            seleniumNodeOptions.Hub = NodeRegisterUrl.ToString();
            var seleniumNode = new SeleniumNode(seleniumNodeOptions);

            seleniumNode.StartProcess();
            registeredNodes.Add(seleniumNode);

            return(seleniumNode);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebDriverFactory"/>
        /// class. NOTE: This will create a hub and node process for better
        /// performance when running tests in parallel.
        /// </summary>
        /// <param name="seleniumHubOptions">The selenium hub options.</param>
        /// <param name="seleniumNodeOptions">The selenium node options.</param>
        /// <exception cref="ArgumentNullException">
        /// seleniumHubOptions
        /// or
        /// seleniumNodeOptions
        /// </exception>
        /// <exception cref="Exception">
        /// Failed to start the hub process.
        /// or
        /// Failed to start the node process.
        /// </exception>
        public WebDriverFactory(
            SeleniumHubOptions seleniumHubOptions,
            SeleniumNodeOptions seleniumNodeOptions)
        {
            if (seleniumHubOptions == null)
            {
                throw new ArgumentNullException(nameof(seleniumHubOptions));
            }
            else if (seleniumNodeOptions == null)
            {
                throw new ArgumentNullException(nameof(seleniumNodeOptions));
            }

            isStandalone   = false;
            disposedValue  = false;
            driverManager  = new DriverManager();
            trackedDrivers = new List <IWebDriver>();
            seleniumHub    = new SeleniumHub(seleniumHubOptions);

            seleniumHub.StartProcess();
            seleniumHub.RegisterNode(seleniumNodeOptions);
        }