Sha256: 981a60f06ab3e19f86004e7b89cc5fb525cecb6d089eb37e2cfd6ec601886e86

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

module Selenium::WebDriver::Find
  def find_element_without_no_element_error(*args)
    find_element(*args)
  rescue Selenium::WebDriver::Error::NoSuchElementError
    nil
  end

  def find_elements_without_no_element_error(*args)
    find_elements(*args)
  rescue Selenium::WebDriver::Error::NoSuchElementError
    nil
  end

  def at_xpath(path, wait: nil)
    if wait.present?
      driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
      driver_wait.until { find_element_without_no_element_error(:xpath, path) }
    end
    find_element_without_no_element_error(:xpath, path)
  end

  def xpath(path, wait: nil)
    if wait.present?
      driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
      driver_wait.until { find_elements_without_no_element_error(:xpath, path) }
    end
    find_elements_without_no_element_error(:xpath, path)
  end

  def at_css(path, wait: nil)
    if wait.present?
      driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
      driver_wait.until { find_element_without_no_element_error(:css, path) }
    end
    find_element_without_no_element_error(:css, path)
  end

  def css(path, wait: nil)
    if wait.present?
      driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
      driver_wait.until { find_elements_without_no_element_error(:css, path) }
    end
    find_elements_without_no_element_error(:css, path)
  end
end

class Selenium::WebDriver::Driver
  include Selenium::WebDriver::Find
end

class Selenium::WebDriver::Element
  include Selenium::WebDriver::Find
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fe_core_ext-0.30.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.30.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.29.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb