automation_helpers 4.1.1 → 5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 154b3a0f5fc399e0c379455a963dd13d3094be200957ecff1740dccfdd75418c
4
- data.tar.gz: ba4e03604da108f8a68661f3879f69180c4f35b27796cc41660a4ee51d25f47f
3
+ metadata.gz: ac74d1da46721b813cf048c83f2c12393132af015ac62fbb38830f8c828550fb
4
+ data.tar.gz: 35342f56615fd96850664dd2c7fd1f6f662e88cf5c5c830ead0ade741fe3632e
5
5
  SHA512:
6
- metadata.gz: 7fc83981d84eabd3887d096b0ab415598aa5243b9027b6b0a8e1de2fb76520346db275fd9f51ea10642946646ae0319f214ab30af76fcc218fbe56c629c17165
7
- data.tar.gz: 6cf8cf6feb9820e8b781d5830557d0d4aaf2ad1e5d370b2db1e0fb7ef8198a5fe012f67ae5d30184068eabb45cfeebaa053f6926cc99955239f5cdfe0cc378e3
6
+ metadata.gz: ed219f7a15fdafda73b3fa56950fac854347ecb5f672e4e28475828d45c847c777d8c5534cecf5e6ee12ea168bdc6dfb96114ef386367298a4be8d5b700eb47a
7
+ data.tar.gz: 15874df9f590c88fa7981405f1618abedb3110dcb9ba52749835c993033ae8bb1b792e7be6afdf6efef751c87d37952bf6d5c3a0abae9ea1fb293513d9780be6
@@ -26,7 +26,6 @@ module AutomationHelpers
26
26
  when :firefox; then firefox_capabilities
27
27
  when :internet_explorer; then internet_explorer_capabilities
28
28
  when :ios; then ios_capabilities(device_options)
29
- when :safari; then safari_capabilities
30
29
  else {}
31
30
  end
32
31
  end
@@ -83,6 +82,7 @@ module AutomationHelpers
83
82
 
84
83
  def android_appium_version(android_version)
85
84
  case android_version.to_f
85
+ when 12..; then '1.22.0'
86
86
  when 10..; then '1.21.0'
87
87
  when 9..; then '1.20.2'
88
88
  else raise ArgumentError, "Your Android Version is too low. Please don't use lower than Android Pie (9)."
@@ -91,20 +91,12 @@ module AutomationHelpers
91
91
 
92
92
  def ios_appium_version(ios_version)
93
93
  case ios_version.to_f
94
+ when 14..; then '1.22.0'
94
95
  when 13..; then '1.21.0'
95
96
  when 12..; then '1.20.2'
96
- when 11..; then '1.16.0'
97
- else raise ArgumentError, "Your iOS Version is too low. Please don't use lower than iOS 11."
97
+ else raise ArgumentError, "Your iOS Version is too low. Please don't use lower than iOS 12."
98
98
  end
99
99
  end
100
-
101
- def safari_capabilities
102
- AutomationHelpers.logger.warn('Altering Browser Name request to alleviate Capybara failure with STP.')
103
-
104
- {
105
- 'browserName' => 'Safari Technology Preview'
106
- }
107
- end
108
100
  end
109
101
  end
110
102
  end
@@ -31,31 +31,16 @@ module AutomationHelpers
31
31
  app,
32
32
  browser: browser,
33
33
  service: service,
34
- capabilities: capabilities
34
+ options: options
35
35
  )
36
36
  end
37
37
  end
38
38
 
39
- # @return [Array]
40
- #
41
- # The order of these capabilities is important because in the internal configuration
42
- # for the driver; these 2 objects are merged (And both will contain a browserName)
43
- # as such we need to ensure the browserName we manually set in `desired_capabilities`
44
- # is retained as this is the one required by safari
45
- def capabilities
46
- if safari?
47
- [options, desired_capabilities]
48
- else
49
- [desired_capabilities, options]
50
- end
51
- end
52
-
53
39
  private
54
40
 
55
- # This is required to make local drivers work exclusively with Safari TP
56
- # This is required in V13 of Safari as the driver there is notoriously flaky
57
- # In V12 it doesn't hinder it
58
- # Safari V11 is unsupported.
41
+ # This is required to make local drivers work with Safari TP
42
+ # This is required in V13+ of Safari as the driver there is notoriously flaky
43
+ # Safari V11/V12 is unsupported
59
44
  def service
60
45
  return unless safari?
61
46
 
@@ -63,19 +48,6 @@ module AutomationHelpers
63
48
  ::Selenium::WebDriver::Service.safari(args: ['--diagnose'])
64
49
  end
65
50
 
