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.
162 163 164 |
# File 'lib/test-factory/gem_ext.rb', line 162 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’
193 194 195 196 197 198 199 |
# File 'lib/test-factory/gem_ext.rb', line 193 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.
182 183 184 185 186 187 188 |
# File 'lib/test-factory/gem_ext.rb', line 182 def pick!(item) if item=='::random::' item.replace(select_at_random) else fit item end end |