Class: Lyne::Session::Browser
Overview
sessionの維持 ページ遷移などのブラウザの動き
Instance Method Summary
collapse
#go_to_character_select, #go_to_home, #go_to_welcome, #visit_to_home
Constructor Details
#initialize(options) ⇒ Browser
Returns a new instance of Browser.
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/lyne/session/browser.rb', line 7
def initialize options
@options = options.reverse_merge(default_options)
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, {
js_errors: false,
timeout: 1000,
phantomjs: @options[:phantomjs]
})
end
Capybara.default_selector = :xpath
@page = Capybara::Session.new(:poltergeist)
@page.driver. = {'User-Agent' => @options[:user_agent]}
end
|
Instance Method Details
#first_visit! ⇒ Object
27
28
29
30
|
# File 'lib/lyne/session/browser.rb', line 27
def first_visit!
return if @page.current_path == '/sc/home/'
character_select_url? ? go(:home) : visit(:home)
end
|
#go(type) ⇒ Object
32
33
34
|
# File 'lib/lyne/session/browser.rb', line 32
def go type
__send__("go_to_#{type}")
end
|
#html ⇒ Object
40
41
42
|
# File 'lib/lyne/session/browser.rb', line 40
def html
@page.html
end
|
#start! ⇒ Object
21
22
23
24
25
|
# File 'lib/lyne/session/browser.rb', line 21
def start!
go :welcome
go :character_select
self
end
|
#visit(type) ⇒ Object
36
37
38
|
# File 'lib/lyne/session/browser.rb', line 36
def visit type
__send__("visit_to_#{type}")
end
|