howitzer 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -2
  3. data/.travis.yml +3 -3
  4. data/CHANGELOG.md +27 -11
  5. data/Gemfile +1 -0
  6. data/ISSUE_TEMPLATE.md +16 -0
  7. data/README.md +2 -1
  8. data/Rakefile +18 -2
  9. data/bin/howitzer +7 -6
  10. data/features/cli_help.feature +1 -1
  11. data/features/cli_new.feature +51 -11
  12. data/features/cli_update.feature +44 -4
  13. data/features/cli_version.feature +1 -1
  14. data/features/step_definitions/common_steps.rb +5 -0
  15. data/generators/base_generator.rb +30 -16
  16. data/generators/config/config_generator.rb +13 -3
  17. data/generators/config/templates/boot.rb +1 -1
  18. data/generators/config/templates/capybara.rb +2 -128
  19. data/generators/config/templates/default.yml +20 -3
  20. data/generators/config/templates/drivers/browserstack.rb +19 -0
  21. data/generators/config/templates/drivers/crossbrowsertesting.rb +25 -0
  22. data/generators/config/templates/drivers/headless_chrome.rb +16 -0
  23. data/generators/config/templates/drivers/phantomjs.rb +20 -0
  24. data/generators/config/templates/drivers/poltergeist.rb +11 -0
  25. data/generators/config/templates/drivers/sauce.rb +21 -0
  26. data/generators/config/templates/drivers/selenium.rb +24 -0
  27. data/generators/config/templates/drivers/selenium_grid.rb +27 -0
  28. data/generators/config/templates/drivers/testingbot.rb +20 -0
  29. data/generators/config/templates/drivers/webkit.rb +6 -0
  30. data/generators/cucumber/cucumber_generator.rb +2 -2
  31. data/generators/cucumber/templates/cucumber.rake +0 -8
  32. data/generators/cucumber/templates/env.rb +1 -1
  33. data/generators/cucumber/templates/transformers.rb +11 -25
  34. data/generators/emails/emails_generator.rb +2 -2
  35. data/generators/emails/templates/example_email.rb +1 -1
  36. data/generators/prerequisites/prerequisites_generator.rb +3 -3
  37. data/generators/prerequisites/templates/base.rb +1 -1
  38. data/generators/prerequisites/templates/{factory_girl.rb → factory_bot.rb} +6 -6
  39. data/generators/prerequisites/templates/users.rb +1 -1
  40. data/generators/root/root_generator.rb +2 -2
  41. data/generators/root/templates/.rubocop.yml +2 -2
  42. data/generators/root/templates/Gemfile.erb +14 -18
  43. data/generators/rspec/rspec_generator.rb +2 -2
  44. data/generators/rspec/templates/spec_helper.rb +1 -1
  45. data/generators/tasks/tasks_generator.rb +2 -2
  46. data/generators/turnip/templates/spec_helper.rb +1 -1
  47. data/generators/turnip/turnip_generator.rb +2 -2
  48. data/generators/web/web_generator.rb +2 -2
  49. data/howitzer.gemspec +3 -1
  50. data/lib/howitzer/capybara_helpers.rb +25 -8
  51. data/lib/howitzer/gmail_api.rb +7 -0
  52. data/lib/howitzer/gmail_api/client.rb +22 -0
  53. data/lib/howitzer/mail_adapters/gmail.rb +93 -0
  54. data/lib/howitzer/mail_adapters/mailgun.rb +2 -2
  55. data/lib/howitzer/mail_adapters/mailtrap.rb +105 -0
  56. data/lib/howitzer/mailtrap_api.rb +7 -0
  57. data/lib/howitzer/mailtrap_api/client.rb +52 -0
  58. data/lib/howitzer/version.rb +1 -1
  59. data/lib/howitzer/web/page.rb +13 -1
  60. data/lib/howitzer/web/page_dsl.rb +1 -1
  61. data/spec/config/custom.yml +1 -1
  62. data/spec/spec_helper.rb +1 -0
  63. data/spec/unit/generators/base_generator_spec.rb +23 -12
  64. data/spec/unit/generators/config_generator_spec.rb +27 -6
  65. data/spec/unit/generators/cucumber_generator_spec.rb +8 -8
  66. data/spec/unit/generators/emails_generator_spec.rb +2 -2
  67. data/spec/unit/generators/prerequisites_generator_spec.rb +7 -7
  68. data/spec/unit/generators/root_generator_spec.rb +25 -22
  69. data/spec/unit/generators/rspec_generator_spec.rb +4 -4
  70. data/spec/unit/generators/tasks_generator_spec.rb +2 -2
  71. data/spec/unit/generators/turnip_generator_spec.rb +7 -7
  72. data/spec/unit/generators/web_generator_spec.rb +3 -3
  73. data/spec/unit/lib/capybara_helpers_spec.rb +2 -1
  74. data/spec/unit/lib/gmail_api/client_spec.rb +26 -0
  75. data/spec/unit/lib/mail_adapters/gmail_spec.rb +128 -0
  76. data/spec/unit/lib/mail_adapters/mailgun_spec.rb +13 -18
  77. data/spec/unit/lib/mail_adapters/mailtrap_spec.rb +130 -0
  78. data/spec/unit/lib/mailgun_api/client_spec.rb +31 -9
  79. data/spec/unit/lib/mailtrap_api/client_spec.rb +67 -0
  80. data/spec/unit/lib/web/page_spec.rb +30 -1
  81. metadata +63 -8
  82. data/features/support/transformers.rb +0 -3
  83. data/spec/support/mailgun_unit_client.rb +0 -68
