Class: Pyrite::PyriteTest

Inherits:
ActionController::IntegrationTest
  • Object
show all
Includes:
Assertions, Dsl, Helpers
Defined in:
lib/pyrite/pyrite_test.rb

Instance Method Summary collapse

Methods included from Helpers

#fixture

Methods included from Assertions

#assert_element, #assert_no_element, #assert_no_text, #assert_text

Methods included from Dsl

#check, #click, #code_me, #drag_and_drop, #fill_in, #follow, #get_confirmation, #inside_iframe, #press, #select, #select_date, #show_me, #visit, #wait_for, #wait_for_frame

Instance Method Details

#browserObject

:nodoc:



13
14
15
16
17
18
19
20
21
# File 'lib/pyrite/pyrite_test.rb', line 13

def browser #:nodoc:
  $browser ||= Selenium::Client::Driver.new(
    :host => Pyrite.rc_host,
    :port => 4444,
    :browser => Pyrite.browser,
    :url => "#{Pyrite.sever_url}:#{Pyrite.server_port}",
    :timeout_in_second => Pyrite.timeout
  )
end

#setupObject

:nodoc:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/pyrite/pyrite_test.rb', line 23

def setup #:nodoc:
  DatabaseCleaner.clean
  browser.start_new_browser_session
  browser.get_eval "window.moveTo(1,0)"
  browser.window_maximize
  browser.add_location_strategy("jquery",
              "var loc = locator; " +
              "var attr = null; " +
              "var isattr = false; " +
              "var inx = locator.lastIndexOf('@'); " +

              "if (inx != -1){ " +
              "   loc = locator.substring(0, inx); " +
              "   attr = locator.substring(inx + 1); " +
              "   isattr = true; " +
              "} " +

              "var found = jQuery(inDocument).find(loc); " +
              "if (found.length >= 1) { " +
              "   if (isattr) { " +
              "       return found[0].getAttribute(attr); " +
              "   } else { " +
              "       return found[0]; " +
              "   } " +
              "} else { " +
              "   return null; " +
              "}"
          )
  super
end

#teardownObject

:nodoc:



54
55
56
57
# File 'lib/pyrite/pyrite_test.rb', line 54

def teardown #:nodoc:
  super
  browser.close_current_browser_session
end