Sha256: ea1289f9b3872e7ec05f17afa19c282d38dff6a74ff6d0ccd571debd37925933

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

module WatirSplash
  module Page
    class Base
      include SpecHelper

      class << self
        def url url
          @url = url
        end

        def _url
          @url || "about:blank"
        end
      end

      def initialize(browser=nil)
        if browser
          @browser = browser 
        else
          @browser = WatirSplash::Browser.exists? ? WatirSplash::Browser.current : (WatirSplash::Browser.current = WatirSplash::Browser.new)
          @browser.goto self.class._url
        end
      end

      def redirect_to page, browser=nil
        page.new browser || WatirSplash::Browser.current
      end      

      def modify element, methodz
        methodz.each_pair do |meth, return_value|
          element.instance_eval do 
            singleton = class << self; self end

            singleton.send :alias_method, "__#{meth}", meth if respond_to? meth
            singleton.send :define_method, meth do |*args|
              self.send("__#{meth}", *args) if respond_to? "__#{meth}"
              return_value.call(*args)
            end
          end
        end
        element
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watirsplash-2.4.4 lib/watirsplash/page/base.rb
watirsplash-2.4.3 lib/watirsplash/page/base.rb