Class: YuiRestClient::Widgets::Tab

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

Overview

Class representing a tab in the UI. It can be YDumbTab.

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 tab.

Examples:

Get items from tab with id “test_id”

{
  "class": "YDumbTab",
  "debug_label": "YDumbTab [tab1] [tab2] [tab3]",
  "hstretch": true,
  "icon_base_path": "",
  "id": "test_id",
  "items": [
    {
      "label": "tab1"
    },
    {
      "label": "tab2",
      "selected": true
    },
    {
      "label": "tab3"
    }
  ],
  "items_count": 3,
  "vstretch": true
}
app.tab(id: 'test').items
# tab1
# tab2
# tab3

Returns:

  • (Array)

    array of String objects.



36
37
38
# File 'lib/yui_rest_client/widgets/tab.rb', line 36

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

#select(item) ⇒ Tab

Sends action to click the tab in UI.

Examples:

Click tab with id ‘test’

app.button(id: 'test', value: test_item).select

Parameters:

  • item (String)

    value to select from items.

Returns:

  • (Tab)

    in case action is successful



45
46
47
48
# File 'lib/yui_rest_client/widgets/tab.rb', line 45

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

#selected_itemString

Returns the label of the selected tab.

Examples:

Get items from tab with id “test_id”

{
  "class": "YDumbTab",
  "debug_label": "YDumbTab [tab1] [tab2] [tab3]",
  "hstretch": true,
  "icon_base_path": "",
  "id": "test_id",
  "items": [
    {
      "label": "tab1"
    },
    {
      "label": "tab2",
      "selected": true
    },
    {
      "label": "tab3"
    }
  ],
  "items_count": 3,
  "vstretch": true
}
app.tab(id: 'test').selected_item  # tab2

Returns:

  • (String)

    label of the tab selected



76
77
78
# File 'lib/yui_rest_client/widgets/tab.rb', line 76

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