diff --git a/lib/ferrum/client/web_socket.rb b/lib/ferrum/client/web_socket.rb index e88d73bc..55e71188 100644 --- a/lib/ferrum/client/web_socket.rb +++ b/lib/ferrum/client/web_socket.rb @@ -19,7 +19,7 @@ def initialize(url, max_receive_size, logger) uri = URI.parse(@url) port = uri.port || DEFAULT_PORTS[uri.scheme] - if port == 443 + if port == 443 || url.scheme == 'wss' tcp = TCPSocket.new(uri.host, port) ssl_context = OpenSSL::SSL::SSLContext.new @sock = OpenSSL::SSL::SSLSocket.new(tcp, ssl_context) diff --git a/lib/ferrum/context.rb b/lib/ferrum/context.rb index 55c986f6..4fdfe877 100644 --- a/lib/ferrum/context.rb +++ b/lib/ferrum/context.rb @@ -61,6 +61,8 @@ def add_target(params:, session_id: nil) new_target = Target.new(@client, session_id, params) # `put_if_absent` returns nil if added a new value or existing if there was one already target = @targets.put_if_absent(new_target.id, new_target) || new_target + # on first iteration session_id may be null, then if session is present here we must set it to the target + target.session_id = session_id if session_id @default_target ||= target new_pending = Concurrent::IVar.new