Class: Common::DSL::Browser
- Inherits:
-
Watir::Browser
- Object
- Watir::Browser
- Common::DSL::Browser
- Defined in:
- lib/spider_rails/common/dsl.rb
Overview
Add a visit method to ::Watir::Browser
Instance Method Summary collapse
- #dsl_enable ⇒ Object
-
#initialize(browser = :phantomjs, *args) ⇒ Browser
constructor
A new instance of Browser.
- #visit(relative_url = nil, base_url = 'http://localhost:3000/') ⇒ Object
Constructor Details
#initialize(browser = :phantomjs, *args) ⇒ Browser
Returns a new instance of Browser.
11 12 13 |
# File 'lib/spider_rails/common/dsl.rb', line 11 def initialize(browser = :phantomjs, *args) super end |
Instance Method Details
#dsl_enable ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/spider_rails/common/dsl.rb', line 15 def dsl_enable @doc = Nokogiri::HTML.parse(self.html) ::String.class_variable_set(:@@doc, @doc) eval <<-RUBY class ::String def ctn if block_given? @@doc.css(self) &block else @@doc.css(self).each do |e| return e.text end end end end RUBY end |
#visit(relative_url = nil, base_url = 'http://localhost:3000/') ⇒ Object
7 8 9 |
# File 'lib/spider_rails/common/dsl.rb', line 7 def visit(relative_url = nil, base_url = 'http://localhost:3000/') goto("#{base_url}#{relative_url}") end |