@@ -2,7 +2,7 @@ Feature: Howitzer CLI Version
2
2
 
3
3
  Scenario Outline: Run with version global option
4
4
  When I run `howitzer <option>`
5
- Then the output should contain exactly:
5
+ Then the output should be exactly:
6
6
  """
7
7
  howitzer version <HOWITZER_VERSION>
8
8
 
@@ -27,3 +27,8 @@ Given /^created old howitzer project based on turnip$/ do
27
27
  FileUtils.move(Dir.glob("#{expand_path('.')}/test_automation/*"), expand_path('.'))
28
28
  FileUtils.remove_dir File.join(expand_path('.'), 'test_automation'), true
29
29
  end
30
+
31
+ Then 'the output should be exactly:' do |text|
32
+ text.gsub!('<HOWITZER_VERSION>', Howitzer::VERSION)
33
+ step 'the output should contain exactly:', text
34
+ end
@@ -1,3 +1,4 @@
1
+ require 'colorized_string'
1
2
  require 'fileutils'
2
3
  require 'erb'
3
4
  require 'ostruct'
@@ -29,7 +30,7 @@ module Howitzer
29
30
  end
30
31
 
31
32
  def print_banner
32
- logger.puts banner unless banner.empty?
33
+ logger.puts ColorizedString.new(banner.chomp).light_cyan unless banner.empty?
33
34
  end
34
35
 
35
36
  def print_info(data)
@@ -41,7 +42,7 @@ module Howitzer
41
42
  end
42
43
 
43
44
  def puts_error(data)
44
- logger.puts " ERROR: #{data}"
45
+ logger.puts ColorizedString.new(" ERROR: #{data}").red
45
46
  end
46
47
  end
47
48
 
@@ -88,7 +89,8 @@ module Howitzer
88
89
  copy_templates_file_exist(data, destination_path, source_path)
89
90
  else
90
91
  write_template(destination_path, source_path)
91
- puts_info "Added template '#{data[:source]}' with params '#{@options}' to destination '#{data[:destination]}'"
92
+ puts_info "#{ColorizedString.new('Added').light_green} template '#{data[:source]}' with"\
93
+ " params '#{@options}' to destination '#{data[:destination]}'"
92
94
  end
93
95
  end
94
96
  end
@@ -103,14 +105,13 @@ module Howitzer
103
105
  end
104
106
 
105
107
  def copy_with_path(data)
106
- src = source_path(data[:source])
107
- dst = dest_path(data[:destination])
108
+ src, dst = get_source_and_destination(data)
108
109
  FileUtils.mkdir_p(File.dirname(dst))
109
110
  if File.exist?(dst)
110
111
  copy_with_path_file_exist(data, src, dst)
111
112
  else
112
113
  FileUtils.cp(src, dst)
113
- puts_info("Added '#{data[:destination]}' file")
114
+ puts_info("#{ColorizedString.new('Added').light_green} '#{data[:destination]}' file")
114
115
  end
115
116
  rescue => e
116
117
  puts_error("Impossible to create '#{data[:destination]}' file. Reason: #{e.message}")
@@ -118,24 +119,37 @@ module Howitzer
118
119
 
119
120
  def write_template(dest_path, source_path)
120
121
  File.open(dest_path, 'w+') do |f|
121
- f.write(ERB.new(File.open(source_path, 'r').read).result(OpenStruct.new(@options).instance_eval { binding }))
122
+ f.write(ERB.new(File.open(source_path, 'r').read, nil, '-')
123
+ .result(OpenStruct.new(@options).instance_eval { binding }))
122
124
  end
123
125
  end
124
126
 
125
127
  private
126
128
 
129
+ def get_source_and_destination(data)
130
+ [source_path(data[:source]), dest_path(data[:destination])]
131
+ end
132
+
133
+ def conflict_file_msg(data)
134
+ ColorizedString.new("Conflict with '#{data[:destination]}' file").yellow
135
+ end
136
+
137
+ def overwrite_file_msg(data)
138
+ ColorizedString.new(" Overwrite '#{data[:destination]}' file? [Yn]:").yellow
139
+ end
140
+
127
141
  def copy_templates_file_exist(data, destination_path, source_path)
128
- puts_info("Conflict with '#{data[:destination]}' template")
129
- print_info(" Overwrite '#{data[:destination]}' template? [Yn]:")
142
+ puts_info(ColorizedString.new("Conflict with '#{data[:destination]}' template").yellow)
143
+ print_info(ColorizedString.new(" Overwrite '#{data[:destination]}' template? [Yn]:").yellow)
130
144
  copy_templates_overwrite(gets.strip.downcase, data, destination_path, source_path)
131
145
  end
132
146
 
133
147
  def copy_with_path_file_exist(data, source, destination)
134
148
  if FileUtils.identical?(source, destination)
135
- puts_info("Identical '#{data[:destination]}' file")
149
+ puts_info("#{ColorizedString.new('Identical').light_green} '#{data[:destination]}' file")
136
150
  else
137
- puts_info("Conflict with '#{data[:destination]}' file")
138
- print_info(" Overwrite '#{data[:destination]}' file? [Yn]:")
151
+ puts_info(conflict_file_msg(data))
152
+ print_info(overwrite_file_msg(data))
139
153
  copy_with_path_overwrite(gets.strip.downcase, data, source, destination)
140
154
  end
141
155
  end
@@ -144,9 +158,9 @@ module Howitzer
144
158
  case answer
145
159
  when 'y'
146
160
  write_template(destination_path, source_path)
147
- puts_info(" Forced '#{data[:destination]}' template")
161
+ puts_info(" #{ColorizedString.new('Forced').light_green} '#{data[:destination]}' template")
148
162
  when 'n'
149
- puts_info(" Skipped '#{data[:destination]}' template")
163
+ puts_info(" #{ColorizedString.new('Skipped').light_black} '#{data[:destination]}' template")
150
164
  else nil
151
165
  end
152
166
  end
@@ -155,9 +169,9 @@ module Howitzer
155
169
  case answer
156
170
  when 'y'
157
171
  FileUtils.cp(source, destination)
158
- puts_info(" Forced '#{data[:destination]}' file")
172
+ puts_info(" #{ColorizedString.new('Forced').light_green} '#{data[:destination]}' file")
159
173
  when 'n' then
160
- puts_info(" Skipped '#{data[:destination]}' file")
174
+ puts_info(" #{ColorizedString.new('Skipped').light_black} '#{data[:destination]}' file")
161
175
  else nil
162
176
  end
163
177
  end
@@ -8,16 +8,26 @@ module Howitzer
8
8
  { source: 'boot.rb', destination: 'config/boot.rb' },
9
9
  { source: 'custom.yml', destination: 'config/custom.yml' },
10
10
  { source: 'capybara.rb', destination: 'config/capybara.rb' },
11
- { source: 'default.yml', destination: 'config/default.yml' }
11
+ { source: 'default.yml', destination: 'config/default.yml' },
12
+ { source: 'drivers/browserstack.rb', destination: 'config/drivers/browserstack.rb' },
13
+ { source: 'drivers/crossbrowsertesting.rb', destination: 'config/drivers/crossbrowsertesting.rb' },
14
+ { source: 'drivers/headless_chrome.rb', destination: 'config/drivers/headless_chrome.rb' },
15
+ { source: 'drivers/phantomjs.rb', destination: 'config/drivers/phantomjs.rb' },
16
+ { source: 'drivers/poltergeist.rb', destination: 'config/drivers/poltergeist.rb' },
17
+ { source: 'drivers/sauce.rb', destination: 'config/drivers/sauce.rb' },
18
+ { source: 'drivers/selenium.rb', destination: 'config/drivers/selenium.rb' },
19
+ { source: 'drivers/selenium_grid.rb', destination: 'config/drivers/selenium_grid.rb' },
20
+ { source: 'drivers/testingbot.rb', destination: 'config/drivers/testingbot.rb' },
21
+ { source: 'drivers/webkit.rb', destination: 'config/drivers/webkit.rb' }
12
22
  ] }
13
23
  end
14
24
 
15
25
  protected
16
26
 
17
27
  def banner
18
- <<-EOF
28
+ <<-MSG
19
29
  * Config files generation ...
20
- EOF
30
+ MSG
21
31
  end
22
32
  end
23
33
  end
@@ -8,7 +8,7 @@ Dir[
8
8
  './web/sections/**/*.rb',
9
9
  './web/pages/**/*.rb',
10
10
  './prerequisites/models/**/*.rb',
11
- './prerequisites/factory_girl.rb'
11
+ './prerequisites/factory_bot.rb'
12
12
  ].each { |f| require f }
13
13
 
14
14
  String.send(:include, Howitzer::Utils::StringExtensions)
@@ -7,6 +7,7 @@ HOWITZER_KNOWN_DRIVERS = %i[
7
7
  sauce
8
8
  testingbot
9
9
  browserstack
10
+ crossbrowsertesting
10
11
  headless_chrome
11
12
  ].freeze
12
13
 
@@ -36,135 +37,8 @@ module CapybaraHelpers
36
37
  extend Howitzer::CapybaraHelpers
37
38
  end
38
39
 
39
- # :selenium driver
40
+ require_relative "drivers/#{Howitzer.driver}"
40
41
 
41
- Capybara.register_driver :selenium do |app|
42
- params = { browser: Howitzer.selenium_browser.to_s.to_sym }
43
- if CapybaraHelpers.ff_browser?
44
- ff_profile = Selenium::WebDriver::Firefox::Profile.new.tap do |profile|
45
- profile['network.http.phishy-userpass-length'] = 255
46
- profile['browser.safebrowsing.malware.enabled'] = false
47
- profile['network.automatic-ntlm-auth.allow-non-fqdn'] = true
48
- profile['network.ntlm.send-lm-response'] = true
49
- profile['network.automatic-ntlm-auth.trusted-uris'] = Howitzer.app_host
50
- end
51
- params[:profile] = ff_profile
52
- end
53
- Capybara::Selenium::Driver.new app, params
54
- end
55
-
56
- # :headless_chrome driver
57
-
58
- Capybara.register_driver :headless_chrome do |app|
59
- startup_flags = ['--headless']
60
- startup_flags << '-start-maximized' if Howitzer.maximized_window
61
- startup_flags.concat(Howitzer.headless_chrome_flags.split(/\s*,\s*/)) if Howitzer.headless_chrome_flags
62
- params = { browser: :chrome, switches: startup_flags }
63
- Capybara::Selenium::Driver.new app, params
64
- end
65
-
66
- # :webkit driver
67
-
68
- if Howitzer.driver.to_sym == :webkit
69
- CapybaraHelpers.load_driver_gem!(:webkit, 'capybara-webkit', 'capybara-webkit')
70
- Capybara::Webkit.configure do |config|
71
- config.allow_url(Howitzer.app_host)
72
- end
73
- end
74
-
75
- # :poltergeist driver
76
-
77
- if Howitzer.driver.to_sym == :poltergeist
78
- CapybaraHelpers.load_driver_gem!(:poltergeist, 'capybara/poltergeist', 'poltergeist')
79
-
80
- Capybara.register_driver :poltergeist do |app|
81
- Capybara::Poltergeist::Driver.new(
82
- app,
83
- js_errors: !Howitzer.phantom_ignore_js_errors,
84
- phantomjs_options: ["--ignore-ssl-errors=#{Howitzer.phantom_ignore_ssl_errors ? 'yes' : 'no'}"]
85
- )
86
- end
87
- end
88
-
89
- # :phantomjs driver
90
-
91
- Capybara.register_driver :phantomjs do |app|
92
- Capybara::Selenium::Driver.new(
93
- app, browser: :phantomjs,
94
- desired_capabilities: {
95
- javascript_enabled: !Howitzer.phantom_ignore_js_errors
96
- },
97
- driver_opts: {
98
- args: ["--ignore-ssl-errors=#{Howitzer.phantom_ignore_ssl_errors ? 'yes' : 'no'}"]
99
- }
100
- )
101
- end
102
-
103
- # :sauce driver
104
-
105
- Capybara.register_driver :sauce do |app|
106
- caps = CapybaraHelpers.required_cloud_caps.merge(
107
- maxDuration: Howitzer.cloud_max_duration,
108
- idleTimeout: Howitzer.cloud_sauce_idle_timeout,
109
- recordScreenshots: Howitzer.cloud_sauce_record_screenshots,
110
- videoUploadOnPass: Howitzer.cloud_sauce_video_upload_on_pass
111
- )
112
- url = "http://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@ondemand.saucelabs.com:80/wd/hub"
113
- CapybaraHelpers.cloud_driver(app, caps, url)
114
- end
115
-
116
- # :testingbot driver
117
-
118
- Capybara.register_driver :testingbot do |app|
119
- caps = CapybaraHelpers.required_cloud_caps.merge(
120
- maxduration: Howitzer.cloud_max_duration,
121
- idletimeout: Howitzer.cloud_testingbot_idle_timeout,
122
- screenshot: Howitzer.cloud_testingbot_screenshots
123
- )
124
- url = "http://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@hub.testingbot.com/wd/hub"
125
- CapybaraHelpers.cloud_driver(app, caps, url)
126
- end
127
-
128
- # :browserstack driver
129
-
130
- Capybara.register_driver :browserstack do |app|
131
- caps = CapybaraHelpers.required_cloud_caps.merge(
132
- project: Howitzer.cloud_bstack_project,
133
- build: Howitzer.cloud_bstack_build
134
- )
135
- caps[:resolution] = Howitzer.cloud_bstack_resolution if Howitzer.cloud_bstack_resolution.present?
136
- caps[:device] = Howitzer.cloud_bstack_mobile_device if Howitzer.cloud_bstack_mobile_device.present?
137
- url = "http://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@hub.browserstack.com/wd/hub"
138
- CapybaraHelpers.cloud_driver(app, caps, url)
139
- end
140
-
141
- # :selenium_grid driver
142
-
143
- Capybara.register_driver :selenium_grid do |app|
144
- caps = if CapybaraHelpers.ie_browser?
145
- Selenium::WebDriver::Remote::Capabilities.internet_explorer
146
- elsif CapybaraHelpers.ff_browser?
147
- Selenium::WebDriver::Remote::Capabilities.firefox
148
- elsif CapybaraHelpers.chrome_browser?
149
- Selenium::WebDriver::Remote::Capabilities.chrome
150
- elsif CapybaraHelpers.safari_browser?
151
- Selenium::WebDriver::Remote::Capabilities.safari
152
- else
153
- raise Howitzer::UnknownBrowserError, "Unknown '#{Howitzer.selenium_browser}' selenium_browser." \
154
- ' Check your settings, it should be one of' \
155
- ' [:ie, :iexplore, :ff, :firefox, :chrome, safari]'
156
- end
157
-
158
- Capybara::Selenium::Driver.new(app, browser: :remote, url: Howitzer.selenium_hub_url, desired_capabilities: caps)
159
- end
160
-
161
- Capybara.save_path = Howitzer.log_dir
162
- Capybara::Screenshot.register_driver(:phantomjs) do |driver, path|
163
- driver.browser.save_screenshot path
164
- end
165
- Capybara::Screenshot.register_driver(:headless_chrome) do |driver, path|
166
- driver.browser.save_screenshot path
167
- end
168
42
  Capybara::Screenshot.append_timestamp = false
169
43
  Capybara::Screenshot.register_filename_prefix_formatter(:default) do
170
44
  "capybara-screenshot-#{Gen.serial}"
@@ -17,11 +17,12 @@
17
17
  ###########################################################
18
18
  # TEST ENVIRONMENTS SETTINGS #
19
19
  ###########################################################
20
+ user_agent: # if blank, then default agent
20
21
  page_load_idle_timeout: 20
21
22
  maximized_window: true # Specify maximized browser window size
22
23
 
23
24
  # Specify one of the following drivers: selenium, selenium_grid, webkit, poltergeist, phantomjs, sauce,
24
- # testingbot, browserstack, headless_chrome
25
+ # testingbot, browserstack, crossbrowsertesting, headless_chrome
25
26
  driver: phantomjs
26
27
 
27
28
  # -Selenium-
@@ -30,7 +31,7 @@
30
31
 
31
32
  # -Headless Chrome-
32
33
  # List of available flags (http://peter.sh/experiments/chromium-command-line-switches/)
33
- headless_chrome_flags: "--window-size=1920x1080, --disable-gpu"
34
+ headless_chrome_flags: "window-size=1920x1080, disable-gpu"
34
35
 
35
36
  # -Selenium Grid-
36
37
  selenium_hub_url: "http://example.com:4444/wd/hub"
@@ -68,6 +69,14 @@
68
69
  cloud_bstack_build: 'v1'
69
70
  cloud_bstack_mobile_device:
70
71
 
72
+ # -CrossBrowserTesting (https://app.crossbrowsertesting.com/selenium/run)
73
+ cloud_cbt_name: 'Howitzer Example'
74
+ cloud_cbt_build: '1.0'
75
+ cloud_cbt_os_api_name: 'Win7x64-C1'
76
+ cloud_cbt_screen_resolution: '1024x768'
77
+ cloud_cbt_record_video: 'true'
78
+ cloud_cbt_record_network: 'true'
79
+
71
80
  ###########################################################
72
81
  # CAPYBARA SETTINGS #
73
82
  ###########################################################
@@ -88,8 +97,16 @@
88
97
  ###########################################################
89
98
  mail_adapter: mailgun
90
99
  mail_wait_time: 60
100
+ mail_sleep_time: 3
91
101
 
92
102
  # -Mailgun- (http://www.mailgun.com/)
93
103
  mailgun_key: mailgun_account_private_key
94
104
  mailgun_domain: mailgun_domain_with_stored_method
95
- mailgun_sleep_time: 3
105
+
106
+ # -Mailtrap- (https://mailtrap.io/)
107
+ mailtrap_api_token: private_api_key
108
+ mailtrap_inbox_id: inbox_id
109
+
110
+ # -Gmail-
111
+ gmail_login: gmail_address
112
+ gmail_password: gmail_password
@@ -0,0 +1,19 @@
1
+ Capybara.register_driver :browserstack do |app|
2
+ caps = CapybaraHelpers.required_cloud_caps.merge(
3
+ project: Howitzer.cloud_bstack_project,
4
+ build: Howitzer.cloud_bstack_build
5
+ )
6
+ caps[:resolution] = Howitzer.cloud_bstack_resolution if Howitzer.cloud_bstack_resolution.present?
7
+ caps[:device] = Howitzer.cloud_bstack_mobile_device if Howitzer.cloud_bstack_mobile_device.present?
8
+ if Howitzer.user_agent.present?
9
+ if CapybaraHelpers.chrome_browser?
10
+ caps['chromeOptions'] = { 'args' => ["--user-agent=#{Howitzer.user_agent}"] }
11
+ elsif CapybaraHelpers.ff_browser?
12
+ profile = Selenium::WebDriver::Firefox::Profile.new
13
+ profile['general.useragent.override'] = Howitzer.user_agent
14
+ caps[:firefox_profile] = profile
15
+ end
16
+ end
17
+ url = "http://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@hub.browserstack.com/wd/hub"
18
+ CapybaraHelpers.cloud_driver(app, caps, url)
19
+ end
@@ -0,0 +1,25 @@
1
+ # :crossbrowsertesting driver
2
+
3
+ Capybara.register_driver :crossbrowsertesting do |app|
4
+ caps = {}
5
+ caps['name'] = Howitzer.cloud_cbt_name
6
+ caps['build'] = Howitzer.cloud_cbt_build
7
+ caps['browser_api_name'] = Howitzer.cloud_browser_name + Howitzer.cloud_browser_version.to_s
8
+ caps['os_api_name'] = Howitzer.cloud_cbt_os_api_name
9
+ caps['screen_resolution'] = Howitzer.cloud_cbt_screen_resolution
10
+ caps['record_video'] = Howitzer.cloud_cbt_record_video
11
+ caps['record_network'] = Howitzer.cloud_cbt_record_network
12
+ caps['max_duration'] = Howitzer.cloud_max_duration
13
+ if Howitzer.user_agent.present?
14
+ if CapybaraHelpers.chrome_browser?
15
+ caps['chromeOptions'] = { 'args' => ["--user-agent=#{Howitzer.user_agent}"] }
16
+ elsif CapybaraHelpers.ff_browser?
17
+ profile = Selenium::WebDriver::Firefox::Profile.new
18
+ profile['general.useragent.override'] = Howitzer.user_agent
19
+ caps[:firefox_profile] = profile
20
+ end
21
+ end
22
+ url = "http://#{CGI.escape(Howitzer.cloud_auth_login)}:#{Howitzer.cloud_auth_pass}"\
23
+ '@hub.crossbrowsertesting.com/wd/hub'
24
+ CapybaraHelpers.cloud_driver(app, caps, url)
25
+ end
@@ -0,0 +1,16 @@
1
+ # :headless_chrome driver
2
+
3
+ Capybara.register_driver :headless_chrome do |app|
4
+ startup_flags = ['headless']
5
+ startup_flags << 'start-fullscreen' if Howitzer.maximized_window
6
+ startup_flags << "user-agent=#{Howitzer.user_agent}" if Howitzer.user_agent.present?
7
+ startup_flags.concat(Howitzer.headless_chrome_flags.split(/\s*,\s*/)) if Howitzer.headless_chrome_flags
8
+ options = Selenium::WebDriver::Chrome::Options.new(args: startup_flags)
9
+ params = { browser: :chrome, options: options }
10
+ Capybara::Selenium::Driver.new app, params
11
+ end
12
+
13
+ Capybara.save_path = Howitzer.log_dir
14
+ Capybara::Screenshot.register_driver(:headless_chrome) do |driver, path|
15
+ driver.browser.save_screenshot path
16
+ end
@@ -0,0 +1,20 @@
1
+ # :phantomjs driver
2
+
3
+ Capybara.register_driver :phantomjs do |app|
4
+ caps = {
5
+ javascript_enabled: !Howitzer.phantom_ignore_js_errors
6
+ }
7
+ caps['phantomjs.page.settings.userAgent'] = "WebKit #{Howitzer.user_agent}" if Howitzer.user_agent.present?
8
+ Capybara::Selenium::Driver.new(
9
+ app, browser: :phantomjs,
10
+ desired_capabilities: caps,
11
+ driver_opts: {
12
+ args: ["--ignore-ssl-errors=#{Howitzer.phantom_ignore_ssl_errors ? 'yes' : 'no'}"]
13
+ }
14
+ )
15
+ end
16
+
17
+ Capybara.save_path = Howitzer.log_dir
18
+ Capybara::Screenshot.register_driver(:phantomjs) do |driver, path|
19
+ driver.browser.save_screenshot path
20
+ end