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.15.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.14.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.14.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.13.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.13.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.12.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.12.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.11.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.11.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.10.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.9.2 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.9.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.9.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.8.3 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.8.2 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.8.1 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.7.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.6.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.5.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb
fe_core_ext-0.4.0 lib/fe_core_ext/gem_ext/selenium_webdriver.rb