Пример #1
0
        /// <summary>
        /// Creates a Selenium Server instance
        /// </summary>
        /// <param name="location">Directory where the selenium jar file is located</param>
        /// <param name="package">Is the name of the selenium jar file to execute</param>
        /// <param name="displayCommandWindow">Indicates if the command window running selenium should be displayed</param>
        /// <returns>Instance of the SeleniumServer class</returns>
        /// <remarks>Class acts as a singleton to ensure only one instance of the selenium server is running at any one time.</remarks>
        public static SeleniumServer Create(string location, string package, bool displayCommandWindow)
        {
            if (Server == null)
            {
                Server = new SeleniumServer(location, package, displayCommandWindow);
            }

            return(Server);
        }
        /// <summary>
        /// Creates a new instance of this class
        /// </summary>
        /// <param name="seleniumServer">Instance of the SeleniumServer to use</param>
        /// <returns>Instance of SeleniumSupport class</returns>
        /// <exception cref="ArgumentNullException">Exception thrown if the selenium server is not provided</exception>
        public static SeleniumSupport Create(SeleniumServer seleniumServer)
        {
            if (seleniumServer == null)
            {
                throw new ArgumentNullException("seleniumServer");
            }

            if (Instance == null || Instance._disposed)
            {
                Instance = new SeleniumSupport(seleniumServer);
            }

            return(Instance);
        }
 /// <summary>
 /// Private constructor to remove ability for class to be instantiated
 /// </summary>
 SeleniumSupport(SeleniumServer seleniumServer)
 {
     this.Server = seleniumServer;
     _disposed   = false;
     Instances   = new List <ISelenium>();
 }
        private void Dispose(bool disposing)
        {
            if (!this._disposed)
            {
                if (disposing)
                {
                    if (!_seleniumProcess.HasExited)
                    {
                        Stop();
                    }
                    Server = null;
                }
            }

            this._disposed = true;
        }
        /// <summary>
        /// Creates a Selenium Server instance
        /// </summary>
        /// <param name="location">Directory where the selenium jar file is located</param>
        /// <param name="package">Is the name of the selenium jar file to execute</param>
        /// <param name="displayCommandWindow">Indicates if the command window running selenium should be displayed</param>
        /// <returns>Instance of the SeleniumServer class</returns>
        /// <remarks>Class acts as a singleton to ensure only one instance of the selenium server is running at any one time.</remarks>
        public static SeleniumServer Create(string location, string package, bool displayCommandWindow)
        {
            if (Server == null)
            {
                Server = new SeleniumServer(location, package, displayCommandWindow);
            }

            return Server;
        }
        private SeleniumSupport CreateTarget(bool showWindow)
        {
            if(SeleniumServer == null)
                SeleniumServer = SeleniumServer.Create(_location, _package, showWindow);

            return SeleniumSupport.Create(SeleniumServer);
        }
        /// <summary>
        /// Creates a new instance of this class
        /// </summary>
        /// <param name="seleniumServer">Instance of the SeleniumServer to use</param>
        /// <returns>Instance of SeleniumSupport class</returns>
        /// <exception cref="ArgumentNullException">Exception thrown if the selenium server is not provided</exception>
        public static SeleniumSupport Create(SeleniumServer seleniumServer)
        {
            if(seleniumServer == null)
            {
                throw new ArgumentNullException("seleniumServer");
            }

            if(Instance == null || Instance._disposed)
            {
                Instance = new SeleniumSupport(seleniumServer);
            }

            return Instance;
        }
 /// <summary>
 /// Private constructor to remove ability for class to be instantiated
 /// </summary>
 SeleniumSupport(SeleniumServer seleniumServer)
 {
     this.Server = seleniumServer;
     _disposed = false;
     Instances = new List<ISelenium>();
 }