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
Same as #pick!, except it does not change the value of ‘item’.
-
#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.
169 170 171 |
# File 'lib/test-factory/gem_ext.rb', line 169 def fit(str_or_rx) select_by :text, str_or_rx unless str_or_rx==nil end |
#pick(item) ⇒ Object
Same as #pick!, except it does not change the value of ‘item’
200 201 202 203 204 205 206 |
# File 'lib/test-factory/gem_ext.rb', line 200 def pick(item) if item=='::random::' select_at_random else fit item end 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). Note that this method will be slow with large selection lists.
189 190 191 192 193 194 195 |
# File 'lib/test-factory/gem_ext.rb', line 189 def pick!(item) if item=='::random::' item.replace(select_at_random) else fit item end end |