Method: Selenium::WebDriver::Driver#text?
- Defined in:
- lib/oats/oats_selenium_api.rb
#text?(value, *locators) ⇒ Boolean
Returns locator if /value/ =~ text in any of the locators, or
false if element is not found, nil otherwise
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/oats/oats_selenium_api.rb', line 257 def text?(value, *locators) locators.flatten! found = nil value_reg = value.instance_of?(Regexp) ? value : /#{value}/ if locators.empty? Oats.warn "Please include a locator to more speficifically locate text: [#{value}]" # if webdriver? locators = [Locator.new('body',:tag_name)] # else # found = is_text_orig(value) # end end locator = false found = locators.find do |loc| # if webdriver? elems = elements(loc) if elems and !elems.empty? elems.find { |el| if el.displayed? locator = true value_reg =~ el.text end } end # else # if loc # begin # if element?(loc) and visible?(loc) # locator = true # value_reg =~ text_orig(loc) # end # rescue Selenium::CommandError => exc # raise unless exc.message =~ /Element .* not found/ # end # end # end end if found.nil? oats_debug('text? '+(found ? 'found' : 'could not locate' ) +" [#{value}] at #{locators}") if found found else locator ? nil : false end end |