66
- # This is required because Capybara and Safari aren't quite sure what the difference
67
- # is between the two browsers. So to compensate an illegal browserName value is
68
- # set that allows easy distinction between the two browsers
69
- #
70
- # NB: Whilst using Safari TP this is required.
71
- def desired_capabilities
72
- if safari?
73
- Capabilities.for(:safari)
74
- else
75
- ::Selenium::WebDriver::Remote::Capabilities.new
76
- end
77
- end
78
-
79
51
  def options
80
52
  Options.for(browser)
81
53
  end
@@ -11,29 +11,41 @@ module AutomationHelpers
11
11
  #
12
12
  # #### Initial setup options
13
13
  #
14
- # - **ENV["HEADLESS"]** (optional) - Whether you want your browser to run headless or not
14
+ # - **ENV["HEADLESS"]** (optional) - Whether you want your browser (only applicable ones) to run headless or not
15
15
  class Options
16
16
  class << self
17
17
  # @return [Selenium::Webdriver::Options]
18
18
  #
19
19
  # Returns the Options payload relevant to the browser specified to be passed to the driver instantiation
20
20
  def for(browser)
21
- initial_options(browser).tap { |opts| opts.headless! if headless? }
22
- end
23
-
24
- private
25
-
26
- def initial_options(browser)
27
21
  case browser
28
- when :chrome; then ::Selenium::WebDriver::Chrome::Options.new
29
- when :firefox; then ::Selenium::WebDriver::Firefox::Options.new(log_level: 'trace')
30
- when :edge; then ::Selenium::WebDriver::Edge::Options.new
31
- when :safari; then ::Selenium::WebDriver::Safari::Options.new(automatic_inspection: true)
22
+ when :chrome; then chrome_options
23
+ when :firefox; then firefox_options
24
+ when :edge; then edge_options
25
+ when :safari; then safari_options
32
26
  when :internet_explorer; then internet_explorer_options
33
27
  else {}
34
28
  end
35
29
  end
36
30
 
31
+ private
32
+
33
+ def chrome_options
34
+ ::Selenium::WebDriver::Chrome::Options.new.tap { |opts| opts.add_argument('--headless=new') if headless? }
35
+ end
36
+
37
+ def firefox_options
38
+ ::Selenium::WebDriver::Firefox::Options.new(log_level: 'trace').tap { |opts| opts.add_argument('-headless') if headless? }
39
+ end
40
+
41
+ def edge_options
42
+ ::Selenium::WebDriver::Edge::Options.new.tap { |opts| opts.add_argument('--headless=new') if headless? }
43
+ end
44
+
45
+ def safari_options
46
+ ::Selenium::WebDriver::Safari::Options.new(automatic_inspection: true)
47
+ end
48
+
37
49
  # Constantly fire mouseOver events on click actions (Should help mitigate flaky clicks)
38
50
  def internet_explorer_options
39
51
  ::Selenium::WebDriver::IE::Options.new(persistent_hover: true).tap do |opts|
@@ -7,7 +7,7 @@ module AutomationHelpers
7
7
  module Drivers
8
8
  module V4
9
9
  #
10
- # The Remote Driver that will connect to a dockerised self-hosted grid
10
+ # The Remote Driver that will connect to a dockerized self-hosted grid
11
11
  # This expects the grid to be live **and** accepting node requests
12
12
  #
13
13
  class Remote
@@ -17,7 +17,7 @@ module AutomationHelpers
17
17
  # #### Initial setup options
18
18
  #
19
19
  # - **browser** (required) - When instantiating, the first argument must be the symbol that represents what browser to use
20
- # - **ENV["HUB_URL"]** (required) - The environment variable HUB_URL must be set to the actively running dockerised grid
20
+ # - **ENV["HUB_URL"]** (required) - The environment variable HUB_URL must be set to the actively running dockerized grid
21
21
  # (By default this should be +http://hub:4444/wd/hub+)
22
22
  def initialize(browser)
23
23
  @browser = browser
@@ -54,7 +54,7 @@ module AutomationHelpers
54
54
  end
55
55
 
56
56
  def supported_browser?
57
- %i[chrome firefox].include?(browser)
57
+ %i[chrome edge firefox].include?(browser)
58
58
  end
59
59
  end
60
60
  end
@@ -14,7 +14,7 @@ module AutomationHelpers
14
14
 
15
15
  Kernel.warn('This is now deprecated and should not be used') if deprecate?
16
16
  AutomationHelpers.logger.info("Adding patch: #{self.class}")
17
- AutomationHelpers.logger.debug(description)
17
+ AutomationHelpers.logger.info(description)
18
18
  perform
