Class: Watir::FileField
- Inherits:
-
InputElement
- Object
- Element
- InputElement
- Watir::FileField
- Defined in:
- lib/watir/dialogs/file_field.rb
Constant Summary collapse
- INPUT_TYPES =
:stopdoc:
["file"]
Constants inherited from Element
Instance Attribute Summary
Attributes inherited from Element
Attributes included from Container
#activeObjectHighLightColor, #page_container, #type_keys, #typingspeed
Instance Method Summary collapse
- #assert_file_exists(file_path) ⇒ Object
- #cancel_button ⇒ Object
- #file_upload_window ⇒ Object
- #open_button ⇒ Object
-
#set(file_path) ⇒ Object
:startdoc:.
- #set_file_name(path_to_file) ⇒ Object
Methods inherited from InputElement
Methods inherited from Element
#<=>, #activeObjectHighLightColor, #after_text, #assert_enabled, #assert_exists, #attribute_value, #before_text, #click, #click!, #create_event, #dispatch_event, #document, #enabled?, #exists?, #fire_event, #flash, #focus, #initialize, #inspect, #method_missing, #ole_object, #ole_object=, #parent, #text, #to_s, #type_keys, #typingspeed, #visible?
Methods included from Container
#area, #areas, #button, #buttons, #cell, #cells, #checkbox, #checkboxes, #dds, #divs, #dls, #dts, #element, #element_by_css, #elements, #ems, #file_field, #file_fields, #form, #forms, #frame, #frames, #hidden, #hiddens, #image, #images, #javascript_dialog, #labels, #link, #links, #lis, #locate_all_elements, #locate_input_element, #locate_tagged_element, #log, #map, #maps, #modal_dialog, #popup, #pres, #ps, #radio, #radios, #row, #rows, #select_list, #select_lists, #set_container, #show_all_objects, #spans, #strongs, #table, #tables, #text_field, #text_fields, #wait
Constructor Details
This class inherits a constructor from Watir::InputElement
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Watir::Element
Instance Method Details
#assert_file_exists(file_path) ⇒ Object
15 16 17 |
# File 'lib/watir/dialogs/file_field.rb', line 15 def assert_file_exists(file_path) raise WatirException, "#{file_path} has to exist to set!" unless File.exists?(file_path) end |
#cancel_button ⇒ Object
27 28 29 |
# File 'lib/watir/dialogs/file_field.rb', line 27 def file_upload_window.(:value => 'Cancel') end |
#file_upload_window ⇒ Object
31 32 33 |
# File 'lib/watir/dialogs/file_field.rb', line 31 def file_upload_window @window ||= RAutomation::Window.new(:title => /^choose file( to upload)?$/i) end |
#open_button ⇒ Object
23 24 25 |
# File 'lib/watir/dialogs/file_field.rb', line 23 def file_upload_window.(:value => '&Open') end |
#set(file_path) ⇒ Object
:startdoc:
7 8 9 10 11 12 13 |
# File 'lib/watir/dialogs/file_field.rb', line 7 def set(file_path) assert_file_exists(file_path) assert_exists click_no_wait set_file_name file_path .click end |
#set_file_name(path_to_file) ⇒ Object
19 20 21 |
# File 'lib/watir/dialogs/file_field.rb', line 19 def set_file_name(path_to_file) file_upload_window.text_field(:class => 'Edit', :index => 0).set path_to_file end |