Class: OperaWatir::QuickEditField

Inherits:
QuickWidget show all
Defined in:
lib/operawatir/quickwidgets/quick_editfield.rb

Constant Summary

Constants inherited from QuickWidget

OperaWatir::QuickWidget::ConditionTimeout

Instance Method Summary collapse

Methods inherited from QuickWidget

#click_with_condition, #double_click_with_condition, #enabled?, #exist?, #focus_with_hover, #has_ui_string?, #height, #middle_click_with_condition, #name, #open_menu_with_rightclick, #open_window_with_hover, #parent_name, #position, #quick_tabs, #quick_widgets, #right_click_with_condition, #text, #to_s, #type, #value, #verify_includes_text, #verify_text, #visible?, #widget_info_string, #width

Methods included from DesktopContainer

#quick_addressfield, #quick_button, #quick_checkbox, #quick_dialogtab, #quick_dropdown, #quick_dropdownitem, #quick_editfield, #quick_find, #quick_griditem, #quick_gridlayout, #quick_label, #quick_menu, #quick_menuitem, #quick_radiobutton, #quick_searchfield, #quick_tab, #quick_thumbnail, #quick_toolbar, #quick_treeitem, #quick_treeview, #quick_window

Instance Method Details

#clearObject

Clears the contents of the edit field



51
52
53
54
55
56
57
58
59
# File 'lib/operawatir/quickwidgets/quick_editfield.rb', line 51

def clear
  focus_with_click

  key_press_direct("a", :ctrl)
  key_press_direct("backspace")

  # Cheat until we have an event
  sleep(0.1)
end

#focus_with_clickObject

Sets focus to the edit field by clicking on it

Examples:

browser.quick_editfield(:name, "Startpage_edit").focus_with_clic

Raises:



19
20
21
# File 'lib/operawatir/quickwidgets/quick_editfield.rb', line 19

def focus_with_click
  super
end

#key_press(key, *modifiers) ⇒ String

Note:

The edit field must have focus for this method to work

Note:

WARNING: This method will not wait for page load or window shown events. If you need to wait for these events do not use this method

Presses a key including modifiers

Examples:

browser.quick_toolbar(:name, "Document Toolbar").quick_addressfield(:name, "tba_address_field").key_press("a", :ctrl)
browser.quick_toolbar(:name, "Document Toolbar").quick_addressfield(:name, "tba_address_field").key_press("c", :ctrl)

Parameters:

  • key (String)

    key to press (e.g. “a” or “backspace”)

  • modifiers (Symbol)

    optional modifier(s) to hold down while pressing the key (e.g. :shift, :ctrl, :alt, :meta)

Returns:

  • (String)

    Text in the field after the keypress



78
79
80
81
82
83
84
85
86
# File 'lib/operawatir/quickwidgets/quick_editfield.rb', line 78

def key_press(key, *modifiers)
  key_press_direct(key, *modifiers)

  # Cheat until we have an event
  sleep(0.1)

  # Return what is in the field to check
  element(true).getText
end

#type_text(text, wait = 0) ⇒ String

Note:

Only characters that appear on the keyboard that is currently selected can be typed, and the edit field must have focus.

Types a text string into the edit field

Parameters:

  • text (String)

    text string to type in

  • wait (defaults to: 0)
    • seconds to wait after typing

Returns:

  • (String)

    contents of the edit field after typing has completed



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/operawatir/quickwidgets/quick_editfield.rb', line 34

def type_text(text, wait = 0)
  text.each_char { | t | key_press_direct t }

  # No event yet so just cheat and sleep
  sleep(0.2)

  # Return what is in the field to check
  text = element(true).getText

  sleep(wait) if wait != 0

  text
end