Method: Selenium::WebDriver::Driver#select
- Defined in:
- lib/oats/oats_selenium_api.rb
#select(locator, value, noscript = nil, select_tag = 'option') ⇒ Object
select
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/oats/oats_selenium_api.rb', line 172 def select(locator, value, noscript = nil, select_tag = 'option') oats_debug "select #{value} at #{locator} by tag_name #{select_tag}" # unless webdriver? # select_orig(locator, value) # return locator # end attribute, val = value.split(/=/) = [] if val attribute = 'text' if attribute == 'label' else val = attribute attribute = 'text' end if val.index("*") regex = true end el = element?(locator) if el el.find_elements(:tag_name,select_tag).each do |opt| attr_value = opt.attribute(attribute) match = if regex attr_value =~ /#{val}/ else attr_value == val end # if attr_value == val # el.click if match loc = locator.to_s.split(/'/) opt.click unless noscript selenium.run_script("$('##{loc[1]}').change()") if selenium.ie? and loc[1] end return opt end .push attr_value end end raise OatsTestError, "Could not find #{val} among options: #{options.inspect}" end |