Module: Calliper
- Defined in:
- lib/calliper.rb,
lib/calliper/page.rb,
lib/calliper/config.rb,
lib/calliper/server.rb,
lib/calliper/version.rb,
lib/calliper/webdriver.rb
Defined Under Namespace
Modules: Config, VERSION
Classes: Page, Server
Class Method Summary
collapse
Class Method Details
.driver ⇒ Object
FIXME: Only firefox quits correctly when used directly. There are no
problems when using a Selenium Server.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/calliper/webdriver.rb', line 6
def self.driver
@driver ||= if local_server_running?
Selenium::WebDriver.for(:remote,
url: "http://localhost:4444/wd/hub",
desired_capabilities: { browserName: Config.driver.to_s }
)
elsif Config.driver == :remote
Selenium::WebDriver.for(:remote,
url: Config.remote_url,
desired_capabilities: Config.capabilities
)
else
Selenium::WebDriver.for(Config.driver ? Config.driver.to_sym : :firefox)
end
end
|
.driver? ⇒ Boolean
31
32
33
|
# File 'lib/calliper/webdriver.rb', line 31
def self.driver?
!!@driver
end
|
.enable! ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/calliper.rb', line 9
def self.enable!
application = Config.application || (::Rails.application if defined?(::Rails))
raise "No application configured" unless application
logger = ::Rails.logger if defined?(::Rails)
@server = Server.new(application, logger: logger)
@server.start
end
|
.local_server_running? ⇒ Boolean
22
23
24
25
26
27
28
29
|
# File 'lib/calliper/webdriver.rb', line 22
def self.local_server_running?
begin
TCPSocket.new('localhost', 4444).close
true
rescue
false
end
end
|
.server ⇒ Object
19
20
21
|
# File 'lib/calliper.rb', line 19
def self.server
@server
end
|
.server? ⇒ Boolean
23
24
25
|
# File 'lib/calliper.rb', line 23
def self.server?
!!@server
end
|
.setup {|Config| ... } ⇒ Object
41
42
43
|
# File 'lib/calliper/config.rb', line 41
def self.setup
yield Config
end
|
.version ⇒ Object
2
3
4
|
# File 'lib/calliper/version.rb', line 2
def self.version
Gem::Version.new File.read(File.expand_path('../../../VERSION', __FILE__))
end
|