class Client
A client for the WebDriver protocol.
If you have a running web driver server, you can connect to it like so (assuming it is running on port 4444):
begin
client = Async::WebDriver::Client.open(Async::HTTP::Endpoint.parse("http://localhost:4444"))
session = client.session
ensure
client&.close
end
Definitions
def self.open(endpoint, **options)
Open a new session.
Signature
-
parameter
endpointAsync::HTTP::Endpoint The endpoint to connect to.
-
yields
{|client| ...} The client will be closed automatically if you provide a block.
-
parameter
clientClient The client.
-
parameter
-
returns
Client The client if no block is given.
Implementation
def self.open(endpoint, **options)
client = self.new(
Async::HTTP::Client.open(endpoint, **options)
)
return client unless block_given?
begin
yield client
ensure
client.close
end
end
def initialize(delegate)
Initialize the client.
Signature
-
parameter
delegateProtocol::HTTP::Middleware The underlying HTTP client (or wrapper).
Implementation
def initialize(delegate)
@delegate = delegate
end
def close
Close the client.
Implementation
def close
@delegate.close
end
def session(capabilities, &block)
Request a new session.
Signature
-
returns
Session The session if no block is given.
-
yields
{|session| ...} The session will be closed automatically if you provide a block.
-
parameter
sessionSession The session.
-
parameter
Implementation
def session(capabilities, &block)
reply = post("session", {capabilities: capabilities})
session = Session.new(@delegate, reply["sessionId"], reply["capabilities"])
return session unless block_given?
begin
yield session
ensure
session.close
end
end