Class: DriverMetaData
- Inherits:
-
Object
- Object
- DriverMetaData
- Defined in:
- lib/driver_metadata.rb
Instance Method Summary collapse
- #capabilities ⇒ Object
- #command_executor_url ⇒ Object
-
#initialize(driver) ⇒ DriverMetaData
constructor
A new instance of DriverMetaData.
- #session_id ⇒ Object
Constructor Details
#initialize(driver) ⇒ DriverMetaData
Returns a new instance of DriverMetaData.
4 5 6 |
# File 'lib/driver_metadata.rb', line 4 def initialize(driver) @driver = driver end |
Instance Method Details
#capabilities ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/driver_metadata.rb', line 40 def capabilities cached = Cache.get_cache(session_id, Cache::CAPABILITIES) return cached unless cached.nil? caps = begin @driver.capabilities.as_json rescue StandardError begin @driver.capabilities.to_h rescue StandardError {} end end Cache.set_cache(session_id, Cache::CAPABILITIES, caps) caps end |
#command_executor_url ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/driver_metadata.rb', line 12 def command_executor_url cached = Cache.get_cache(session_id, Cache::COMMAND_EXECUTOR_URL) return cached unless cached.nil? url = nil begin raw = @driver.send(:bridge).http.send(:server_url) url = raw.to_s unless raw.nil? rescue StandardError => e if defined?(Percy) Percy.log("Could not get command_executor_url via bridge.http.server_url: #{e}", 'debug') end end if url.nil? || url.empty? begin raw = @driver.send(:bridge).http.instance_variable_get(:@server_url) url = raw.to_s unless raw.nil? rescue StandardError => e Percy.log("Could not get @server_url instance variable: #{e}", 'debug') if defined?(Percy) end end url ||= '' Cache.set_cache(session_id, Cache::COMMAND_EXECUTOR_URL, url) url end |
#session_id ⇒ Object
8 9 10 |
# File 'lib/driver_metadata.rb', line 8 def session_id @driver.session_id end |