Class: Watir::FileField
- Inherits:
-
InputElement
- Object
- Element
- InputElement
- Watir::FileField
- Defined in:
- lib/watir-classic/dialogs/file_field.rb
Constant Summary
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 (also: #value=)
- #set_file_name(path_to_file) ⇒ Object
Methods inherited from InputElement
Methods inherited from Element
#<=>, #__ole_inner_elements, #activeObjectHighLightColor, #assert_enabled, #assert_exists, #attribute_value, #click, #click!, #create_event, #disabled?, #dispatch_event, #document, #double_click, #enabled?, #exists?, #fire_event, #flash, #focus, #focused?, #initialize, #inspect, #locate, #method_missing, #ole_object, #ole_object=, #parent, #right_click, #send_keys, #style, #tag_name, #text, #to_s, #to_subtype, #type_keys, #typingspeed, #visible?
Methods included from DragAndDropHelper
#drag_and_drop_by, #drag_and_drop_on
Methods included from Container
#__ole_inner_elements, #alert, #locator_for, #modal_dialog, #set_container, support_element, #wait
Methods included from Exception
Methods included from ElementExtensions
#present?, #wait_until_present, #wait_while_present, #when_present
Constructor Details
This class inherits a constructor from Watir::Element
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
14 15 16 |
# File 'lib/watir-classic/dialogs/file_field.rb', line 14 def assert_file_exists(file_path) raise Errno::ENOENT, "#{file_path} has to exist to set!" unless File.exists?(file_path) end |
#cancel_button ⇒ Object
26 27 28 |
# File 'lib/watir-classic/dialogs/file_field.rb', line 26 def file_upload_window.(:value => /Cancel/) end |
#file_upload_window ⇒ Object
30 31 32 |
# File 'lib/watir-classic/dialogs/file_field.rb', line 30 def file_upload_window @window ||= RAutomation::Window.new(:title => /^choose file( to upload)?|Elegir archivos para cargar$/i) end |
#open_button ⇒ Object
22 23 24 |
# File 'lib/watir-classic/dialogs/file_field.rb', line 22 def file_upload_window.(:value => /&Open|&Abrir/) end |
#set(file_path) ⇒ Object Also known as: value=
3 4 5 6 7 8 9 10 |
# File 'lib/watir-classic/dialogs/file_field.rb', line 3 def set(file_path) assert_file_exists(file_path) assert_exists click_no_wait set_file_name file_path.gsub(File::SEPARATOR, File::ALT_SEPARATOR) .click Wait.until(5) {value.include?(File.basename(file_path))} end |
#set_file_name(path_to_file) ⇒ Object
18 19 20 |
# File 'lib/watir-classic/dialogs/file_field.rb', line 18 def set_file_name(path_to_file) file_upload_window.text_field(:class => 'Edit', :index => 0).set path_to_file end |