Module: RWebSpec::WebDriver::RSpecHelper

Includes:
Assert, Driver, Utils
Defined in:
lib/rwebspec-webdriver/rspec_helper.rb

Constant Summary

Constants included from Utils

Utils::WORDS

Instance Method Summary collapse

Methods included from Utils

#allow, #days_before, #days_from_now, #failsafe, #interpret_value, #on, #paragraphs, #random_boolean, #random_char, #random_digit, #random_number, #random_str, #random_string_in, #repeat_try, #sentences, #shall_not_allow, #symbol_to_sequence, #take_screenshot, #today, #tomorrow, #try, #try_for, #value_in_range, #words, #yesterday

Methods included from Assert

#assert_button_not_present, #assert_button_not_present_with_text, #assert_button_present, #assert_button_present_with_text, #assert_checkbox_not_selected, #assert_checkbox_selected, #assert_disabled, #assert_enabled, #assert_equals, #assert_exists, #assert_hidden, #assert_link_not_present_with_text, #assert_link_present_with_text, #assert_nil, #assert_not, #assert_not_exists, #assert_not_nil, #assert_option_equals, #assert_option_not_present, #assert_option_present, #assert_option_value_equals, #assert_option_value_not_present, #assert_option_value_present, #assert_radio_option_not_present, #assert_radio_option_not_selected, #assert_radio_option_present, #assert_radio_option_selected, #assert_text_field_value, #assert_text_in_element, #assert_text_in_page_source, #assert_text_not_in_page_source, #assert_text_not_present, #assert_text_not_present_in_table, #assert_text_present, #assert_text_present_in_table, #assert_title_equals, #assert_visible, #fail

Methods included from Driver

#absolutify_url, #absolutize_page, #absolutize_page_hpricot, #ajax_wait_for_element, #attach_browser, #basic_authentication, #basic_authentication_celerity, #basic_authentication_firefox, #basic_authentication_ie, #begin_at, #browser, #cell_with_id, #check_ie_version, #choose_file_dialog, #clear_popup, #click_button_with_image_src_contains, #close_all_browsers, #close_browser, #contains, #contains_text, #context, #default_dump_dir, #dump_response, #element_by_id, #ends_with?, #enter_text_with_id, #expect_page, #find_element, #find_elements, #firefox, #goto_page, #goto_url, #ie, #is_firefox?, #is_htmlunit?, #is_ie?, #is_linux?, #is_mac?, #is_windows?, #label_with_id, #new_popup_window, #open_browser, #page_source, #page_text, #page_title, #perform_operation, #quit, #save_current_page, #select_file_for_upload, #span_with_id, #substitute_relative_path_in_src_line, #support_utf8, #use_current_browser, #wait_for_element, #wait_until

Methods included from Popup

#check_for_popups, #check_for_security_alerts, #click_button_in_javascript_popup, #click_button_in_popup_after, #click_button_in_security_alert_popup, #click_button_in_security_information_popup, #click_popup_window, #ie_popup_clicker, #prepare_to_click_button_in_popup, #start_checking_js_dialog, #verify_alert

Methods included from TestWisePlugin

#check_for_pause, #connect_to_testwise, #debug, #dump_caller_stack, #notify_screenshot_location, #operation_delay

Instance Method Details

#be_odd_numberObject

RSpec Matchers

Example,

a_number.should be_odd_number


94
95
96
# File 'lib/rwebspec-webdriver/rspec_helper.rb', line 94

def be_odd_number
  simple_matcher("must be odd number") { |actual| actual && actual.to_id % 2 == 1}
end

#button_by_id(button_id) ⇒ Object



51
52
53
# File 'lib/rwebspec-webdriver/rspec_helper.rb', line 51

def button_by_id(button_id)
  button(:id, button_id)
end

#buttons_by_caption(text) ⇒ Object Also known as: buttons_by_text



55
56
57
# File 'lib/rwebspec-webdriver/rspec_helper.rb', line 55

def buttons_by_caption(text)
  button(:text, text)
end

#debugging?Boolean

When running

Returns:

  • (Boolean)


86
87
88
# File 'lib/rwebspec-webdriver/rspec_helper.rb', line 86

def debugging?
  $TESTWISE_DEBUGGING && $TESTWISE_RUNNING_AS == "test_case"
end

#element_source(elem_id) ⇒ Object

TODO: is it working?



46
47
48
# File 'lib/rwebspec-webdriver/rspec_helper.rb', line 46

def element_source(elem_id)
  @web_browser.get_html_in_element(elem_id)
end

#element_text(elem_id) ⇒ Object Also known as: element_text_by_id



40
41
42
# File 'lib/rwebspec-webdriver/rspec_helper.rb', line 40

def element_text(elem_id)
  @web_browser.element_value(elem_id)
end


60
61
62
# File 'lib/rwebspec-webdriver/rspec_helper.rb', line 60

def link_by_id(link_id)
  link(:id, link_id)
end

default options: exact => true



65
66
67
68
69
70
71
72
# File 'lib/rwebspec-webdriver/rspec_helper.rb', line 65

def links_by_text(link_text, options = {})
  options.merge!({:exact=> true})
  matching_links = []
  links.each { |link|
    matching_links << link if (options[:exact] ? link.text == link_text :  link.text.include?(link_text))
  }
  return matching_links
end

#save_content_to_file(content, file_name = nil) ⇒ Object



79
80
81
82
83
# File 'lib/rwebspec-webdriver/rspec_helper.rb', line 79

def save_content_to_file(content, file_name = nil)
  file_name ||= Time.now.strftime("%Y%m%d%H%M%S") + ".html"
  puts "about to save page: #{File.expand_path(file_name)}"
  File.open(file_name, "w").puts content
end

#save_page(file_name = nil) ⇒ Object



75
76
77
# File 'lib/rwebspec-webdriver/rspec_helper.rb', line 75

def save_page(file_name = nil)
  @web_browser.save_page(file_name)
end

#table_source(table_id) ⇒ Object Also known as: table_source_by_id

Content



32
33
34
35
36
37
# File 'lib/rwebspec-webdriver/rspec_helper.rb', line 32

def table_source(table_id)
  table(:id, table_id).innerHTML
  # elem = @web_browser.document.getElementById(table_id)
  # raise "The element '#{table_id}' is not a table or there are multple elements with same id" unless elem.name.uppercase == "TABLE"
  # elem.innerHTML
end