Module: Symbiont::Evaluators

Included in:
Symbiont
Defined in:
lib/symbiont/evaluators.rb

Instance Method Summary collapse

Instance Method Details

#backObject



34
35
36
# File 'lib/symbiont/evaluators.rb', line 34

def back
  platform.back
end

#focusObject Also known as: what_has_focus?

Returns the element on a page that has the focus.



69
70
71
# File 'lib/symbiont/evaluators.rb', line 69

def focus
  platform.focus
end

#forwardObject



38
39
40
# File 'lib/symbiont/evaluators.rb', line 38

def forward
  platform.forward
end

#markupObject Also known as: html



58
59
60
# File 'lib/symbiont/evaluators.rb', line 58

def markup
  platform.markup
end

#refreshObject



42
43
44
# File 'lib/symbiont/evaluators.rb', line 42

def refresh
  platform.refresh
end

#remove_cookiesObject Also known as: clear_cookies



46
47
48
# File 'lib/symbiont/evaluators.rb', line 46

def remove_cookies
  platform.remove_cookies
end

#run_script(script) ⇒ Object Also known as: execute_script

Executes JavaScript against the browser instance.



28
29
30
# File 'lib/symbiont/evaluators.rb', line 28

def run_script(script)
  platform.run_script(script)
end

#screenshot(file) ⇒ Object Also known as: save_screenshot

Save a snapshot of the current screen to a provided file location. The file will be saved as a PNG file in the path specified or in the location where the tests are being run from.



21
22
23
# File 'lib/symbiont/evaluators.rb', line 21

def screenshot(file)
  platform.screenshot file
end

#textObject

Page-Level Actions ##



54
55
56
# File 'lib/symbiont/evaluators.rb', line 54

def text
  platform.text
end

#titleObject



64
65
66
# File 'lib/symbiont/evaluators.rb', line 64

def title
  platform.title
end

#urlObject Also known as: current_url



12
13
14
# File 'lib/symbiont/evaluators.rb', line 12

def url
  platform.url
end

#visit(url) ⇒ Object Also known as: navigate_to

Browser-Level Actions ##



6
7
8
# File 'lib/symbiont/evaluators.rb', line 6

def visit(url)
  platform.visit(url)
end

#wait_for_app(value = 1) ⇒ Object



75
76
77
# File 'lib/symbiont/evaluators.rb', line 75

def wait_for_app(value=1)
  sleep value
end

#wait_for_pending_requests(time_limit = 30, message_if_timeout = nil) ⇒ Object

Provides an evaluator that attempts to wait for any pending AJAX requests from the jQuery library.



81
82
83
84
85
86
87
88
89
# File 'lib/symbiont/evaluators.rb', line 81

def wait_for_pending_requests(time_limit=30, message_if_timeout=nil)
  end_time = ::Time.now + time_limit
  until ::Time.now > end_time
    return if @browser.execute_script('return jQuery.active') == 0
    sleep 0.5
  end
  message = "Pending jQuery requests never indicated completion." unless message_if_timeout
  raise message
end