Class: Async::WebDriver::Client
- Inherits:
-
Object
- Object
- Async::WebDriver::Client
- Includes:
- RequestHelper
- Defined in:
- lib/async/webdriver/client.rb
Overview
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):
“‘ ruby begin client = Async::WebDriver::Client.open(Async::HTTP::Endpoint.parse(“localhost:4444”)) session = client.session ensure client&.close end “`
Constant Summary
Constants included from RequestHelper
RequestHelper::CONTENT_TYPE, RequestHelper::ELEMENT_KEY, RequestHelper::GET_HEADERS, RequestHelper::POST_HEADERS
Class Method Summary collapse
-
.open(endpoint, **options) ⇒ Object
Open a new session.
Instance Method Summary collapse
-
#close ⇒ Object
Close the client.
-
#initialize(delegate) ⇒ Client
constructor
Initialize the client.
-
#session(capabilities, &block) ⇒ Object
Request a new session.
Methods included from RequestHelper
#delete, #extract_value, #get, #post, #request_path, #unwrap_object, #unwrap_objects
Constructor Details
#initialize(delegate) ⇒ Client
Initialize the client.
47 48 49 |
# File 'lib/async/webdriver/client.rb', line 47 def initialize(delegate) @delegate = delegate end |
Class Method Details
.open(endpoint, **options) ⇒ Object
Open a new session.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/async/webdriver/client.rb', line 31 def self.open(endpoint, **) client = self.new( Async::HTTP::Client.open(endpoint, **) ) return client unless block_given? begin yield client ensure client.close end end |
Instance Method Details
#close ⇒ Object
Close the client.
52 53 54 |
# File 'lib/async/webdriver/client.rb', line 52 def close @delegate.close end |
#session(capabilities, &block) ⇒ Object
Request a new session.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/async/webdriver/client.rb', line 60 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 |