Class: OperaWatir::QuickWidget
- Includes:
- Deprecated, DesktopContainer
- Defined in:
- lib/operawatir/quickwidgets/quick_widget.rb
Direct Known Subclasses
QuickButton, QuickCheckbox, QuickDialogTab, QuickEditField, QuickGridItem, QuickGridLayout, QuickLabel, QuickMenu, QuickMenuItem, QuickToolbar, QuickTreeItem, QuickTreeView
Constant Summary collapse
- ConditionTimeout =
10.0
Instance Method Summary collapse
-
#click_with_condition(&condition) ⇒ Object
click_with_condition { block } → res.
-
#double_click_with_condition(&condition) ⇒ Object
double_click_with_condition { block } → res.
-
#enabled? ⇒ Boolean
Checks if a widget is enabled or not.
-
#exist? ⇒ Boolean
(also: #exists?)
Checks whether a widget exists or not.
-
#focus_with_click ⇒ Object
Focus a widget with a click.
-
#focus_with_hover ⇒ Object
Focus a widget by moving the mouse over it.
-
#has_ui_string? ⇒ Boolean
Checks that the text in the widget matches the text as loaded from the current language file in Opera using the string_id (Strips &‘s from the string before comparing).
-
#height ⇒ Object
Height of widget.
-
#middle_click_with_condition(&condition) ⇒ Object
middle_click_with_condition { block } → res.
-
#name ⇒ String
Gets the name of the widget (as it appears in dialog.ini or code).
-
#open_menu_with_rightclick(menu_name) ⇒ String
Rightclicks the widget, and waits for the menu with name menu_name to be shown.
-
#open_window_with_hover(win_name = "") ⇒ Object
Hovers widget and waits for window to be shown.
-
#parent_name ⇒ Object
Gets parent widget name.
-
#position ⇒ Object
Position for elements that have a position, else false.
- #quick_tabs ⇒ Object
-
#quick_widgets ⇒ Object
All widgets inside this widget.
-
#right_click_with_condition(&condition) ⇒ Object
right_click_with_condition { block } → res.
-
#text ⇒ String
Gets the text of the widget.
-
#to_s ⇒ String
Gets a string representation of the widget.
-
#type ⇒ Symbol
Gets the type of a widget.
- #value ⇒ Object
-
#verify_includes_text(string_id) ⇒ Boolean
(also: #includes_text?)
Checks that the text in the widget includes the text as loaded from the current language file in Opera using the string_id.
-
#verify_text(string_id, *params) ⇒ Boolean
Checks that the text in the widget matches the text as loaded from the current language file in Opera using the string_id (Strips &‘s from the string before comparing).
-
#visible? ⇒ Boolean
Checks if a widget is visible or not.
-
#widget_info_string ⇒ Object
Returns a string of all of the internal information about the widget.
-
#width ⇒ Object
Width of widget.
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
#click_with_condition(&condition) ⇒ Object
click_with_condition { block } → res
Clicks widget and waits until block evaluates to true or timeout is hit
384 385 386 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 384 def click_with_condition(&condition) click_with_condition_internal(:left, 1, &condition) end |
#double_click_with_condition(&condition) ⇒ Object
double_click_with_condition { block } → res
Doubleclicks widget and waits until block evaluates to true or timeout is hit
344 345 346 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 344 def double_click_with_condition(&condition) click_with_condition_internal(:left, 2, &condition) end |
#enabled? ⇒ Boolean
Checks if a widget is enabled or not
77 78 79 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 77 def enabled? element.isEnabled end |
#exist? ⇒ Boolean Also known as: exists?
Checks whether a widget exists or not
62 63 64 65 66 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 62 def exist? !!element rescue Exceptions::UnknownObjectException false end |
#focus_with_click ⇒ Object
Focus a widget with a click
321 322 323 324 325 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 321 def focus_with_click click # No event yet so just cheat and sleep sleep(0.1) end |
#focus_with_hover ⇒ Object
Focus a widget by moving the mouse over it
330 331 332 333 334 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 330 def focus_with_hover element.hover #No event yet so just cheat and sleep sleep(0.1) end |
#has_ui_string? ⇒ Boolean
Checks that the text in the widget matches the text as loaded from the current language file in Opera using the string_id (Strips &‘s from the string before comparing)
168 169 170 171 172 173 174 175 176 177 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 168 def verify_text(string_id) text = driver.getString(string_id, true) #true => stripAmpersands from string if text.include? "%" text.gsub!(/%[csduoxefg0-9]/, ".*") res = /#{text}/ =~ element.getText() res == nil ? false: true else element.verifyText(string_id) end end |
#height ⇒ Object
Returns height of widget.
263 264 265 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 263 def height element.getRect().height end |
#middle_click_with_condition(&condition) ⇒ Object
middle_click_with_condition { block } → res
Middleclicks widget and waits until block evaluates to true or timeout is hit
368 369 370 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 368 def middle_click_with_condition(&condition) click_with_condition_internal(:middle, 1, &condition) end |
#name ⇒ String
Gets the name of the widget (as it appears in dialog.ini or code)
128 129 130 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 128 def name element.getName end |
#open_menu_with_rightclick(menu_name) ⇒ String
Rightclicks the widget, and waits for the menu with name menu_name to be shown
51 52 53 54 55 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 51 def () wait_start click(:right) () end |
#open_window_with_hover(win_name = "") ⇒ Object
Hovers widget and waits for window to be shown
33 34 35 36 37 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 33 def open_window_with_hover(win_name = "") wait_start element.hover wait_for_window_shown(win_name) end |
#parent_name ⇒ Object
Gets parent widget name
314 315 316 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 314 def parent_name element.getParentName() end |
#position ⇒ Object
Returns position for elements that have a position, else false.
239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 239 def position case type when :treeitem then [row, col] when :tabbutton, :button then col else false end #return [row, col] if type == :treeitem #return col if type == :tabbutton #return col if type == :button #false end |
#quick_tabs ⇒ Object
416 417 418 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 416 def quick_tabs end |
#quick_widgets ⇒ Object
you can also specify the widgets by type to retrieve only a specific type of widgets
Returns all widgets inside this widget.
412 413 414 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 412 def (window_id).select { | w | w.parent_name == name } end |
#right_click_with_condition(&condition) ⇒ Object
right_click_with_condition { block } → res
Rightclicks widget and waits until block evaluates to true or timeout is hit
356 357 358 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 356 def right_click_with_condition(&condition) click_with_condition_internal(:right, 1, &condition) end |
#text ⇒ String
This method should not be used to check the text in a widget if the text is in the Opera language file. Use verify_text instead
Gets the text of the widget
104 105 106 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 104 def text element.getText end |
#to_s ⇒ String
Gets a string representation of the widget
140 141 142 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 140 def to_s "#{type.to_s.capitalize} #{name}, text=#{text}, parentName=#{parent_name}, visible=#{visible?}, enabled=#{enabled?}, position=#{row},#{col}" end |
#type ⇒ Symbol
Gets the type of a widget
116 117 118 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 116 def type WIDGET_ENUM_MAP.invert[element.getType] end |
#value ⇒ Object
393 394 395 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 393 def value return element.getValue end |
#verify_includes_text(string_id) ⇒ Boolean Also known as: includes_text?
Checks that the text in the widget includes the text as loaded from the current language file in Opera using the string_id
201 202 203 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 201 def verify_includes_text(string_id) element.verifyContainsText(string_id) end |
#verify_text(string_id, *params) ⇒ Boolean
Checks that the text in the widget matches the text as loaded from the current language file in Opera using the string_id (Strips &‘s from the string before comparing)
157 158 159 160 161 162 163 164 165 166 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 157 def verify_text(string_id) text = driver.getString(string_id, true) #true => stripAmpersands from string if text.include? "%" text.gsub!(/%[csduoxefg0-9]/, ".*") res = /#{text}/ =~ element.getText() res == nil ? false: true else element.verifyText(string_id) end end |
#visible? ⇒ Boolean
Checks if a widget is visible or not
89 90 91 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 89 def visible? element.isVisible end |
#widget_info_string ⇒ Object
Returns a string of all of the internal information about the widget. Used to discover the names of widgets and windows to use in the tests
295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 295 def " Name: " + name + "\n Text: " + text + "\n Type: " + type.to_s + "\n Parent: " + element.getParentName() + "\nVisible: " + visible?.to_s + "\nEnabled: " + enabled?.to_s + "\n Pos: x=" + element.getRect().x.to_s + ", y=" + element.getRect().y.to_s + "\n Size: width=" + element.getRect().width.to_s + ", height=" + element.getRect().height.to_s + "\n Ref: row=" + element.getRow().to_s + ", col=" + element.getColumn().to_s + "\nselected: " + element.isSelected().to_s + "\n" end |
#width ⇒ Object
Returns width of widget.
255 256 257 |
# File 'lib/operawatir/quickwidgets/quick_widget.rb', line 255 def width element.getRect().width end |