/// <summary> /// Initializes a new instance of the <see cref="SafariDriverServer"/> class using the specified options. /// </summary> /// <param name="options">The <see cref="SafariOptions"/> defining the browser settings.</param> public SafariDriverServer(SafariOptions options) { if (options == null) { throw new ArgumentNullException("options", "options must not be null"); } int webSocketPort = options.Port; if (webSocketPort == 0) { webSocketPort = PortUtilities.FindFreePort(); } this.webSocketServer = new WebSocketServer(webSocketPort, "ws://localhost/wd"); this.webSocketServer.Opened += new EventHandler<ConnectionEventArgs>(this.ServerOpenedEventHandler); this.webSocketServer.Closed += new EventHandler<ConnectionEventArgs>(this.ServerClosedEventHandler); this.webSocketServer.StandardHttpRequestReceived += new EventHandler<StandardHttpRequestReceivedEventArgs>(this.ServerStandardHttpRequestReceivedEventHandler); this.serverUri = new Uri(string.Format(CultureInfo.InvariantCulture, "http://localhost:{0}/", webSocketPort.ToString(CultureInfo.InvariantCulture))); if (string.IsNullOrEmpty(options.SafariLocation)) { this.safariExecutableLocation = GetDefaultSafariLocation(); } else { this.safariExecutableLocation = options.SafariLocation; } }
/// <summary> /// Initializes a new instance of the <see cref="SafariDriverServer"/> class using a specific port for communication. /// </summary> /// <param name="port">The port to use to communicate.</param> public SafariDriverServer(int port) { if (port == 0) { port = PortUtilities.FindFreePort(); } this.server = new WebSocketServer(port, "ws://localhost/wd"); this.server.Opened += new EventHandler<ConnectionEventArgs>(this.ServerOpenedEventHandler); this.server.Closed += new EventHandler<ConnectionEventArgs>(this.ServerClosedEventHandler); this.server.StandardHttpRequestReceived += new EventHandler<StandardHttpRequestReceivedEventArgs>(this.ServerStandardHttpRequestReceivedEventHandler); this.serverUri = new Uri(string.Format(CultureInfo.InvariantCulture, "http://localhost:{0}/", port.ToString(CultureInfo.InvariantCulture))); }
/// <summary> /// Initializes a new instance of the <see cref="SafariDriverServer"/> class using the specified options. /// </summary> /// <param name="options">The <see cref="SafariOptions"/> defining the browser settings.</param> public SafariDriverServer(SafariOptions options) { int webSocketPort = options.Port; if (webSocketPort == 0) { webSocketPort = PortUtilities.FindFreePort(); } this.webSocketServer = new WebSocketServer(webSocketPort, "ws://localhost/wd"); this.webSocketServer.Opened += new EventHandler<ConnectionEventArgs>(this.ServerOpenedEventHandler); this.webSocketServer.Closed += new EventHandler<ConnectionEventArgs>(this.ServerClosedEventHandler); this.webSocketServer.StandardHttpRequestReceived += new EventHandler<StandardHttpRequestReceivedEventArgs>(this.ServerStandardHttpRequestReceivedEventHandler); this.serverUri = new Uri(string.Format(CultureInfo.InvariantCulture, "http://localhost:{0}/", webSocketPort.ToString(CultureInfo.InvariantCulture))); if (string.IsNullOrEmpty(options.SafariLocation)) { this.safariExecutableLocation = GetDefaultSafariLocation(); } else { this.safariExecutableLocation = options.SafariLocation; } this.extension = new SafariDriverExtension(options.CustomExtensionPath, options.SkipExtensionInstallation); }