Sha256: 032f885458758676dedac8464a372b194b3f91b42a6b2aafdf0d159b56e2e56f

Contents?: true

Size: 855 Bytes

Versions: 1

Compression:

Stored size: 855 Bytes

Contents

require 'selenium-webdriver'

class GogoDriver
  attr_accessor :driver

  def initialize
    @driver = Selenium::WebDriver.for(:chrome)
  end

  def go(url)
    @driver.navigate.to(url)
  end

  def reload
    @driver.navigate.refresh
  end

  def find(selector)
    @driver.find_element(css: selector)
  end

  def has?(selector)
    !!find(selector)
  rescue Selenium::WebDriver::Error::NoSuchElementError
    false
  end

  def has_text?(text)
    !!@driver.find_element({xpath: "//*[text()[contains(.,\"#{text}\")]]"})
  rescue Selenium::WebDriver::Error::NoSuchElementError
    false
  end

  def click(selector)
    has?(selector) ? find(selector).click : false
  end

  def submit
    $focus.submit if $focus
  end

  def method_missing(method, *args, &block)
    @driver.respond_to?(method) ? @driver.send(method, *args, &block) : super
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gogo_driver-0.1.0 lib/gogo_driver.rb