-
Notifications
You must be signed in to change notification settings - Fork 19
/
lambdatest.rb
50 lines (40 loc) · 1.48 KB
/
lambdatest.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'yaml'
require 'selenium/webdriver'
require 'capybara/cucumber'
# monkey patch to avoid reset sessions
class Capybara::Selenium::Driver < Capybara::Driver::Base
def reset!
if @browser
@browser.navigate.to('about:blank')
end
end
end
TASK_ID = (ENV['TASK_ID'] || 0).to_i
CONFIG_NAME = ENV['CONFIG_NAME'] || 'single'
CONFIG = YAML.load(File.read(File.join(File.dirname(__FILE__), "../../config/#{CONFIG_NAME}.config.yml")))
CONFIG['user'] = ENV['LT_USERNAME'] || CONFIG['user']
CONFIG['key'] = ENV['LT_ACCESS_KEY'] || CONFIG['key']
Capybara.register_driver :lambdatest do |app|
@caps = CONFIG['common_caps'].merge(CONFIG['browser_caps'][TASK_ID])
if (CONFIG_NAME=='jenkins')
puts ENV['LT_GRID_URL']
lt_browser = ENV['LT_BROWSER_NAME']
lt_os = ENV['LT_PLATFORM']
lt_browser_version = ENV['LT_BROWSER_VERSION']
lt_res = ENV['LT_RESOLUTION']
@caps={"browserName"=>lt_browser, "version"=>lt_browser_version, "platform"=>lt_os, "resolution"=>lt_res, "build"=>"capybara-lambdatest", "name"=>"single-Test-Jenkins","video"=>true, "network"=>true, "console"=>true, "visual"=>true }
Capybara::Selenium::Driver.new(app,
:browser => :remote,
:url => ENV['LT_GRID_URL'],
:desired_capabilities => @caps
)
else
Capybara::Selenium::Driver.new(app,
:browser => :remote,
:url => "https://#{CONFIG['user']}:#{CONFIG['key']}@#{CONFIG['server']}/wd/hub",
:desired_capabilities => @caps
)
end
end
Capybara.default_driver = :lambdatest
Capybara.run_server = false