Class: Async::WebDriver::Session
- Inherits:
-
Object
- Object
- Async::WebDriver::Session
- Includes:
- RequestHelper, Async::WebDriver::Scope::Alerts, Async::WebDriver::Scope::Cookies, Async::WebDriver::Scope::Document, Async::WebDriver::Scope::Elements, Async::WebDriver::Scope::Fields, Async::WebDriver::Scope::Frames, Async::WebDriver::Scope::Navigation, Async::WebDriver::Scope::Printing, Async::WebDriver::Scope::ScreenCapture, Async::WebDriver::Scope::Timeouts
- Defined in:
- lib/async/webdriver/session.rb
Overview
A session represents a single browser session, potentially with multiple windows. It is the primary interface for interacting with a browser.
“‘ ruby begin bridge = Async::WebDriver::Bridge::Pool.start(Async::WebDriver::Bridge::Chrome.new) session = bridge.session session.navigate_to(“google.com”) # … ensure bridge&.close end “`
Constant Summary
Constants included from RequestHelper
RequestHelper::CONTENT_TYPE, RequestHelper::ELEMENT_KEY, RequestHelper::GET_HEADERS, RequestHelper::POST_HEADERS
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#delegate ⇒ Object
readonly
Returns the value of attribute delegate.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
- #The session identifier.(sessionidentifier.) ⇒ Object readonly
- #The underlying HTTP client (or wrapper).(underlyingHTTPclient() ⇒ Object
Class Method Summary collapse
-
.open(endpoint, *arguments, **options) ⇒ Object
Open a new session.
Instance Method Summary collapse
-
#close ⇒ Object
Close the session.
- #current_scope ⇒ Object
-
#initialize(delegate, id, capabilities) ⇒ Session
constructor
Initialize the session.
- #inspect ⇒ Object
-
#request_path(path = nil) ⇒ Object
The path used for making requests to the web driver bridge.
- #session ⇒ Object
- #The capabilities of the session.=(capabilitiesofthesession. = (value)) ⇒ Object
Methods included from Async::WebDriver::Scope::Timeouts
#implicit_wait_timeout, #implicit_wait_timeout=, #page_load_timeout, #page_load_timeout=, #script_timeout, #script_timeout=, #timeouts
Methods included from Async::WebDriver::Scope::ScreenCapture
Methods included from Async::WebDriver::Scope::Printing
Methods included from Async::WebDriver::Scope::Navigation
#current_path, #current_url, #navigate_back, #navigate_forward, #navigate_to, #refresh
Methods included from Async::WebDriver::Scope::Frames
#switch_to_frame, #switch_to_parent_frame
Methods included from Async::WebDriver::Scope::Fields
#check, #click_button, #fill_in, #find_field
Methods included from Async::WebDriver::Scope::Elements
#children, #find_element, #find_element_by_css, #find_element_by_link_text, #find_element_by_partial_link_text, #find_element_by_tag_name, #find_element_by_xpath, #find_elements, #find_elements_by_css, #find_elements_by_link_text, #find_elements_by_partial_link_text, #find_elements_by_tag_name, #find_elements_by_xpath
Methods included from Async::WebDriver::Scope::Document
#execute, #execute_async, #source, #title
Methods included from Async::WebDriver::Scope::Cookies
#add_cookie, #cookie, #cookies, #delete_all_cookies, #delete_cookie
Methods included from Async::WebDriver::Scope::Alerts
#accept_alert, #alert_text, #dismiss_alert, #set_alert_text
Methods included from RequestHelper
#delete, #extract_value, #get, #post, #unwrap_object, #unwrap_objects
Constructor Details
#initialize(delegate, id, capabilities) ⇒ Session
Initialize the session.
50 51 52 53 54 |
# File 'lib/async/webdriver/session.rb', line 50 def initialize(delegate, id, capabilities) @delegate = delegate @id = id @capabilities = capabilities end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
67 68 69 |
# File 'lib/async/webdriver/session.rb', line 67 def capabilities @capabilities end |
#delegate ⇒ Object (readonly)
Returns the value of attribute delegate.
61 62 63 |
# File 'lib/async/webdriver/session.rb', line 61 def delegate @delegate end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
64 65 66 |
# File 'lib/async/webdriver/session.rb', line 64 def id @id end |
#The session identifier.(sessionidentifier.) ⇒ Object (readonly)
64 |
# File 'lib/async/webdriver/session.rb', line 64 attr :id |
#The underlying HTTP client (or wrapper).(underlyingHTTPclient() ⇒ Object
61 |
# File 'lib/async/webdriver/session.rb', line 61 attr :delegate |
Class Method Details
.open(endpoint, *arguments, **options) ⇒ Object
Open a new session.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/async/webdriver/session.rb', line 31 def self.open(endpoint, *arguments, **) client = self.new( Async::HTTP::Client.open(endpoint, **), *arguments ) return client unless block_given? begin yield client ensure client.close end end |
Instance Method Details
#close ⇒ Object
Close the session.
83 84 85 86 87 88 |
# File 'lib/async/webdriver/session.rb', line 83 def close if @delegate self.delete @delegate = nil end end |
#current_scope ⇒ Object
96 97 98 |
# File 'lib/async/webdriver/session.rb', line 96 def current_scope self end |
#inspect ⇒ Object
56 57 58 |
# File 'lib/async/webdriver/session.rb', line 56 def inspect "\#<#{self.class} id=#{@id.inspect}>" end |
#request_path(path = nil) ⇒ Object
The path used for making requests to the web driver bridge.
72 73 74 75 76 77 78 |
# File 'lib/async/webdriver/session.rb', line 72 def request_path(path = nil) if path "/session/#{@id}/#{path}" else "/session/#{@id}" end end |
#session ⇒ Object
91 92 93 |
# File 'lib/async/webdriver/session.rb', line 91 def session self end |
#The capabilities of the session.=(capabilitiesofthesession. = (value)) ⇒ Object
67 |
# File 'lib/async/webdriver/session.rb', line 67 attr :capabilities |