Class: RoRoSupport::Watir::Browser
- Inherits:
-
Object
- Object
- RoRoSupport::Watir::Browser
- Defined in:
- lib/roro_support/watir/browser.rb
Instance Method Summary collapse
- #batch(&blk) ⇒ Object
- #css(selector) ⇒ Object
-
#goto(url, options = {}) ⇒ Object
Get html from path eg get_html_from ‘baidu.com’ eg get_html_from ‘/home/users/testfile’.
- #next_page_url ⇒ Object
Instance Method Details
#batch(&blk) ⇒ Object
31 32 33 |
# File 'lib/roro_support/watir/browser.rb', line 31 def batch &blk self.instance_eval &blk end |
#css(selector) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/roro_support/watir/browser.rb', line 19 def css(selector) es = self.elements(css: selector) if es.size == 0 "Element #{selector} is not exist" return elsif es.size == 1 return es.first else es end end |
#goto(url, options = {}) ⇒ Object
Get html from path eg get_html_from ‘baidu.com’ eg get_html_from ‘/home/users/testfile’
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/roro_support/watir/browser.rb', line 8 def goto(url, = {}) if [:local] url = Format.url(url, local: true) else url = Format.url(url) end @driver.navigate.to url run_checkers self end |
#next_page_url ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/roro_support/watir/browser.rb', line 35 def next_page_url self.css('a').each do |a| reg = /(下一页)|(next)/i if a.text[reg] return a.attribute 'href' end end end |