19
19
  AutomationHelpers.logger.info('Patch successfully added.')
20
20
  end
@@ -4,7 +4,4 @@ require 'automation_helpers/logger'
4
4
 
5
5
  require 'automation_helpers/patches/base'
6
6
  require 'automation_helpers/patches/capybara'
7
- require 'automation_helpers/patches/parallel_cucumber'
8
7
  require 'automation_helpers/patches/selenium_logger'
9
- require 'automation_helpers/patches/selenium_manager'
10
- require 'automation_helpers/patches/selenium_options'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AutomationHelpers
4
- VERSION = '4.1.1'
4
+ VERSION = '5.0'
5
5
  end
@@ -17,7 +17,6 @@ module AutomationHelpers
17
17
 
18
18
  # The Automation Helpers logger object - This is called automatically in several
19
19
  # locations and will log messages according to the normal Ruby protocol
20
- # To alter (or check), the log level; call .log_level= or .log_level
21
20
  #
22
21
  # This logger object can also be used to manually log messages
23
22
  #
@@ -31,12 +30,6 @@ module AutomationHelpers
31
30
  @logger ||= Logger.create
32
31
  end
33
32
 
34
- def logger=(logger)
35
- raise ArgumentError, 'You must supply an existing Logger' unless logger.is_a?(::Logger)
36
-
37
- @logger = logger
38
- end
39
-
40
33
  # This writer method allows you to configure where you want the output of
41
34
  # the automation_helpers logs to go (Default is $stdout)
42
35
  #
@@ -45,24 +38,5 @@ module AutomationHelpers
45
38
  def log_path=(logdev)
46
39
  logger.reopen(logdev)
47
40
  end
48
-
49
- # To enable full logging (This uses the Ruby API, so can accept any of a
50
- # Symbol / String / Integer as an input
51
- # AutomationHelpers.log_level = :DEBUG
52
- # AutomationHelpers.log_level = 'DEBUG'
53
- # AutomationHelpers.log_level = 0
54
- #
55
- # To disable all logging
56
- # AutomationHelpers.log_level = :UNKNOWN
57
- def log_level=(value)
58
- logger.level = value
59
- end
60
-
61
- # To query what level is being logged
62
- # AutomationHelpers.log_level
63
- # => :INFO # By default
64
- def log_level
65
- %i[DEBUG INFO WARN ERROR FATAL UNKNOWN][logger.level]
66
- end
67
41
  end
68
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: automation_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: '5.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Hill
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-08-16 00:00:00.000000000 Z
12
+ date: 2023-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara
@@ -65,26 +65,6 @@ dependencies:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '2.7'
68
- - !ruby/object:Gem::Dependency
69
- name: parallel_tests
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '3.7'
75
- - - "<"
76
- - !ruby/object:Gem::Version
77
- version: '5'
78
- type: :development
79
- prerelease: false
80
- version_requirements: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: '3.7'
85
- - - "<"
86
- - !ruby/object:Gem::Version
87
- version: '5'
88
68
  - !ruby/object:Gem::Dependency
89
69
  name: rspec
90
70
  requirement: !ruby/object:Gem::Requirement
@@ -105,76 +85,56 @@ dependencies:
105
85
  requirements:
106
86
  - - "~>"
107
87
  - !ruby/object:Gem::Version
108
- version: 1.45.0
88
+ version: 1.56.0
109
89
  type: :development
110
90
  prerelease: false
111
91
  version_requirements: !ruby/object:Gem::Requirement
112
92
  requirements:
113
93
  - - "~>"
114
94
  - !ruby/object:Gem::Version
115
- version: 1.45.0
95
+ version: 1.56.0
116
96
  - !ruby/object:Gem::Dependency
117
97
  name: rubocop-performance
118
98
  requirement: !ruby/object:Gem::Requirement
119
99
  requirements:
120
100
  - - "~>"
121
101
  - !ruby/object:Gem::Version
122
- version: 1.18.0
102
+ version: 1.19.0
123
103
  type: :development
124
104
  prerelease: false
125
105
  version_requirements: !ruby/object:Gem::Requirement
126
106
  requirements:
127
107
  - - "~>"
128
108
  - !ruby/object:Gem::Version
129
- version: 1.18.0
109
+ version: 1.19.0
130
110
  - !ruby/object:Gem::Dependency
131
111
  name: rubocop-rspec
132
112
  requirement: !ruby/object:Gem::Requirement
133
113
  requirements:
134
114
  - - "~>"
135
115
  - !ruby/object:Gem::Version
136
- version: 2.22.0
116
+ version: 2.23.2
137
117
  type: :development
138
118
  prerelease: false
