Class: YuiRestClient::Widgets::Selectionbox

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

Overview

Class representing a selectionbox in the UI. It can be YSelectionBox.

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

#itemsArray

Returns the list of items available to select from selection box.

Examples:

Get items from selection box with id “test_id”

{
  "class" : "YSelectionBox",
  "debug_label" : "selection box title",
  "hstretch" : true,
  "icon_base_path" : "",
  "id" : "test_id",
  "items" :
  [
    {
      "label" : "selection 1",
      "selected" : true
    },
    {
      "label" : "selection 2"
    },
    {
      "label" : "selection 3"
    }
  ],
  "items_count" : 3,
  "label" : "&selection box title",
  "vstretch" : true
}
app.selectionbox(id: 'test_id').items
# selection 1
# selection 2
# selection 3

Returns:

  • (Array)

    array of String objects.



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

def items
  property(:items).map { |x| x[:label] }
end

#select(item) ⇒ Selectionbox

Sends action to click the selection in UI.

Examples:

Click selection with id ‘test_id’

app.selectionbox(id: 'test_id').select('item_id')

Parameters:

  • item (String)

    value to select from items.

Returns:



48
49
50
51
# File 'lib/yui_rest_client/widgets/selectionbox.rb', line 48

def select(item)
  action(action: Actions::SELECT, value: item)
  self
end

#selected_itemObject

Returns selected item in selection box.

Examples:

Get selected item in selection box with id “test_id”

{
  "class" : "YSelectionBox",
  "debug_label" : "selection box title",
  "hstretch" : true,
  "icon_base_path" : "",
  "id" : "test_id",
  "items" :
  [
    {
      "label" : "selection 1",
      "selected" : true
    },
    {
      "label" : "selection 2"
    },
    {
      "label" : "selection 3"
    }
  ],
  "items_count" : 3,
  "label" : "&selection box title",
  "vstretch" : true
}
app.selectionbox(id: 'test_id').selected_item
# selection 1


82
83
84
# File 'lib/yui_rest_client/widgets/selectionbox.rb', line 82

def selected_item
  property(:items).select { |x| x[:selected] }.first[:label]
end