Sha256: 211899c7d0fd607df71835185218626707007114d002a0bc766e682c8e38bea4

Contents?: true

Size: 1.51 KB

Versions: 52

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

52 entries across 52 versions & 1 rubygems

Version Path
fe_core_ext-0.29.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.28.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.27.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.26.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.26.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.25.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.24.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.23.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.22.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.21.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.20.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.19.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.18.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.18.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.17.3 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.17.2 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.17.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.17.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.16.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.16.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb