Class: Web
- Includes:
- Webdriver
- Defined in:
- lib/platform/web/web.rb
Overview
Web adds to or modifies a Platform Web-specific functionality
Instance Attribute Summary
Attributes inherited from Platform
#id, #keys, #remotes, #roi, #screens
Instance Method Summary collapse
-
#init?(browser, sleep_time: 0.sec) ⇒ Boolean
Public: Initializes a Web device.
-
#initialize(browser, test_case) ⇒ Web
constructor
Public: Initializes a Web device.
-
#navigate?(url) ⇒ Boolean
Public: Navigates to the specified screen or URL.
Methods included from Webdriver
#click?, #close?, #double_click?, #forward?, #refresh?, #send?, #type?
Methods included from Selenium
#back?, #element, #element?, #elements, #elements?, #time_to_element, #time_to_elements, #type?
Methods inherited from Platform
#alt_parental_controls_pin, #app_version, #audio_level, #audio_level_left, #audio_level_right, #audio_present?, #capture_audio, #capture_frames, #capture_screen, #device_type_is?, #device_type_not?, #entitlements, #has_power?, #height, #high_def?, #ip_address, #is_generic?, #lock, #mac_address, #model, #name, #parental_controls_pin, #password, #platform, #power_cycle, #power_off, #power_on, #power_on?, #press_key, #record_audio, #record_video, #remote_type=, #remote_type_is?, #reset_video, #resolution, #save_last_screen_captured, #slot, #snmp_get, #snmp_set, #software_version, #stop_audio, #stop_video, #upload_screenshot, #username, #width
Constructor Details
#initialize(browser, test_case) ⇒ Web
Public: Initializes a Web device.
10 11 12 13 14 |
# File 'lib/platform/web/web.rb', line 10 def initialize(browser, test_case) super(test_case) @browser = browser @ready = false end |
Instance Method Details
#init?(browser, sleep_time: 0.sec) ⇒ Boolean
Public: Initializes a Web device.
browser - Symbol name of browser to launch, can be :firefox, :chrome. sleep_time - Integer total milliseconds to sleep after establishing the session (default: 0).
Returns a Boolean true if the device was initialized, otherwise false.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/platform/web/web.rb', line 37 def init?(browser, sleep_time: 0.sec) super() do ret = selenium_post(nil, {:browser => browser}) if ret.nil? @ready = false else @id = ret['id'] sleep(sleep_time) @ready = true end @ready end end |
#navigate?(url) ⇒ Boolean
Public: Navigates to the specified screen or URL.
url - String URL to navigate to.
Returns a Boolean true if successfully navigated, otherwise false.
21 22 23 24 25 26 27 28 29 |
# File 'lib/platform/web/web.rb', line 21 def navigate?(url) unless @ready unless self.init?(browser: @browser) raise 'Failed to launch browser!' end @test_case.add_teardown('Closing browser') { self.close? } end super(url) end |