139
119
  version_requirements: !ruby/object:Gem::Requirement
140
120
  requirements:
141
121
  - - "~>"
142
122
  - !ruby/object:Gem::Version
143
- version: 2.22.0
123
+ version: 2.23.2
144
124
  - !ruby/object:Gem::Dependency
145
125
  name: selenium-webdriver
146
- requirement: !ruby/object:Gem::Requirement
147
- requirements:
148
- - - ">="
149
- - !ruby/object:Gem::Version
150
- version: '4.0'
151
- - - "<"
152
- - !ruby/object:Gem::Version
153
- version: '5'
154
- type: :development
155
- prerelease: false
156
- version_requirements: !ruby/object:Gem::Requirement
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- version: '4.0'
161
- - - "<"
162
- - !ruby/object:Gem::Version
163
- version: '5'
164
- - !ruby/object:Gem::Dependency
165
- name: webdrivers
166
126
  requirement: !ruby/object:Gem::Requirement
167
127
  requirements:
168
128
  - - "~>"
169
129
  - !ruby/object:Gem::Version
170
- version: '5.2'
130
+ version: '4.0'
171
131
  type: :development
172
132
  prerelease: false
173
133
  version_requirements: !ruby/object:Gem::Requirement
174
134
  requirements:
175
135
  - - "~>"
176
136
  - !ruby/object:Gem::Version
177
- version: '5.2'
137
+ version: '4.0'
178
138
  description: Automation Patches / Extensions that allow you to extend your Ruby-based
179
139
  testing frameworks
180
140
  email:
@@ -207,10 +167,7 @@ files:
207
167
  - lib/automation_helpers/patches.rb
208
168
  - lib/automation_helpers/patches/base.rb
209
169
  - lib/automation_helpers/patches/capybara.rb
210
- - lib/automation_helpers/patches/parallel_cucumber.rb
211
170
  - lib/automation_helpers/patches/selenium_logger.rb
212
- - lib/automation_helpers/patches/selenium_manager.rb
213
- - lib/automation_helpers/patches/selenium_options.rb
214
171
  - lib/automation_helpers/version.rb
215
172
  homepage: https://www.github.com/site-prism/automation_helpers
216
173
  licenses:
@@ -227,14 +184,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
184
  requirements:
228
185
  - - ">="
229
186
  - !ruby/object:Gem::Version
230
- version: '2.7'
187
+ version: '3.0'
231
188
  required_rubygems_version: !ruby/object:Gem::Requirement
232
189
  requirements:
233
190
  - - ">="
234
191
  - !ruby/object:Gem::Version
235
192
  version: '0'
236
193
  requirements: []
237
- rubygems_version: 3.1.6
194
+ rubygems_version: 3.2.33
238
195
  signing_key:
239
196
  specification_version: 4
