Module: Awetestlib::Regression::UserInput
- Included in:
- Runner
- Defined in:
- lib/awetestlib/regression/user_input.rb
Instance Method Summary collapse
- #clear(browser, element, how, what, value = nil, desc = '') ⇒ Object
- #clear_checkbox(browser, how, what, value = nil, desc = '') ⇒ Object
- #clear_checkbox_by_id(browser, strg, value = nil, desc = '') ⇒ Object
- #clear_checkbox_by_name(browser, strg, value = nil, desc = '') ⇒ Object
- #clear_radio(browser, how, what, value = nil, desc = '') ⇒ Object
-
#clear_textfield(browser, how, which, skip_value_check = false) ⇒ Object
Set skip_value_check = true when string is altered by application and/or this method will be followed by validate_text.
-
#click(browser, element, how, what, desc = '') ⇒ Object
:category: A_rdoc_test Click a specific DOM element by one of its attributes and that attribute’s value.
-
#click_button_by_class(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_button_by_id(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_button_by_index(browser, index, desc = '') ⇒ Object
:category: User Input.
-
#click_button_by_name(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_button_by_text(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_button_by_title(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_button_by_value(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_button_by_xpath_and_id(browser, strg, desc = '') ⇒ Object
(also: #click_button_by_xpath)
:category: User Input.
-
#click_button_no_wait_by_class(browser, strg, desc = '') ⇒ Object
(also: #click_button_by_class_no_wait)
:category: User Input.
-
#click_button_no_wait_by_id(browser, strg, desc = '') ⇒ Object
(also: #click_button_by_id_no_wait)
:category: User Input.
-
#click_button_no_wait_by_name(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_button_no_wait_by_text(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_button_no_wait_by_value(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_file_field_by_id(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_img_by_alt(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_img_by_src(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_img_by_src_and_index(browser, strg, index, desc = '') ⇒ Object
:category: User Input.
-
#click_img_by_title(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_img_by_xpath_and_name(browser, strg, desc = '') ⇒ Object
(also: #click_img_by_xpath, #click_image_by_xpath, #click_image_by_xpath_and_name)
:category: User Input.
-
#click_img_no_wait_by_alt(browser, strg, desc = '') ⇒ Object
(also: #click_img_by_alt_no_wait)
:category: User Input.
-
#click_link_by_class(browser, strg, desc = '') ⇒ Object
(also: #click_class)
:category: User Input.
-
#click_link_by_href(browser, strg, desc = '') ⇒ Object
(also: #click_href)
:category: User Input.
-
#click_link_by_id(browser, strg, desc = '') ⇒ Object
(also: #click_id)
:category: A_rdoc_test Click a link identified by the value in its id attribute.
-
#click_link_by_index(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_link_by_name(browser, strg, desc = '') ⇒ Object
(also: #click_name)
:category: User Input.
-
#click_link_by_name_no_wait(browser, strg, desc = '') ⇒ Object
(also: #click_no_wait_name, #click_name_no_wait)
:category: User Input.
-
#click_link_by_text(browser, strg, desc = '') ⇒ Object
(also: #click_link, #click_text, #click_js_button)
:category: A_rdoc_test Click a link identified by the value in its text attribute.
-
#click_link_by_text_no_wait(browser, strg, desc = '') ⇒ Object
(also: #click_no_wait_text, #click_text_no_wait)
:category: User Input.
-
#click_link_by_title(browser, strg, desc = '') ⇒ Object
(also: #click_title)
:category: User Input.
-
#click_link_by_value(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_link_by_xpath_and_id(browser, strg, desc = '') ⇒ Object
(also: #click_link_by_xpath)
:category: User Input.
-
#click_link_no_wait_by_href(browser, strg, desc = '') ⇒ Object
(also: #click_href_no_wait)
:category: User Input.
-
#click_link_no_wait_by_id(browser, strg, desc = '') ⇒ Object
(also: #click_no_wait_id, #click_no_wait_by_id, #click_id_no_wait, #click_no_wait_link_by_id)
:category: User Input.
-
#click_no_wait(browser, element, how, what, desc = '') ⇒ Object
:category: A_rdoc_test Click a specific DOM element by one of its attributes and that attribute’s value and do not wait for the browser to finish reloading.
- #click_popup_button(title, button, waitTime = 9, user_input = nil) ⇒ Object
-
#click_span_by_text(browser, strg, desc = '') ⇒ Object
:category: User Input.
-
#click_span_with_text(browser, trgt, desc = '') ⇒ Object
TODO no logging yet.
-
#click_table_row_with_text_by_id(browser, ptrn, strg, column = nil) ⇒ Object
:category: User Input.
-
#click_table_row_with_text_by_index(browser, idx, strg, column = nil) ⇒ Object
:category: User Input.
-
#click_title_no_wait(browser, strg, desc = '') ⇒ Object
:category: User Input.
- #double_click_table_row_with_text_by_id(browser, ptrn, strg, column = nil) ⇒ Object
- #double_click_table_row_with_text_by_index(browser, idx, strg, column = nil) ⇒ Object
-
#fire_event(browser, element, how, what, event, desc = '') ⇒ Object
:category: A_rdoc_test Allows a generic way to fire browser or javascript events on page elements.
- #fire_event_on_image_by_src(browser, strg, event = 'onclick', desc = '') ⇒ Object (also: #fire_event_src, #fire_event_image_by_src)
- #fire_event_on_link_by_id(browser, strg, event = 'onclick', desc = '') ⇒ Object (also: #fire_event_id, #fire_event_by_id)
- #fire_event_on_link_by_text(browser, strg, event = 'onclick', desc = '') ⇒ Object (also: #fire_event_text, #fire_event_by_text)
- #select_option(browser, how, what, which, value, desc = '') ⇒ Object
- #select_option_by_class_and_option_text(browser, strg, option, desc = '') ⇒ Object
- #select_option_by_id_and_index(browser, strg, idx, desc = '') ⇒ Object
-
#select_option_by_id_and_option_text(browser, strg, option, nofail = false, desc = '') ⇒ Object
(also: #select_option_by_id, #select_option_by_id_and_text)
:category: A_rdoc_test Select an option from a specific drop down list.
- #select_option_by_id_and_option_value(browser, strg, option, desc = '') ⇒ Object
- #select_option_by_name_and_index(browser, strg, idx) ⇒ Object
- #select_option_by_name_and_option_text(browser, strg, option, desc = '') ⇒ Object (also: #select_option_by_name)
- #select_option_by_name_and_option_value(browser, strg, option, desc = '') ⇒ Object
- #select_option_by_title_and_option_text(browser, strg, option, desc = '') ⇒ Object
- #select_option_by_xpath_and_index(browser, strg, idx) ⇒ Object
- #select_option_from_list(list, what, what_strg, desc = '') ⇒ Object
- #set(browser, element, how, what, value = nil, desc = '') ⇒ Object
- #set_checkbox(browser, how, what, value, desc = '') ⇒ Object
- #set_checkbox_by_class(browser, strg, value = nil, desc = '') ⇒ Object
- #set_checkbox_by_id(browser, strg, value = nil, desc = '') ⇒ Object
- #set_checkbox_by_name(browser, strg, value = nil, desc = '') ⇒ Object
- #set_checkbox_by_title(browser, strg, value = nil, desc = '') ⇒ Object
- #set_checkbox_by_value(browser, strg, desc = '') ⇒ Object
- #set_file_field(browser, how, what, filespec, desc = '') ⇒ Object
- #set_file_field_by_id(browser, strg, path, desc = '') ⇒ Object
- #set_file_field_by_name(browser, strg, path, desc = '') ⇒ Object
- #set_radio(browser, how, what, value = nil, desc = '') ⇒ Object
- #set_radio_by_class(browser, strg, value = nil, desc = '') ⇒ Object
- #set_radio_by_id(browser, strg, value = nil, desc = '') ⇒ Object
- #set_radio_by_index(browser, index, desc = '') ⇒ Object
- #set_radio_by_name(browser, strg, value = nil, desc = '') ⇒ Object
- #set_radio_by_name_and_index(browser, name, index, desc = '') ⇒ Object
- #set_radio_by_name_and_text(browser, name, text, desc = '') ⇒ Object
- #set_radio_by_name_and_value(browser, strg, value, desc = '') ⇒ Object
- #set_radio_by_title(browser, strg, value = nil, desc = '') ⇒ Object
- #set_radio_by_value(browser, strg, desc = '') ⇒ Object
- #set_radio_by_value_and_index(browser, value, index, desc = '') ⇒ Object
- #set_radio_no_wait_by_index(browser, index, desc = '') ⇒ Object
- #set_radio_two_attributes(browser, how1, what1, how2, what2, desc = '') ⇒ Object
-
#set_text_field(browser, how, what, value, desc = '', skip_value_check = false) ⇒ Object
(also: #set_textfield)
:category: A_rdoc_test Enter a string into a text field element identified by an attribute type and a value.
-
#set_text_field_and_validate(browser, how, what, value, desc = '', valid_value = nil) ⇒ Object
:category: A_rdoc_test Enter a string into a text field element identified by an attribute type and a value.
- #set_textfield_by_class(browser, strg, value, desc = '', skip_value_check = false) ⇒ Object
-
#set_textfield_by_id(browser, id, value, desc = '', skip_value_check = false) ⇒ Object
:category: A_rdoc_test Enter a string into a text field element identified by the value in its id attribute.
- #set_textfield_by_name(browser, name, value, desc = '', skip_value_check = false) ⇒ Object
- #set_textfield_by_title(browser, title, value, desc = '', skip_value_check = false) ⇒ Object
Instance Method Details
#clear(browser, element, how, what, value = nil, desc = '') ⇒ Object
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 |
# File 'lib/awetestlib/regression/user_input.rb', line 920 def clear(browser, element, how, what, value = nil, desc = '') msg = "Clear #{element} #{how}=>'#{what}' " msg << ", value=>#{value} " if value msg << " '#{desc}' " if desc.length > 0 case element when :radio browser.radio(how, what, value).clear when :checkbox browser.checkbox(how, what, value).clear when :text_field browser.text_field(how, what).set('') else failed_to_log("#{__method__}: #{element} not supported") end if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("#{msg} '#{$!}'") end |
#clear_checkbox(browser, how, what, value = nil, desc = '') ⇒ Object
942 943 944 |
# File 'lib/awetestlib/regression/user_input.rb', line 942 def clear_checkbox(browser, how, what, value = nil, desc = '') clear(browser, :checkbox, how, what, value, desc) end |
#clear_checkbox_by_id(browser, strg, value = nil, desc = '') ⇒ Object
950 951 952 |
# File 'lib/awetestlib/regression/user_input.rb', line 950 def clear_checkbox_by_id(browser, strg, value = nil, desc = '') clear(browser, :checkbox, :id, strg, value, desc) end |
#clear_checkbox_by_name(browser, strg, value = nil, desc = '') ⇒ Object
946 947 948 |
# File 'lib/awetestlib/regression/user_input.rb', line 946 def clear_checkbox_by_name(browser, strg, value = nil, desc = '') clear(browser, :checkbox, :name, strg, value, desc) end |
#clear_radio(browser, how, what, value = nil, desc = '') ⇒ Object
954 955 956 |
# File 'lib/awetestlib/regression/user_input.rb', line 954 def clear_radio(browser, how, what, value = nil, desc = '') clear(browser, :radio, how, what, value, desc) end |
#clear_textfield(browser, how, which, skip_value_check = false) ⇒ Object
Set skip_value_check = true when string is altered by application and/or this method will be followed by validate_text
960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 |
# File 'lib/awetestlib/regression/user_input.rb', line 960 def clear_textfield(browser, how, which, skip_value_check = false) if browser.text_field(how, which).exists? tf = browser.text_field(how, which) if validate(browser, @myName, __LINE__) tf.clear if validate(browser, @myName, __LINE__) if tf.value == '' passed_to_log("Textfield #{how}='#{which}' cleared.") true elsif skip_value_check passed_to_log("Textfield #{how}='#{which}' cleared. (skip value check)") true else failed_to_log("Textfield #{how}='#{which}' not cleared: Found:'#{tf.value}'. (#{__LINE__})") end end end else failed_to_log("Textfield id='#{id}' to clear. (#{__LINE__})") end rescue failed_to_log("Textfield id='#{id}' could not be cleared: '#{$!}'. (#{__LINE__})") end |
#click(browser, element, how, what, desc = '') ⇒ Object
:category: A_rdoc_test Click a specific DOM element by one of its attributes and that attribute’s value.
- Parameters
-
browser - a reference to the browser window or container element to be tested
element - the kind of element to click. Must be one of the elements recognized by Watir. Some common values are :link, :button, :image, :div, :span.
how - the element attribute used to identify the specific element. Valid values depend on the kind of element. Common values: :text, :id, :title, :name, :class, :href (:link only)
what - a string or a regular expression to be found in the how attribute that uniquely identifies the element.
desc - a string containing a message or description intended to appear in the log and/or report output
Example
# html for a link element: # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a> click(browser, :link, :text, 'Pickaxe')
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/awetestlib/regression/user_input.rb', line 31 def click(browser, element, how, what, desc = '') #debug_to_log("#{__method__}: #{element}, #{how}, #{what}") msg = "Click #{element} :#{how}=>'#{what}'" msg << ", '#{desc}'" if desc.length > 0 msg1 = "#{element}(#{how}, '#{what}')" begin case element when :link browser.link(how, what).click when :button browser.(how, what).click when :image browser.image(how, what).click when :radio case how when :index set_radio_by_index(browser, what, desc) else browser.radio(how, what).set end when :span browser.span(how, what).click when :div browser.div(how, what).click when :cell browser.cell(how, what).click else browser.element(how, what).click end end if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("Unable to #{msg}. '#{$!}'") end |
#click_button_by_class(browser, strg, desc = '') ⇒ Object
:category: User Input
180 181 182 |
# File 'lib/awetestlib/regression/user_input.rb', line 180 def (browser, strg, desc = '') click(browser, :button, :class, strg, desc) end |
#click_button_by_id(browser, strg, desc = '') ⇒ Object
:category: User Input
143 144 145 |
# File 'lib/awetestlib/regression/user_input.rb', line 143 def (browser, strg, desc = '') click(browser, :button, :id, strg, desc) end |
#click_button_by_index(browser, index, desc = '') ⇒ Object
:category: User Input
165 166 167 |
# File 'lib/awetestlib/regression/user_input.rb', line 165 def (browser, index, desc = '') click(browser, :button, :index, index, desc) end |
#click_button_by_name(browser, strg, desc = '') ⇒ Object
:category: User Input
170 171 172 |
# File 'lib/awetestlib/regression/user_input.rb', line 170 def (browser, strg, desc = '') click(browser, :button, :name, strg, desc) end |
#click_button_by_text(browser, strg, desc = '') ⇒ Object
:category: User Input
175 176 177 |
# File 'lib/awetestlib/regression/user_input.rb', line 175 def (browser, strg, desc = '') click(browser, :button, :text, strg, desc) end |
#click_button_by_title(browser, strg, desc = '') ⇒ Object
:category: User Input
207 208 209 |
# File 'lib/awetestlib/regression/user_input.rb', line 207 def (browser, strg, desc = '') click(browser, :button, :title, strg, desc) end |
#click_button_by_value(browser, strg, desc = '') ⇒ Object
:category: User Input
202 203 204 |
# File 'lib/awetestlib/regression/user_input.rb', line 202 def (browser, strg, desc = '') click(browser, :button, :value, strg, desc) end |
#click_button_by_xpath_and_id(browser, strg, desc = '') ⇒ Object Also known as:
:category: User Input
212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/awetestlib/regression/user_input.rb', line 212 def (browser, strg, desc = '') msg = "Click button by xpath and id '#{strg}' #{desc}" if browser.(:xpath, "//a[@id = '#{strg}']").click passed_to_log(msg) true else failed_to_log(msg) end rescue failed_to_log("Unable to click button by xpath and id '#{strg}' #{desc} '#{$!}' (#{__LINE__})") end |
#click_button_no_wait_by_class(browser, strg, desc = '') ⇒ Object Also known as:
:category: User Input
196 197 198 |
# File 'lib/awetestlib/regression/user_input.rb', line 196 def (browser, strg, desc = '') click_no_wait(browser, :button, :class, strg, desc) end |
#click_button_no_wait_by_id(browser, strg, desc = '') ⇒ Object Also known as:
:category: User Input
185 186 187 |
# File 'lib/awetestlib/regression/user_input.rb', line 185 def (browser, strg, desc = '') click_no_wait(browser, :button, :id, strg, desc) end |
#click_button_no_wait_by_name(browser, strg, desc = '') ⇒ Object
:category: User Input
191 192 193 |
# File 'lib/awetestlib/regression/user_input.rb', line 191 def (browser, strg, desc = '') click_no_wait(browser, :button, :name, strg, desc) end |
#click_button_no_wait_by_text(browser, strg, desc = '') ⇒ Object
:category: User Input
384 385 386 |
# File 'lib/awetestlib/regression/user_input.rb', line 384 def (browser, strg, desc = '') click_no_wait(browser, :button, :text, strg, desc) end |
#click_button_no_wait_by_value(browser, strg, desc = '') ⇒ Object
:category: User Input
389 390 391 |
# File 'lib/awetestlib/regression/user_input.rb', line 389 def (browser, strg, desc = '') click_no_wait(browser, :button, :value, strg, desc) end |
#click_file_field_by_id(browser, strg, desc = '') ⇒ Object
:category: User Input
286 287 288 |
# File 'lib/awetestlib/regression/user_input.rb', line 286 def click_file_field_by_id(browser, strg, desc = '') click(browser, :file_field, :id, strg, desc) end |
#click_img_by_alt(browser, strg, desc = '') ⇒ Object
:category: User Input
291 292 293 |
# File 'lib/awetestlib/regression/user_input.rb', line 291 def click_img_by_alt(browser, strg, desc = '') click(browser, :image, :alt, strg, desc) end |
#click_img_by_src(browser, strg, desc = '') ⇒ Object
:category: User Input
324 325 326 |
# File 'lib/awetestlib/regression/user_input.rb', line 324 def click_img_by_src(browser, strg, desc = '') click(browser, :image, :src, strg, desc) end |
#click_img_by_src_and_index(browser, strg, index, desc = '') ⇒ Object
:category: User Input
329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/awetestlib/regression/user_input.rb', line 329 def click_img_by_src_and_index(browser, strg, index, desc = '') msg = "Click image by src='#{strg}' and index=#{index}" msg << " #{desc}" if desc.length > 0 browser.image(:src => strg, :index => index).click if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("Unable to #{msg} '#{$!}'") end |
#click_img_by_title(browser, strg, desc = '') ⇒ Object
:category: User Input
296 297 298 |
# File 'lib/awetestlib/regression/user_input.rb', line 296 def click_img_by_title(browser, strg, desc = '') click(browser, :image, :title, strg, desc) end |
#click_img_by_xpath_and_name(browser, strg, desc = '') ⇒ Object Also known as: click_img_by_xpath, click_image_by_xpath, click_image_by_xpath_and_name
:category: User Input
301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/awetestlib/regression/user_input.rb', line 301 def click_img_by_xpath_and_name(browser, strg, desc = '') msg = "Click image by xpath where name='#{strg}' #{desc}" if browser.link(:xpath, "//input[@name = '#{strg}']").click passed_to_log(msg) true else failed_to_log(msg) end rescue failed_to_log("Unable to click image by xpath where name='#{strg}' #{desc} '#{$!}'") end |
#click_img_no_wait_by_alt(browser, strg, desc = '') ⇒ Object Also known as: click_img_by_alt_no_wait
:category: User Input
318 319 320 |
# File 'lib/awetestlib/regression/user_input.rb', line 318 def click_img_no_wait_by_alt(browser, strg, desc = '') click_no_wait(browser, :image, :alt, strg, desc) end |
#click_link_by_class(browser, strg, desc = '') ⇒ Object Also known as: click_class
:category: User Input
377 378 379 |
# File 'lib/awetestlib/regression/user_input.rb', line 377 def click_link_by_class(browser, strg, desc = '') click(browser, :link, :class, strg, desc) end |
#click_link_by_href(browser, strg, desc = '') ⇒ Object Also known as: click_href
:category: User Input
153 154 155 |
# File 'lib/awetestlib/regression/user_input.rb', line 153 def click_link_by_href(browser, strg, desc = '') click(browser, :link, :href, strg, desc) end |
#click_link_by_id(browser, strg, desc = '') ⇒ Object Also known as: click_id
:category: A_rdoc_test Click a link identified by the value in its id attribute. Calls click()
- Parameters
-
browser - a reference to the browser window to be tested
strg - a string or a regular expression to be found in the id attribute that uniquely identifies the element.
desc - a string containing a message or description intended to appear in the log and/or report output
Example
# html for a link element: # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a> click_link_by_text(browser, 'Pickaxe', 'Open the page for the Pickaxe book')
247 248 249 |
# File 'lib/awetestlib/regression/user_input.rb', line 247 def click_link_by_id(browser, strg, desc = '') click(browser, :link, :id, strg, desc) end |
#click_link_by_index(browser, strg, desc = '') ⇒ Object
:category: User Input
148 149 150 |
# File 'lib/awetestlib/regression/user_input.rb', line 148 def click_link_by_index(browser, strg, desc = '') click(browser, :link, :index, strg, desc) end |
#click_link_by_name(browser, strg, desc = '') ⇒ Object Also known as: click_name
:category: User Input
255 256 257 |
# File 'lib/awetestlib/regression/user_input.rb', line 255 def click_link_by_name(browser, strg, desc = '') click(browser, :link, :name, strg, desc) end |
#click_link_by_name_no_wait(browser, strg, desc = '') ⇒ Object Also known as: click_no_wait_name, click_name_no_wait
:category: User Input
394 395 396 |
# File 'lib/awetestlib/regression/user_input.rb', line 394 def click_link_by_name_no_wait(browser, strg, desc = '') click_no_wait(browser, :link, :name, strg, desc) end |
#click_link_by_text(browser, strg, desc = '') ⇒ Object Also known as: click_link, click_text,
:category: A_rdoc_test Click a link identified by the value in its text attribute. Calls click()
- Parameters
-
browser - a reference to the browser window to be tested
strg - a string or a regular expression to be found in the how attribute that uniquely identifies the element.
desc - a string containing a message or description intended to appear in the log and/or report output
Example
# html for a link element: # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a> click_link_by_text(browser, 'Pickaxe', 'Open the page for the Pickaxe book')
367 368 369 |
# File 'lib/awetestlib/regression/user_input.rb', line 367 def click_link_by_text(browser, strg, desc = '') click(browser, :link, :text, strg, desc) end |
#click_link_by_text_no_wait(browser, strg, desc = '') ⇒ Object Also known as: click_no_wait_text, click_text_no_wait
:category: User Input
402 403 404 |
# File 'lib/awetestlib/regression/user_input.rb', line 402 def click_link_by_text_no_wait(browser, strg, desc = '') click_no_wait(browser, :link, :text, strg, desc) end |
#click_link_by_title(browser, strg, desc = '') ⇒ Object Also known as: click_title
:category: User Input
443 444 445 |
# File 'lib/awetestlib/regression/user_input.rb', line 443 def click_link_by_title(browser, strg, desc = '') click(browser, :link, :title, strg, desc) end |
#click_link_by_value(browser, strg, desc = '') ⇒ Object
:category: User Input
342 343 344 |
# File 'lib/awetestlib/regression/user_input.rb', line 342 def click_link_by_value(browser, strg, desc = '') click(browser, :link, :value, strg, desc) end |
#click_link_by_xpath_and_id(browser, strg, desc = '') ⇒ Object Also known as: click_link_by_xpath
:category: User Input
261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/awetestlib/regression/user_input.rb', line 261 def click_link_by_xpath_and_id(browser, strg, desc = '') msg = "Click link by xpath and id '#{strg}' #{desc}" if browser.link(:xpath, "//a[@id = '#{strg}']").click passed_to_log(msg) true else failed_to_log(msg) end rescue failed_to_log("Unable click on link by xpath and id '#{strg}' #{desc} '#{$!}' (#{__LINE__})") end |
#click_link_no_wait_by_href(browser, strg, desc = '') ⇒ Object Also known as: click_href_no_wait
:category: User Input
159 160 161 |
# File 'lib/awetestlib/regression/user_input.rb', line 159 def click_link_no_wait_by_href(browser, strg, desc = '') click_no_wait(browser, :link, :href, strg, desc) end |
#click_link_no_wait_by_id(browser, strg, desc = '') ⇒ Object Also known as: click_no_wait_id, click_no_wait_by_id, click_id_no_wait, click_no_wait_link_by_id
:category: User Input
276 277 278 |
# File 'lib/awetestlib/regression/user_input.rb', line 276 def click_link_no_wait_by_id(browser, strg, desc = '') click_no_wait(browser, :link, :id, strg, desc) end |
#click_no_wait(browser, element, how, what, desc = '') ⇒ Object
:category: A_rdoc_test Click a specific DOM element by one of its attributes and that attribute’s value and do not wait for the browser to finish reloading. Used when a modal popup or alert is expected. Allows the script to keep running so the popup can be handled.
- Parameters
-
browser - a reference to the browser window to be tested
element - the kind of element to click. Must be one of the elements recognized by Watir. Some common values are :link, :button, :image, :div, :span.
how - the element attribute used to identify the specific element. Valid values depend on the kind of element. Common values: :text, :id, :title, :name, :class, :href (:link only)
what - a string or a regular expression to be found in the how attribute that uniquely identifies the element.
desc - a string containing a message or description intended to appear in the log and/or report output
Example
# html for a link element: # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a> click_no_wait(browser, :link, :text, 'Pickaxe')
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/awetestlib/regression/user_input.rb', line 97 def click_no_wait(browser, element, how, what, desc = '') debug_to_log("#{__method__}: #{element}, #{how}, #{what}") msg = "Click no wait #{element} :#{how}=>'#{what}'" msg << ", '#{desc}'" if desc.length > 0 msg1 = "#{element}(#{how}, '#{what}'" begin case element when :link browser.link(how, what).click_no_wait when :button browser.(how, what).click_no_wait when :image browser.image(how, what).click_no_wait when :radio case how when :index set_radio_no_wait_by_index(browser, what, desc) else browser.radio(how, what).click_no_wait end when :span browser.span(how, what).click_no_wait when :div browser.div(how, what).click_no_wait when :checkbox browser.checkbox(how, what).click_no_wait when :cell browser.cell(how, what).click_no_wait else browser.element(how, what).click_no_wait end rescue => e if not rescue_me(e, __method__, "browser(#{msg1}').click_no_wait", "#{browser.class}") raise e end end if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("Unable to #{msg} '#{$!}'") sleep_for(1) end |
#click_popup_button(title, button, waitTime = 9, user_input = nil) ⇒ Object
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
# File 'lib/awetestlib/regression/user_input.rb', line 541 def (title, , waitTime= 9, user_input=nil) #TODO: is winclicker still viable/available? wc = WinClicker.new if wc.clickWindowsButton(title, , waitTime) passed_to_log("Window '#{title}' button '#{}' found and clicked.") true else failed_to_log("Window '#{title}' button '#{}' not found. (#{__LINE__})") end wc = nil # get a handle if one exists # hwnd = $ie.enabled_popup(waitTime) # if (hwnd) # yes there is a popup # w = WinClicker.new # if ( user_input ) # w.setTextValueForFileNameField( hwnd, "#{user_input}" ) # end # # I put this in to see the text being input it is not necessary to work # sleep 3 # # "OK" or whatever the name on the button is # w.clickWindowsButton_hwnd( hwnd, "#{button}" ) # # # # this is just cleanup # w=nil # end end |
#click_span_by_text(browser, strg, desc = '') ⇒ Object
:category: User Input
410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/awetestlib/regression/user_input.rb', line 410 def click_span_by_text(browser, strg, desc = '') if not desc and not strg.match(/Save|Open|Close|Submit|Cancel/) desc = 'to navigate to selection' end msg = "Click span containing text '#{strg}'." msg << " #{desc}" if desc.length > 0 if validate(browser, @myName, __LINE__) passed_to_log("#{msg}") end rescue failed_to_log("Unable to #{msg}: '#{$!}'") end |
#click_span_with_text(browser, trgt, desc = '') ⇒ Object
TODO no logging yet. slow.# :category: User Input
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
# File 'lib/awetestlib/regression/user_input.rb', line 424 def click_span_with_text(browser, trgt, desc = '') msg = "Find and click span containing text '#{trgt}'." msg << " #{desc}" if desc.length > 0 spans = browser.spans x = 0 spans.each do |span| x += 1 debug_to_log("Span #{x}: #{span.text}") aText = span.text if aText and aText.size > 0 if aText =~ /#{trgt}/ break end end end spans[x].click end |
#click_table_row_with_text_by_id(browser, ptrn, strg, column = nil) ⇒ Object
:category: User Input
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
# File 'lib/awetestlib/regression/user_input.rb', line 454 def click_table_row_with_text_by_id(browser, ptrn, strg, column = nil) msg = "id=#{ptrn} row with text='#{strg}" table = get_table_by_id(browser, /#{ptrn}/) if table index = get_index_of_row_with_text(table, strg, column) if index table[index].click if validate(browser, @myName, __LINE__) passed_to_log("Click #{msg} row index=#{index}.") index end else failed_to_log("Table #{msg} not found to click.") end else failed_to_log("Table id=#{ptrn} not found.") end rescue failed_to_log("Unable to click table #{msg}: '#{$!}' (#{__LINE__}) ") end |
#click_table_row_with_text_by_index(browser, idx, strg, column = nil) ⇒ Object
:category: User Input
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File 'lib/awetestlib/regression/user_input.rb', line 476 def click_table_row_with_text_by_index(browser, idx, strg, column = nil) msg = "index=#{idx} row with text='#{strg}" table = get_table_by_index(browser, idx) if table index = get_index_of_row_with_text(table, strg, column) if index table[index].click if validate(browser, @myName, __LINE__) passed_to_log("Click #{msg} row index=#{index}.") index end else failed_to_log("Table #{msg} not found to click.") end else failed_to_log("Table id=#{ptrn} not found.") end rescue failed_to_log("Unable to click table #{msg}: '#{$!}' (#{__LINE__}) ") end |
#click_title_no_wait(browser, strg, desc = '') ⇒ Object
:category: User Input
449 450 451 |
# File 'lib/awetestlib/regression/user_input.rb', line 449 def click_title_no_wait(browser, strg, desc = '') click_no_wait(browser, :link, :title, strg, desc) end |
#double_click_table_row_with_text_by_id(browser, ptrn, strg, column = nil) ⇒ Object
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/awetestlib/regression/user_input.rb', line 497 def double_click_table_row_with_text_by_id(browser, ptrn, strg, column = nil) msg = "id=#{ptrn} row with text='#{strg}" table = get_table_by_id(browser, /#{ptrn}/) if table index = get_index_of_row_with_text(table, strg, column) if index table[index].fire_event('ondblclick') if validate(browser, @myName, __LINE__) passed_to_log("Double click #{msg} row index=#{index}.") index end else failed_to_log("Table #{msg} not found to double click.") end else failed_to_log("Table id=#{ptrn} not found.") end rescue failed_to_log("Unable to double click table #{msg}: '#{$!}' (#{__LINE__}) ") end |
#double_click_table_row_with_text_by_index(browser, idx, strg, column = nil) ⇒ Object
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/awetestlib/regression/user_input.rb', line 518 def double_click_table_row_with_text_by_index(browser, idx, strg, column = nil) msg = "index=#{idx} row with text='#{strg}" table = get_table_by_index(browser, idx) if table index = get_index_of_row_with_text(table, strg, column) if index row = table[index] table[index].fire_event('ondblclick') row.fire_event('ondblclick') if validate(browser, @myName, __LINE__) passed_to_log("Double click #{msg} row index=#{index}.") index end else failed_to_log("Table #{msg} not found to double click.") end else failed_to_log("Table id=#{ptrn} not found.") end rescue failed_to_log("Unable to double click table #{msg}: '#{$!}' (#{__LINE__}) ") end |
#fire_event(browser, element, how, what, event, desc = '') ⇒ Object
:category: A_rdoc_test Allows a generic way to fire browser or javascript events on page elements. Raises UnknownObjectException if the object is not found or ObjectDisabledException if the object is currently disabled.
- Parameters
-
browser - a reference to the browser window to be tested
element - the kind of element to click. Must be one of the elements recognized by Watir. Some common values are :link, :button, :image, :div, :span.
how - the element attribute used to identify the specific element. Valid values depend on the kind of element. Common values: :text, :id, :title, :name, :class, :href (:link only)
what - a string or a regular expression to be found in the how attribute that uniquely identifies the element.
event - a string indicating the event to be triggered, e.g., ‘onMouseOver’, ‘onClick’, and etc.
desc - a string containing a message or description intended to appear in the log and/or report output
Example
# html for a link element: # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a> fire_event(browser, :link, :text, 'Pickaxe', 'onMouseOver')
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 |
# File 'lib/awetestlib/regression/user_input.rb', line 1200 def fire_event(browser, element, how, what, event, desc = '') msg = "#{element.to_s.titlecase}: #{how}=>'#{what}' event:'#{event}'" msg1 = "#{element.to_s.titlecase}(#{how}, '#{what}')" begin case element when :link browser.link(how, what).fire_event(event) when :button browser.(how, what).fire_event(event) when :image browser.image(how, what).fire_event(event) when :span browser.span(how, what).fire_event(event) when :div browser.div(how, what).fire_event(event) else browser.element(how, what).fire_event(event) end rescue => e if not rescue_me(e, __method__, "browser(#{msg1}).fire_event('#{event}')", "#{browser.class}") raise e end end if validate(browser, @myName, __LINE__) passed_to_log("Fire event: #{msg}. #{desc}") true end rescue failed_to_log("Unable to fire event: #{msg}. '#{$!}' #{desc}") end |
#fire_event_on_image_by_src(browser, strg, event = 'onclick', desc = '') ⇒ Object Also known as: fire_event_src, fire_event_image_by_src
1245 1246 1247 |
# File 'lib/awetestlib/regression/user_input.rb', line 1245 def fire_event_on_image_by_src(browser, strg, event = 'onclick', desc = '') fire_event(browser, :img, :src, strg, event, desc) end |
#fire_event_on_link_by_id(browser, strg, event = 'onclick', desc = '') ⇒ Object Also known as: fire_event_id, fire_event_by_id
1238 1239 1240 |
# File 'lib/awetestlib/regression/user_input.rb', line 1238 def fire_event_on_link_by_id(browser, strg, event = 'onclick', desc = '') fire_event(browser, :link, :id, strg, event, desc) end |
#fire_event_on_link_by_text(browser, strg, event = 'onclick', desc = '') ⇒ Object Also known as: fire_event_text, fire_event_by_text
1231 1232 1233 |
# File 'lib/awetestlib/regression/user_input.rb', line 1231 def fire_event_on_link_by_text(browser, strg, event = 'onclick', desc = '') fire_event(browser, :link, :text, strg, event, desc) end |
#select_option(browser, how, what, which, value, desc = '') ⇒ Object
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
# File 'lib/awetestlib/regression/user_input.rb', line 568 def select_option(browser, how, what, which, value, desc = '') msg = "Select option #{which}='#{value}' from list #{how}=#{what}. #{desc}" list = browser.select_list(how, what) case which when :text list.select(value) when :value list.select_value(value) when :index all = list.getAllContents txt = all[value] list.select(txt) else na = "#{__method__} cannot support select by '#{which}'. (#{msg})" debug_to_log(na, __LINE__, true) raise na end passed_to_log(msg) rescue failed_to_log("#Unable to #{msg}': '#{$!}'") end |
#select_option_by_class_and_option_text(browser, strg, option, desc = '') ⇒ Object
699 700 701 702 703 704 705 706 707 708 709 |
# File 'lib/awetestlib/regression/user_input.rb', line 699 def select_option_by_class_and_option_text(browser, strg, option, desc = '') msg = "Select list class=#{strg} option text='#{option}' selected." msg << " #{desc}" if desc.length > 0 browser.select_list(:class, strg).select(option) if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("#{msg} '#{$!}'") end |
#select_option_by_id_and_index(browser, strg, idx, desc = '') ⇒ Object
762 763 764 765 766 767 768 769 770 771 772 773 774 775 |
# File 'lib/awetestlib/regression/user_input.rb', line 762 def select_option_by_id_and_index(browser, strg, idx, desc = '') msg = "Select list id=#{strg} index='#{idx}' selected." msg << " #{desc}" if desc.length > 0 list = browser.select_list(:id, strg) all = list.getAllContents txt = all[idx] browser.select_list(:id, strg).set(browser.select_list(:id, strg).getAllContents[idx]) if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("#{msg} '#{$!}'") end |
#select_option_by_id_and_option_text(browser, strg, option, nofail = false, desc = '') ⇒ Object Also known as: select_option_by_id, select_option_by_id_and_text
:category: A_rdoc_test Select an option from a specific drop down list. The drop down (select list) is id
- Parameters
-
browser - a reference to the browser window to be tested
how - the element attribute used to identify the specific element. Valid values depend on the kind of element. Common values: :text, :id, :title, :name, :class, :href (:link only)
what - a string or a regular expression to be found in the how attribute that uniquely identifies the element.
desc - a string containing a message or description intended to appear in the log and/or report output
Example
# html for a link element: # <a href="http://pragmaticprogrammer.com/titles/ruby/" id="one" name="book">Pickaxe</a> click_no_wait(browser, :link, :text, 'Pickaxe')
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 |
# File 'lib/awetestlib/regression/user_input.rb', line 642 def select_option_by_id_and_option_text(browser, strg, option, nofail=false, desc = '') msg = "Select list id=#{strg} option text='#{option}' selected." msg << " #{desc}" if desc.length > 0 list = browser.select_list(:id, strg) list.select(option) # browser.select_list(:id, strg).select(option) #(browser.select_list(:id, strg).getAllContents[option]) if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue if !nofail failed_to_log("#{msg} '#{$!}'") end end |
#select_option_by_id_and_option_value(browser, strg, option, desc = '') ⇒ Object
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 |
# File 'lib/awetestlib/regression/user_input.rb', line 736 def select_option_by_id_and_option_value(browser, strg, option, desc = '') msg = "Select list name=#{strg} option value='#{option}' selected." msg << " #{desc}" if desc.length > 0 begin list = browser.select_list(:id, strg) rescue => e if not rescue_me(e, __method__, "#{__LINE__}: select_list(:text,'#{strg}')", "#{browser.class}") raise e end end sleep(0.5) unless @targetBrowser.abbrev == 'IE' begin list.select_value(option) rescue => e if not rescue_me(e, __method__, "#{__LINE__}: select_list#select_value('#{option}')", "#{browser.class}") raise e end end if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("#{msg} '#{$!}'") end |
#select_option_by_name_and_index(browser, strg, idx) ⇒ Object
777 778 779 780 781 782 783 784 785 786 787 788 |
# File 'lib/awetestlib/regression/user_input.rb', line 777 def select_option_by_name_and_index(browser, strg, idx) # TODO add check that both list and option exist msg = "Select list name=#{strg} index='#{idx}' selected." msg << " #{desc}" if desc.length > 0 browser.select_list(:name, strg).set(browser.select_list(:name, strg).getAllContents[idx]) if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("#{msg} '#{$!}'") end |
#select_option_by_name_and_option_text(browser, strg, option, desc = '') ⇒ Object Also known as: select_option_by_name
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 |
# File 'lib/awetestlib/regression/user_input.rb', line 661 def select_option_by_name_and_option_text(browser, strg, option, desc = '') msg = "Select list name=#{strg} option text='#{option}' selected." msg << " #{desc}" if desc.length > 0 begin list = browser.select_list(:name, strg) rescue => e if not rescue_me(e, __method__, "#{__LINE__}: select_list(:name,'#{strg}')", "#{browser.class}") raise e end end begin list.select(option) rescue => e if not rescue_me(e, __method__, "#{__LINE__}: select_list#select('#{option}')", "#{browser.class}") raise e end end if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("#{msg} '#{$!}'") end |
#select_option_by_name_and_option_value(browser, strg, option, desc = '') ⇒ Object
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 |
# File 'lib/awetestlib/regression/user_input.rb', line 711 def select_option_by_name_and_option_value(browser, strg, option, desc = '') msg = "Select list name=#{strg} option value='#{option}' selected." msg << " #{desc}" if desc.length > 0 begin list = browser.select_list(:name, strg) rescue => e if not rescue_me(e, __method__, "#{__LINE__}: select_list(:name,'#{strg}')", "#{browser.class}") raise e end end begin list.select_value(option) rescue => e if not rescue_me(e, __method__, "#{__LINE__}: select_list#select_value('#{option}')", "#{browser.class}") raise e end end if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("#{msg} '#{$!}'") end |
#select_option_by_title_and_option_text(browser, strg, option, desc = '') ⇒ Object
688 689 690 691 692 693 694 695 696 697 |
# File 'lib/awetestlib/regression/user_input.rb', line 688 def select_option_by_title_and_option_text(browser, strg, option, desc = '') msg = "Select list name=#{strg} option text='#{option}' selected." msg << " #{desc}" if desc.length > 0 browser.select_list(:title, strg).select(option) if validate(browser, @myName, __LINE__) passed_to_log(msg) end rescue failed_to_log("#{msg} '#{$!}'") end |
#select_option_by_xpath_and_index(browser, strg, idx) ⇒ Object
790 791 792 793 794 795 796 797 798 799 800 |
# File 'lib/awetestlib/regression/user_input.rb', line 790 def select_option_by_xpath_and_index(browser, strg, idx) msg = "Select list xpath=#{strg} index='#{idx}' selected." msg << " #{desc}" if desc.length > 0 browser.select_list(:xpath, strg).set(browser.select_list(:xpath, strg).getAllContents[idx]) if validate(browser, nil, __LINE__) passed_to_log(msg) true end rescue failed_to_log("#{msg} '#{$!}'") end |
#select_option_from_list(list, what, what_strg, desc = '') ⇒ Object
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
# File 'lib/awetestlib/regression/user_input.rb', line 590 def select_option_from_list(list, what, what_strg, desc = '') ok = true msg = "#{__method__.to_s.titleize} " if list msg << "list id=#{list.id}: " case what when :text list.select(what_strg) #TODO: regex? when :value list.select_value(what_strg) #TODO: regex? when :index list.select(list.getAllContents[what_strg.to_i]) else msg << "select by #{what} not supported. #{desc} (#{__LINE__})" failed_to_log(msg) ok = false end if ok msg << "#{what}='#{what_strg}' selected. #{desc}" passed_to_log(msg) true end else failed_to_log("#{__method__.to_s.titleize} list not found. #{desc} (#{__LINE__})") end rescue failed_to_log("#{__method__.to_s.titleize}: #{what}='#{what_strg}' could not be selected: '#{$!}'. #{desc} (#{__LINE__})") end |
#set(browser, element, how, what, value = nil, desc = '') ⇒ Object
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 |
# File 'lib/awetestlib/regression/user_input.rb', line 802 def set(browser, element, how, what, value = nil, desc = '') msg = "Set #{element} #{how}=>'#{what}' " msg << ", :value=>#{value} " if value msg << " '#{desc}' " if desc.length > 0 case element when :radio browser.radio(how, what, value).set when :checkbox browser.checkbox(how, what, value).set else failed_to_log("#{__method__}: #{element} not supported") end if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("#{msg} '#{$!}'") end |
#set_checkbox(browser, how, what, value, desc = '') ⇒ Object
822 823 824 |
# File 'lib/awetestlib/regression/user_input.rb', line 822 def set_checkbox(browser, how, what, value, desc = '') set(browser, :checkbox, how, what, value, desc) end |
#set_checkbox_by_class(browser, strg, value = nil, desc = '') ⇒ Object
826 827 828 |
# File 'lib/awetestlib/regression/user_input.rb', line 826 def set_checkbox_by_class(browser, strg, value = nil, desc = '') set(browser, :checkbox, :class, strg, value, desc) end |
#set_checkbox_by_id(browser, strg, value = nil, desc = '') ⇒ Object
830 831 832 |
# File 'lib/awetestlib/regression/user_input.rb', line 830 def set_checkbox_by_id(browser, strg, value = nil, desc = '') set(browser, :checkbox, :id, strg, value, desc) end |
#set_checkbox_by_name(browser, strg, value = nil, desc = '') ⇒ Object
834 835 836 |
# File 'lib/awetestlib/regression/user_input.rb', line 834 def set_checkbox_by_name(browser, strg, value = nil, desc = '') set(browser, :checkbox, :name, strg, value, desc) end |
#set_checkbox_by_title(browser, strg, value = nil, desc = '') ⇒ Object
838 839 840 |
# File 'lib/awetestlib/regression/user_input.rb', line 838 def set_checkbox_by_title(browser, strg, value = nil, desc = '') set(browser, :checkbox, :title, strg, value, desc) end |
#set_checkbox_by_value(browser, strg, desc = '') ⇒ Object
842 843 844 |
# File 'lib/awetestlib/regression/user_input.rb', line 842 def set_checkbox_by_value(browser, strg, desc = '') set(browser, :checkbox, :value, strg, nil, desc) end |
#set_file_field(browser, how, what, filespec, desc = '') ⇒ Object
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 |
# File 'lib/awetestlib/regression/user_input.rb', line 984 def set_file_field(browser, how, what, filespec, desc = '') msg = "Set file field #{how}=>#{what} to '#{filespec}." msg << " #{desc}" if desc.length > 0 ff = browser.file_field(how, what) if ff ff.set filespec sleep_for(8) if validate(browser, @myName, __LINE__) passed_to_log(msg) true end else failed_to_log("#{msg} File field not found.") end rescue failed_to_log("Unable to #{msg} '#{$!}'") end |
#set_file_field_by_id(browser, strg, path, desc = '') ⇒ Object
1006 1007 1008 |
# File 'lib/awetestlib/regression/user_input.rb', line 1006 def set_file_field_by_id(browser, strg, path, desc = '') set_file_field(browser, :id, strg, path, desc) end |
#set_file_field_by_name(browser, strg, path, desc = '') ⇒ Object
1002 1003 1004 |
# File 'lib/awetestlib/regression/user_input.rb', line 1002 def set_file_field_by_name(browser, strg, path, desc = '') set_file_field(browser, :name, strg, path, desc) end |
#set_radio(browser, how, what, value = nil, desc = '') ⇒ Object
846 847 848 |
# File 'lib/awetestlib/regression/user_input.rb', line 846 def set_radio(browser, how, what, value = nil, desc = '') set(browser, :radio, how, what, value, desc) end |
#set_radio_by_class(browser, strg, value = nil, desc = '') ⇒ Object
862 863 864 |
# File 'lib/awetestlib/regression/user_input.rb', line 862 def set_radio_by_class(browser, strg, value = nil, desc = '') set(browser, :radio, :class, strg, value, desc) end |
#set_radio_by_id(browser, strg, value = nil, desc = '') ⇒ Object
866 867 868 |
# File 'lib/awetestlib/regression/user_input.rb', line 866 def set_radio_by_id(browser, strg, value = nil, desc = '') set(browser, :radio, :id, strg, value, desc) end |
#set_radio_by_index(browser, index, desc = '') ⇒ Object
870 871 872 |
# File 'lib/awetestlib/regression/user_input.rb', line 870 def set_radio_by_index(browser, index, desc = '') set(browser, :radio, :index, index, value, desc) end |
#set_radio_by_name(browser, strg, value = nil, desc = '') ⇒ Object
874 875 876 |
# File 'lib/awetestlib/regression/user_input.rb', line 874 def set_radio_by_name(browser, strg, value = nil, desc = '') set(browser, :radio, :name, strg, value, desc) end |
#set_radio_by_name_and_index(browser, name, index, desc = '') ⇒ Object
904 905 906 |
# File 'lib/awetestlib/regression/user_input.rb', line 904 def set_radio_by_name_and_index(browser, name, index, desc = '') set_radio_two_attributes(browser, :name, name, :index, index, desc) end |
#set_radio_by_name_and_text(browser, name, text, desc = '') ⇒ Object
908 909 910 |
# File 'lib/awetestlib/regression/user_input.rb', line 908 def set_radio_by_name_and_text(browser, name, text, desc = '') set_radio_two_attributes(browser, :name, name, :text, text, desc) end |
#set_radio_by_name_and_value(browser, strg, value, desc = '') ⇒ Object
916 917 918 |
# File 'lib/awetestlib/regression/user_input.rb', line 916 def set_radio_by_name_and_value(browser, strg, value, desc = '') set_radio(browser, :name, strg, value, desc) end |
#set_radio_by_title(browser, strg, value = nil, desc = '') ⇒ Object
878 879 880 |
# File 'lib/awetestlib/regression/user_input.rb', line 878 def set_radio_by_title(browser, strg, value = nil, desc = '') set(browser, :radio, :title, strg, value, desc) end |
#set_radio_by_value(browser, strg, desc = '') ⇒ Object
882 883 884 |
# File 'lib/awetestlib/regression/user_input.rb', line 882 def set_radio_by_value(browser, strg, desc = '') set(browser, :radio, :value, strg, nil, desc) end |
#set_radio_by_value_and_index(browser, value, index, desc = '') ⇒ Object
912 913 914 |
# File 'lib/awetestlib/regression/user_input.rb', line 912 def set_radio_by_value_and_index(browser, value, index, desc = '') set_radio_two_attributes(browser, :value, value, :index, index, desc) end |
#set_radio_no_wait_by_index(browser, index, desc = '') ⇒ Object
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 |
# File 'lib/awetestlib/regression/user_input.rb', line 886 def set_radio_no_wait_by_index(browser, index, desc = '') #TODO: Not supported by Watir 1.8.x msg = "Radio :index=#{index} " radios = browser.radios debug_to_log("\n#{radios}") radio = radios[index] debug_to_log("\n#{radio}") radio.click_no_wait if validate(browser) msg << 'set ' + desc passed_to_log(msg) true end rescue msg << 'not found ' + desc failed_to_log("#{msg} (#{__LINE__})") end |
#set_radio_two_attributes(browser, how1, what1, how2, what2, desc = '') ⇒ Object
850 851 852 853 854 855 856 857 858 859 860 |
# File 'lib/awetestlib/regression/user_input.rb', line 850 def set_radio_two_attributes(browser, how1, what1, how2, what2, desc = '') msg = "Set radio #{how1}='#{what1}', #{how2}= #{what2}" msg << " '#{desc}' " if desc.length > 0 browser.radio(how1 => what1, how2 => what2).set if validate(browser, @myName, __LINE__) passed_to_log(msg) true end rescue failed_to_log("#{msg} '#{$!}'") end |
#set_text_field(browser, how, what, value, desc = '', skip_value_check = false) ⇒ Object Also known as: set_textfield
:category: A_rdoc_test Enter a string into a text field element identified by an attribute type and a value. After the entry the value in the text field is validated against the input value unless the skip_value_check parameter is set to true
- Parameters
-
browser - a reference to the browser window to be tested
how - the element attribute used to identify the specific element. Valid values depend on the kind of element. Common values: :text, :id, :title, :name, :class, :href (:link only)
what - a string or a regular expression to be found in the how attribute that uniquely identifies the element.
value - a string to be entered in the text field
desc - a string containing a message or description intended to appear in the log and/or report output
skip_value_check (Optional, default is false). Set to true to prevent the built-in verification that the text field actually contains the value entered. Useful when application reformats or otherwise edits the input string.
Example
set_text_field(browser, :name, /thisTextfield/, 'The text to enter')
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
# File 'lib/awetestlib/regression/user_input.rb', line 1039 def set_text_field(browser, how, what, value, desc = '', skip_value_check = false) #TODO: fix this to handle Safari password field msg = "Set textfield #{how}='#{what}' to '#{value}'" msg << " #{desc}" if desc.length > 0 msg << " (Skip value check)" if skip_value_check if browser.text_field(how, what).exists? tf = browser.text_field(how, what) debug_to_log("#{tf.inspect}") if validate(browser, @myName, __LINE__) tf.set(value) if validate(browser, @myName, __LINE__) if tf.value == value passed_to_log(msg) true elsif skip_value_check passed_to_log(msg) true else failed_to_log("#{msg}: Found:'#{tf.value}'.") end end end else failed_to_log("Textfield #{how}='#{what}' not found to set to '#{value}''") end rescue failed_to_log("Unable to '#{msg}': '#{$!}'") end |
#set_text_field_and_validate(browser, how, what, value, desc = '', valid_value = nil) ⇒ Object
:category: A_rdoc_test Enter a string into a text field element identified by an attribute type and a value. After the entry the value in the text field is validated against the valid_value. Use when the application reformats or performs edits on the input value.
- Parameters
-
browser - a reference to the browser window to be tested
how - the element attribute used to identify the specific element. Valid values depend on the kind of element. Common values: :text, :id, :title, :name, :class, :href (:link only)
what - a string or a regular expression to be found in the how attribute that uniquely identifies the element.
value - a string to be entered in the text field
desc - a string containing a message or description intended to appear in the log and/or report output
valid_value (Optional, default is nil). Set to the expected value
Example
set_text_field_and_validate(browser, :id, /AmountTendered/, '7500', 'Dollar formatting', '$7,500.00')
1162 1163 1164 1165 1166 1167 1168 1169 1170 |
# File 'lib/awetestlib/regression/user_input.rb', line 1162 def set_text_field_and_validate(browser, how, what, value, desc = '', valid_value = nil) #NOTE: use when value and valid_value differ as with dollar reformatting if set_text_field(browser, how, what, value, desc, true) expected = valid_value ? valid_value : value validate_textfield_value(browser, how, what, expected) end rescue failed_to_log("Unable to '#{msg}': '#{$!}'") end |
#set_textfield_by_class(browser, strg, value, desc = '', skip_value_check = false) ⇒ Object
1131 1132 1133 |
# File 'lib/awetestlib/regression/user_input.rb', line 1131 def set_textfield_by_class(browser, strg, value, desc = '', skip_value_check = false) set_text_field(browser, :class, strg, value, desc, skip_value_check) end |
#set_textfield_by_id(browser, id, value, desc = '', skip_value_check = false) ⇒ Object
:category: A_rdoc_test Enter a string into a text field element identified by the value in its id attribute.
- Parameters
-
browser - a reference to the browser window to be tested
id - a string or a regular expression to be found in the id attribute that uniquely identifies the element.
value - a string to be entered in the text field
desc - a string containing a message or description intended to appear in the log and/or report output
skip_value_check (Optional, default is false). Set to true to prevent the built-in verification that the text field actually contains the value entered. Useful when application reformats or otherwise edits the input string.
Example
set_text_field_by_id(browser, /thisTextfield/, 'The text to enter')
1123 1124 1125 |
# File 'lib/awetestlib/regression/user_input.rb', line 1123 def set_textfield_by_id(browser, id, value, desc = '', skip_value_check = false) set_text_field(browser, :id, id, value, desc, skip_value_check) end |
#set_textfield_by_name(browser, name, value, desc = '', skip_value_check = false) ⇒ Object
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 |
# File 'lib/awetestlib/regression/user_input.rb', line 1070 def set_textfield_by_name(browser, name, value, desc = '', skip_value_check = false) if browser.text_field(:name, name).exists? tf = browser.text_field(:name, name) # Workaround because browser.text_field doesn't work for password fields in Safari elsif @browserAbbrev.eql?("S") tf = browser.password(:name, name) end if tf.exists? if validate(browser, @myName, __LINE__) tf.set(value) if validate(browser, @myName, __LINE__) if tf.value == value passed_to_log("Set textfield name='#{name}' to '#{value}' #{desc}") true elsif skip_value_check passed_to_log("Set textfield name='#{name}' to '#{value}' #{desc} (skip value check)") true else failed_to_log("Set textfield name='#{name}' to '#{value}': Found:'#{tf.value}'. #{desc} (#{__LINE__})") end end end else failed_to_log("Textfield name='#{name}' not found to set to '#{value}'. #{desc} (#{__LINE__})") end rescue failed_to_log("Textfield name='#{name}' could not be set to '#{value}': '#{$!}'. #{desc} (#{__LINE__})") end |
#set_textfield_by_title(browser, title, value, desc = '', skip_value_check = false) ⇒ Object
1127 1128 1129 |
# File 'lib/awetestlib/regression/user_input.rb', line 1127 def set_textfield_by_title(browser, title, value, desc = '', skip_value_check = false) set_text_field(browser, :title, title, value, desc, skip_value_check) end |