Class: YuiRestClient::Widgets::Checkbox

Inherits:
Base
  • Object
show all
Defined in:
lib/yui_rest_client/widgets/checkbox.rb

Overview

Class representing a Checkbox in UI. It can be YCheckBox or YCheckBoxFrame.

Instance Method Summary collapse

Methods inherited from Base

#action, #collect_all, #debug_label, #enabled?, #exists?, #initialize, #property

Methods included from YuiRestClient::Waitable

#wait_until, #wait_while

Constructor Details

This class inherits a constructor from YuiRestClient::Widgets::Base

Instance Method Details

#checkCheckbox

Sends action to explicitly check the checkbox in UI (regardless of the current state).

Examples:

Check checkbox with id ‘test’

app.checkbox(id: 'test').check

Returns:

  • (Checkbox)

    in case action is successful



11
12
13
14
# File 'lib/yui_rest_client/widgets/checkbox.rb', line 11

def check
  action(action: Actions::CHECK)
  self
end

#checked?Boolean

Returns the state of checkbox (checked/unchecked). Gets value from ‘value’ parameter in JSON representation of YCheckBox or YCheckBoxFrame.

Examples:

Get checkbox state

{
  "class": "YCheckBox",
  "debug_label": "Change the Time Now",
  "id": "change_now",
  "label": "Chan&ge the Time Now",
  "notify": true,
  "value": true
}
app.checkbox(id: 'change_now').checked? # true

Returns:

  • (Boolean)

    true if it is checked, false otherwise.



30
31
32
# File 'lib/yui_rest_client/widgets/checkbox.rb', line 30

def checked?
  property(:value)
end

#toggleCheckbox

Sends action to toggle the checkbox in UI (i.e. uncheck when checked, or check otherwise).

Examples:

Toggle checkbox with id ‘test’

app.checkbox(id: 'test').toggle

Returns:

  • (Checkbox)

    in case action is successful



38
39
40
41
# File 'lib/yui_rest_client/widgets/checkbox.rb', line 38

def toggle
  action(action: Actions::TOGGLE)
  self
end

#uncheckCheckbox

Sends action to explicitly uncheck the checkbox in UI (regardless of the current state).

Examples:

Uncheck checkbox with id ‘test’

checkbox(id: 'test').uncheck

Returns:

  • (Checkbox)

    in case action is successful



47
48
49
50
# File 'lib/yui_rest_client/widgets/checkbox.rb', line 47

def uncheck
  action(action: Actions::UNCHECK)
  self
end