240
197
  summary: Automation Helpers - Avoid writing the most common things in Ruby Automation
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module AutomationHelpers
4
- module Patches
5
- #
6
- # Fix the issue where the parser for parallel_tests doesn't permit the --retry flag (Or other flags at the end)
7
- #
8
- class ParallelCucumber < Base
9
- private
10
-
11
- def description
12
- <<~DESCRIPTION
13
- This patch fixes an issue where the parallel tests gem won't place the --retry flag in the correct
14
- position for command invocation with cucumber
15
- See: https://github.com/grosser/parallel_tests/pull/827 for more details/discussion including this fix
16
- DESCRIPTION
17
- end
18
-
19
- def perform
20
- ::ParallelTests::Gherkin::Runner.extend RetryFlagFix
21
- end
22
-
23
- def deprecate_from
24
- '3.12.0'
25
- end
26
-
27
- def prevent_usage_from
28
- '4.0.0'
29
- end
30
-
31
- def gem_version
32
- ::ParallelTests::VERSION
33
- end
34
- end
35
-
36
- module RetryFlagFix
37
- def run_tests(test_files, process_number, num_processes, options)
38
- # Copied Code - https://github.com/grosser/parallel_tests/blob/master/lib/parallel_tests/gherkin/runner.rb#L9
39
- combined_scenarios = test_files
40
-
41
- if options[:group_by] == :scenarios
42
- grouped = test_files.map { |t| t.split(':') }.group_by(&:first)
43
- combined_scenarios = grouped.map do |file, files_and_lines|
44
- "#{file}:#{files_and_lines.map(&:last).join(':')}"
45
- end
46
- end
47
-
48
- sanitized_test_files = combined_scenarios.map { |val| WINDOWS ? "\"#{val}\"" : Shellwords.escape(val) }
49
-
50
- options[:env] ||= {}
51
- options[:env] = options[:env].merge({ 'AUTOTEST' => '1' }) if $stdout.tty?
52
-
53
- # New code
54
- opts = cucumber_opts(options[:test_options])
55
- cmd = [
56
- executable,
57
- (runtime_logging if File.directory?(File.dirname(runtime_log))),
58
- opts[0],
59
- *sanitized_test_files,
60
- opts[1]
61
- ].compact.reject(&:empty?).join(' ')
62
- execute_command(cmd, process_number, num_processes, options)
63
- end
64
-
65
- def cucumber_opts(given)
66
- # All new code
67
- initial =
68
- if given =~ (/--profile/) || given =~ (/(^|\s)-p /)
69
- given
70
- else
71
- [given, profile_from_config].compact.join(" ")
72
- end
73
-
74
- opts_as_individuals = initial.scan(/\S+\s\S+/)
75
- desired_output = ['', '']
76
-
77
- opts_as_individuals.each do |opt|
78
- if opt.match?(/--retry \d+/)
79
- desired_output[1] = opt
80
- else
81
- desired_output[0] = "#{desired_output[0]} #{opt}".strip
82
- end
83
- end
84
-
85
- desired_output
86
- end
87
- end
88
- end
89
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module AutomationHelpers
4
- module Patches
5
- #
6
- # Fix the issue where the `#convert_cookie` API private method in selenium-webdriver doesn't include the
7
- # 'httpOnly' property in the returned cookie hash structure
8
- #
9
- class SeleniumManager < Base
10
- private
11
-
12
- def description
13
- <<~DESCRIPTION
14
- This patch fixes an issue with Selenium4 not bubbling up the httpOnly property of a cookie
15
- See: https://github.com/SeleniumHQ/selenium/pull/8958 for more details/discussion including this fix
16
- DESCRIPTION
17
- end
18
-
19
- def perform
20
- ::Selenium::WebDriver::Manager.prepend CookieConverter
21
- end
22
-
23
- def deprecate_from
24
- '4.0.0.beta3'
25
- end
26
-
27
- def prevent_usage_from
28
- '4.0.0'
29
- end
30
-
31
- def gem_version
32
- ::Selenium::WebDriver::VERSION
33
- end
34
- end
35
-
36
- #
37
- # @api private
38
- #
39
- module CookieConverter
40
- def convert_cookie(cookie)
41
- super(cookie)
42
- .merge(
43
- {
44
- http_only: cookie['httpOnly']
45
- }
46
- )
47
- end
48
- end
49
- end
50
- end
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module AutomationHelpers
4
- module Patches
5
- #
6
- # Fix the issue where for some drivers selenium doesn't camelize the browser name key 'browserName' correctly
7
- #
8
- class SeleniumOptions < Base
9
- def initialize(browser)
10
- @browser = browser
11
- super()
12
- end
13
-
14
- # @return [nil || true]
15
- #
16
- # For SeleniumOptions we only want to run the patch when
17
- # we are on browsers without the relevant JSON fixes in upstream
18
- def patch!
19
- return unless valid?
20
-
21
- super
22
- end
23
-
24
- private
25
-
26
- def valid?
27
- %i[firefox safari].include?(@browser)
28
- end
29
-
30
- def description
31
- <<~DESCRIPTION
32
- This patch fixes an issue with Selenium4 not camelising the browser_name property
33
- The issue is the driver, which is now fully W3C conformant expects `browserName`
34
-
35
- See: https://github.com/SeleniumHQ/selenium/pull/8834 for more details/discussion including this fix
36
- DESCRIPTION
37
- end
38
-
39
- def perform
40
- case @browser
41
- when :firefox then ::Selenium::WebDriver::Firefox::Options.include CapabilitiesAsJsonFix
42
- when :safari then ::Selenium::WebDriver::Safari::Options.include CapabilitiesAsJsonFix
43
- end
44
- end
45
-
46
- def deprecate_from
47
- '4.0.0'
48
- end
49
-
50
- def prevent_usage_from
51
- '4.0.3'
52
- end
53
-
54
- def gem_version
55
- ::Selenium::WebDriver::VERSION
56
- end
57
- end
58
-
59
- #
60
- # @api private
61
- #
62
- module CapabilitiesAsJsonFix
63
- private
64
-
65
- def generate_as_json(value, camelize_keys: true)
66
- if value.is_a?(Hash)
67
- value.each_with_object({}) do |(key, val), hash|
68
- key = convert_json_key(key, camelize: camelize_keys)
69
- hash[key] = generate_as_json(val, camelize_keys: key != 'prefs')
70
- end
71
- else
72
- super
73
- end
74
- end
75
- end
76
- end
77
- end