Method: Sapphire::WebAbstractions::RubySeleniumWebDriver#FindAllItems

Defined in:
lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb

#FindAllItems(array) ⇒ Object



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
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
# File 'lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb', line 242

def FindAllItems(array)
  masterWait = Selenium::WebDriver::Wait.new(:timeout => 5)

  x = nil
  by = nil
  value = nil

  element, by, value = masterWait.until {

    array.each do |item|

      if item.is_a? Hash
        begin
          x = self.FindElements item.keys.first, item.fetch(item.keys.first)
          x = nil if x.is_a? Array and x.empty?

          if !x.nil?
            by = item.keys.first
            value = item[item.keys.first]
          end
        rescue
          #do nothing, let it keep looping
        end
      end

      x, by, value = self.FindElements item[0], item[1] if item.is_a? Array
      x = nil if x.is_a? Array and x.empty?
      return x, by, value if x != nil

    end if array.is_a? Array

    x = self.FindElements array.keys.first, array.fetch(array.keys.first) if array.is_a? Hash
    if !x.nil?
      by = item.keys.first
      value = item[item.keys.first]
    end
    return x, by, value if x != nil
  }
  return element, by, value if element != nil
  raise "Could not find control for array: " + array.to_s
end