Class: Watir::Select
- Inherits:
-
Object
- Object
- Watir::Select
- Defined in:
- lib/test-factory/gem_ext.rb
Instance Method Summary collapse
-
#fit(str_or_rx) ⇒ Object
Extends Watir’s methods.
-
#pick!(item) ⇒ Object
Allows you to select a specific item in a select list, or, if desired, it will pick an item from the list at random.
Instance Method Details
#fit(str_or_rx) ⇒ Object
Extends Watir’s methods. Use when the argument you are passing to a text field may be nil, in which case you don’t want to do anything with the page element.
156 157 158 |
# File 'lib/test-factory/gem_ext.rb', line 156 def fit(str_or_rx) select_by :text, str_or_rx unless str_or_rx==nil end |
#pick!(item) ⇒ Object
Allows you to select a specific item in a select list, or, if desired, it will pick an item from the list at random.
If you pass this method the string ‘::random::’ then it will select an item at random from the select list and, assuming what you passed it was a class instance variable, it will be updated to contain the selected value (hence the ! in the method name).
175 176 177 178 179 180 181 |
# File 'lib/test-factory/gem_ext.rb', line 175 def pick!(item) if item=='::random::' item.replace(select_at_random) else fit item end end |