Module: WDA::Session
- Included in:
- WDA
- Defined in:
- lib/wda_lib/session.rb
Instance Method Summary collapse
-
#healthcheck ⇒ Object
Healthcheck.
-
#launch_app(app_name_or_id) ⇒ self
Post desiredCapabilities to wda server to create a session This is not realy needed since we can find and click app icon to start app.
-
#quit(session_id = nil) ⇒ Object
Exit current app by delete session with given session_id.
-
#restart(app_name_or_id = nil) ⇒ self
recreate a session.
-
#session ⇒ Session
Get current valid session.
-
#status ⇒ Obj
Get current status.
-
#x ⇒ Object
Same as quit, but delete default @session_id.
Instance Method Details
#healthcheck ⇒ Object
Healthcheck
75 76 77 78 |
# File 'lib/wda_lib/session.rb', line 75 def healthcheck response = get(@base_url + '/healthcheck') update_status(response) end |
#launch_app(app_name_or_id) ⇒ self
Post desiredCapabilities to wda server to create a session This is not realy needed since we can find and click app icon to start app
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/wda_lib/session.rb', line 37 def launch_app(app_name_or_id) fail 'Either app name or bundle id should be given for launch app' if app_name_or_id.nil? if app_name_or_id.include?('.') # Given value is app's bundle id @bundle_id = app_name_or_id @session_id = nil # Prepare to create new session @session_valid = false # Prepare to create new session capabilities @driver = Selenium::WebDriver::Driver.for(:remote, :url => @base_url, :desired_capabilities => @caps[:desiredCapabilities]) status else app_name = app_name_or_id find_app(app_name).click end self end |
#quit(session_id = nil) ⇒ Object
Exit current app by delete session with given session_id
63 64 65 66 67 |
# File 'lib/wda_lib/session.rb', line 63 def quit(session_id = nil) (session_id.nil?)? sessionId = @session_id : sessionId = session_id @base_url + '/session/' + sessionId delete(@base_url + '/session/' + sessionId) end |
#restart(app_name_or_id = nil) ⇒ self
recreate a session
55 56 57 58 |
# File 'lib/wda_lib/session.rb', line 55 def restart(app_name_or_id = nil) quit launch_app(app_name_or_id ||= @bundle_id ) end |
#session ⇒ Session
Get current valid session
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/wda_lib/session.rb', line 13 def session response = get(@url) if response['status'] != 0 if response['status'] == 10 response['value'] restart_session response = get(@url) elsif response['status'] == 1 || response['status'] == 6 @session_id = response['sessionId'] @url = @base_url + "/session/#{@session_id}" response = get(@url) end else @session_id = response['sessionId'] @caps[:desiredCapabilities][:session_id] = @session_id @caps[:desiredCapabilities][:session_valid] = true @url = @base_url + "/session/#{@session_id}" end response end |
#status ⇒ Obj
Get current status
6 7 8 9 |
# File 'lib/wda_lib/session.rb', line 6 def status @status = get(@base_url + '/status') update_status(@status) end |
#x ⇒ Object
Same as quit, but delete default @session_id
70 71 72 |
# File 'lib/wda_lib/session.rb', line 70 def x quit end |