Class: Cucumber::Salad::Widgets::FieldGroup::Select

Inherits:
Field
  • Object
show all
Defined in:
lib/cucumber/salad/widgets/field_group.rb

Overview

A select.

Instance Attribute Summary

Attributes inherited from Widget

#root

Instance Method Summary collapse

Methods inherited from Field

find_in, present_in?

Methods inherited from Widget

find_in, #has_action?, #initialize, #inspect, present_in?, #reload, root, selector

Methods included from Cucumber::Salad::WidgetMacros

#action, #widget, #widget_delegator

Methods included from Cucumber::Salad::WidgetContainer

#has_widget?, #widget

Constructor Details

This class inherits a constructor from Cucumber::Salad::Widgets::Widget

Instance Method Details

#getString

Returns The text of the selected option.

Returns:

  • (String)

    The text of the selected option.



293
294
295
296
297
# File 'lib/cucumber/salad/widgets/field_group.rb', line 293

def get
  option = root.find('[selected]') rescue nil

  option && option.text
end

#set(option) ⇒ Object

Selects the given option.

Parameters:

  • option (String)

    The text of the option to select.



302
303
304
# File 'lib/cucumber/salad/widgets/field_group.rb', line 302

def set(option)
  root.find('option', text: option).select_option
end

#to_sObject

Returns the text of the selected option, or the empty string if no option is selected.

Returns:

  • the text of the selected option, or the empty string if no option is selected.



309
# File 'lib/cucumber/salad/widgets/field_group.rb', line 309

def_delegator :get, :to_s