Class: OperaWatir::QuickButton

Inherits:
QuickWidget show all
Includes:
ClickableItem
Defined in:
lib/operawatir/quickwidgets/quick_button.rb

Direct Known Subclasses

QuickTab, QuickThumbnail

Constant Summary

Constants inherited from QuickWidget

OperaWatir::QuickWidget::ConditionTimeout

Instance Method Summary collapse

Methods included from ClickableItem

#close_menu_with_click, #load_page_with_click, #open_menu_with_click, #open_window_with_click

Methods inherited from QuickWidget

#click_with_condition, #double_click_with_condition, #enabled?, #exist?, #focus_with_click, #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, #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

#change_page_with_clickint

Clicks the button, and waits for the dialog wizard to switch to the next page

Examples:

browser.quick_button(:name, "button_Next").change_page_with_click

Returns:

  • (int)

    Window ID of the dialog wizard or 0 if no window is shown

Raises:



32
33
34
35
36
# File 'lib/operawatir/quickwidgets/quick_button.rb', line 32

def change_page_with_click()
  wait_start
  click
  wait_for_window_shown("")
end

#close_toolbar_with_clickObject Also known as: close_panel_with_click

Clicks button to close the toolbar

Examples:

browser.quick_toolbar(:name, "Go To Intranet Toolbar").quick_button(:name, "Done").close_toolbar_with_click

Raises:



92
93
94
95
96
97
# File 'lib/operawatir/quickwidgets/quick_button.rb', line 92

def close_toolbar_with_click
  click

  # Cheat since we don't have an event yet
  sleep(0.1)
end

#close_window_with_click(win_name) ⇒ int Also known as: close_dialog_with_click

Clicks the button, and waits for the window with window name win_name to closed

Parameters:

  • win_name (String)

    name of the window that will be closed (Pass a blank string for any window)

Returns:

  • (int)

    Window ID of the window is closed or 0 if no window is closed

Raises:



50
51
52
53
54
# File 'lib/operawatir/quickwidgets/quick_button.rb', line 50

def close_window_with_click(win_name)
  wait_start
  click
  wait_for_window_close(win_name)
end

#default?Boolean

Checks if the button is the default button

Returns:

  • (Boolean)

    true if the default button otherwise false



16
17
18
# File 'lib/operawatir/quickwidgets/quick_button.rb', line 16

def default?
  element.isDefault
end

#expand_with_clickObject Also known as: collapse_with_click

Clicks button to expand or collapse the toolbar

Raises:



107
108
109
110
111
# File 'lib/operawatir/quickwidgets/quick_button.rb', line 107

def expand_with_click
  click
  sleep(0.1)
  #No refresh element because it might not be there still (after click):)
end

#toggle_with_clickint

Clicks a button or expand control and toggles it state

Returns:

  • (int)

    the new state of the button or expand control, 0 for not pressed, or 1 for pressed, nil if the element does no longer exist

Raises:



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/operawatir/quickwidgets/quick_button.rb', line 69

def toggle_with_click
  click

  # Cheat since we don't have an event yet
  sleep(0.1)

  # Note: click might have made this element dissapear ...
  begin
    element(true).getValue
  rescue Exceptions::UnknownObjectException
    nil
  end
end

#valueint

Gets the value of the button or expand control.

Returns:

  • (int)

    0 if not pressed, or 1 if pressed

Raises:



122
123
124
# File 'lib/operawatir/quickwidgets/quick_button.rb', line 122

def value
  element.getValue
end

#wait_for_enabledBoolean

Pauses to wait for security dialogs when buttons are not active right away on opening

Examples:

(RSpec)

browser.quick_button(:name, "button_OK").wait_for_enabled.should == true

Returns:

  • (Boolean)

    Returns true if the button becomes active



135
136
137
# File 'lib/operawatir/quickwidgets/quick_button.rb', line 135

def wait_for_enabled
  wait_for_widget_enabled
end

#wait_for_visibleBoolean

Waits for widget to be visible

Returns:

  • (Boolean)

    Returns true if the button becomes active



144
145
146
# File 'lib/operawatir/quickwidgets/quick_button.rb', line 144

def wait_for_visible
  wait_for_widget_visible
end