Class: Lyne::Session::Browser
Overview
sessionの維持 ページ遷移などのブラウザの動き
Instance Method Summary
collapse
#go_to_character_select, #go_to_charaselect, #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
20
21
|
# 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]}
setup_cache
end
|
Instance Method Details
#character_change(character_id) ⇒ Object
46
47
48
49
|
# File 'lib/lyne/session/browser.rb', line 46
def character_change character_id
go :charaselect
go_to_home character_id
end
|
#first_visit! ⇒ Object
29
30
31
32
|
# File 'lib/lyne/session/browser.rb', line 29
def first_visit!
return if @page.current_path == '/sc/home/'
character_select_url? ? go(:home) : visit(:home)
end
|
#go(type) ⇒ Object
34
35
36
|
# File 'lib/lyne/session/browser.rb', line 34
def go type
__send__("go_to_#{type}")
end
|
#html ⇒ Object
42
43
44
|
# File 'lib/lyne/session/browser.rb', line 42
def html
@page.html
end
|
#start! ⇒ Object
23
24
25
26
27
|
# File 'lib/lyne/session/browser.rb', line 23
def start!
go :welcome
go :character_select
self
end
|
#visit(type) ⇒ Object
38
39
40
|
# File 'lib/lyne/session/browser.rb', line 38
def visit type
__send__("visit_to_#{type}")
end
|