automation_helpers 4.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: a45b85e5e998a666514c866da1cc6639fa113ebe88232a70ceb979c4a2877a03
4
- data.tar.gz: d66c6284158e939d8d268126e8fd98833316ca2cfa4a29c3afbdd8002c1aa61a
3
+ metadata.gz: ac74d1da46721b813cf048c83f2c12393132af015ac62fbb38830f8c828550fb
4
+ data.tar.gz: 35342f56615fd96850664dd2c7fd1f6f662e88cf5c5c830ead0ade741fe3632e
5
5
  SHA512:
6
- metadata.gz: 97f4e92ba3f4a1bc6629d07b94e60de3b9c722f27feb0700b8fbaf9953a4177302584ec8700245a942b3a9a114ca007e05f976f0ccb34d46a3e55a20b0486856
7
- data.tar.gz: 6039a2641fe43f4f46ac5befd0987bd259391a2da6f59e1e553de76b58ab6ad8c01bccafb0a8ae49079036290da4de0d8571a8fb83549fa36530ab8902da3bcd
6
+ metadata.gz: ed219f7a15fdafda73b3fa56950fac854347ecb5f672e4e28475828d45c847c777d8c5534cecf5e6ee12ea168bdc6dfb96114ef386367298a4be8d5b700eb47a
7
+ data.tar.gz: 15874df9f590c88fa7981405f1618abedb3110dcb9ba52749835c993033ae8bb1b792e7be6afdf6efef751c87d37952bf6d5c3a0abae9ea1fb293513d9780be6
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020-2022, The SitePrism team & Marcelo Nicolosi Santos
1
+ Copyright (c) 2020-2023, The SitePrism team & Marcelo Nicolosi Santos
2
2
 
3
3
  All rights reserved.
4
4
 
@@ -10,4 +10,4 @@ Redistributions in binary form must reproduce the above copyright notice, this l
10
10
 
11
11
  Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
12
 
13
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -29,6 +29,19 @@ $ bundle
29
29
 
30
30
  Either require all of the extensions required, or require individual bits and pieces
31
31
 
32
+ ```shell
33
+ # Require all of the drivers/patches/extensions code
34
+ require 'automation_helpers'
35
+ # Require all driver code
36
+ require 'automation_helpers/drivers'
37
+ # Require just local drivers
38
+ require 'automation_helpers/drivers/local'
39
+ # Require all patches
40
+ require 'automation_helpers/patches'
41
+ # Require all extensions
42
+ require 'automation_helpers/extensions'
43
+ ```
44
+
32
45
  ## Development
33
46
 
34
47
  ```
@@ -82,6 +82,7 @@ module AutomationHelpers
82
82
 
83
83
  def android_appium_version(android_version)
84
84
  case android_version.to_f
85
+ when 12..; then '1.22.0'
85
86
  when 10..; then '1.21.0'
86
87
  when 9..; then '1.20.2'
87
88
  else raise ArgumentError, "Your Android Version is too low. Please don't use lower than Android Pie (9)."
@@ -90,10 +91,10 @@ module AutomationHelpers
90
91
 
91
92
  def ios_appium_version(ios_version)
92
93
  case ios_version.to_f
94
+ when 14..; then '1.22.0'
93
95
  when 13..; then '1.21.0'
94
96
  when 12..; then '1.20.2'
95
- when 11..; then '1.16.0'
96
- 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."
97
98
  end
98
99
  end
99
100
  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,20 +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
- ::Selenium::WebDriver::Remote::Capabilities.new.tap do |capabilities|
73
- if safari?
74
- capabilities['browserName'] = 'Safari Technology Preview'
75
- AutomationHelpers.logger.warn('Altering Browser Name request to alleviate Capybara failure with STP.')
76
- end
77
- end
78
- end
79
-
80
51
  def options
81
52
  Options.for(browser)
82
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
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'automation_helpers/logger'
4
+
3
5
  require 'automation_helpers/drivers/browserstack'
4
6
  require 'automation_helpers/drivers/local'
5
7
  require 'automation_helpers/drivers/remote'
@@ -7,7 +7,12 @@ class String
7
7
  # Generates a single random letter from an array of the english alphabet
8
8
  # Accepts an input to determine what case of alphabet you want
9
9
  def self.alphabet_char(type = :upper)
10
- Array.alphabet(type).sample
10
+ case type
11
+ when :upper; then ('A'..'Z').to_a.sample
12
+ when :lower; then ('a'..'z').to_a.sample
13
+ when :both; then (('a'..'z').to_a + ('A'..'Z').to_a).sample
14
+ else raise ArgumentError, 'Invalid character type. Must be :upper (default), :lower or :both'
15
+ end
11
16
  end
12
17
 
13
18
  # @return [String]
@@ -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
@@ -27,6 +27,7 @@ module AutomationHelpers
27
27
  # From what point should this patch start throwing deprecation notices
28
28
  # If a date is provided, then after that date
29
29
  # If a version from is provided, then all releases after that one (NB: You must provide a link to the gem version)
30
+ # Otherwise the patch is considered never to be deprecated
30
31
  #
31
32
  def deprecate?
32
33
  if defined?(deprecation_notice_date)
@@ -42,6 +43,7 @@ module AutomationHelpers
42
43
  # From what point should this patch start preventing usage deprecation notices
43
44
  # If a date is provided, then after that date
44
45
  # If a version from is provided, then all releases after that one (NB: You must provide a link to the gem version)
46
+ # Otherwise the patch is considered never to be prevented from being used
45
47
  #
46
48
  def prevent_usage?
47
49
  if defined?(prevent_usage_date)
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'automation_helpers/logger'
4
+
3
5
  require 'automation_helpers/patches/base'
4
6
  require 'automation_helpers/patches/capybara'
5
- require 'automation_helpers/patches/parallel_cucumber'
6
7
  require 'automation_helpers/patches/selenium_logger'
7
- require 'automation_helpers/patches/selenium_manager'
8
- 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'
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'
4
+ version: '5.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Hill
@@ -9,29 +9,35 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-11-01 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
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '3.30'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '4'
21
24
  type: :development
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">="
26
29
  - !ruby/object:Gem::Version
27
30
  version: '3.30'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '4'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: cucumber
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
32
38
  - - ">="
33
39
  - !ruby/object:Gem::Version
34
- version: '5.0'
40
+ version: '7.0'
35
41
  - - "<"
36
42
  - !ruby/object:Gem::Version
37
43
  version: '9'
@@ -41,7 +47,7 @@ dependencies:
41
47
  requirements:
42
48
  - - ">="
43
49
  - !ruby/object:Gem::Version
44
- version: '5.0'
50
+ version: '7.0'
45
51
  - - "<"
46
52
  - !ruby/object:Gem::Version
47
53
  version: '9'
@@ -51,84 +57,70 @@ dependencies:
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '1.8'
55
- type: :development
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.8'
62
- - !ruby/object:Gem::Dependency
63
- name: parallel_tests
64
- requirement: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '3.7'
60
+ version: '2.7'
69
61
  type: :development
70
62
  prerelease: false
71
63
  version_requirements: !ruby/object:Gem::Requirement
72
64
  requirements:
73
65
  - - "~>"
74
66
  - !ruby/object:Gem::Version
75
- version: '3.7'
67
+ version: '2.7'
76
68
  - !ruby/object:Gem::Dependency
77
69
  name: rspec
78
70
  requirement: !ruby/object:Gem::Requirement
79
71
  requirements:
80
72
  - - "~>"
81
73
  - !ruby/object:Gem::Version
82
- version: '3.11'
74
+ version: '3.12'
83
75
  type: :development
84
76
  prerelease: false
85
77
  version_requirements: !ruby/object:Gem::Requirement
86
78
  requirements:
87
79
  - - "~>"
88
80
  - !ruby/object:Gem::Version
89
- version: '3.11'
81
+ version: '3.12'
90
82
  - !ruby/object:Gem::Dependency
91
83
  name: rubocop
92
84
  requirement: !ruby/object:Gem::Requirement
93
85
  requirements:
94
86
  - - "~>"
95
87
  - !ruby/object:Gem::Version
96
- version: 1.38.0
88
+ version: 1.56.0
97
89
  type: :development
98
90
  prerelease: false
99
91
  version_requirements: !ruby/object:Gem::Requirement
100
92
  requirements:
101
93
  - - "~>"
102
94
  - !ruby/object:Gem::Version
103
- version: 1.38.0
95
+ version: 1.56.0
104
96
  - !ruby/object:Gem::Dependency
105
97
  name: rubocop-performance
106
98
  requirement: !ruby/object:Gem::Requirement
107
99
  requirements:
108
100
  - - "~>"
109
101
  - !ruby/object:Gem::Version
110
- version: 1.15.0
102
+ version: 1.19.0
111
103
  type: :development
112
104
  prerelease: false
113
105
  version_requirements: !ruby/object:Gem::Requirement
114
106
  requirements:
115
107
  - - "~>"
116
108
  - !ruby/object:Gem::Version
117
- version: 1.15.0
109
+ version: 1.19.0
118
110
  - !ruby/object:Gem::Dependency
119
111
  name: rubocop-rspec
120
112
  requirement: !ruby/object:Gem::Requirement
121
113
  requirements:
122
114
  - - "~>"
123
115
  - !ruby/object:Gem::Version
124
- version: 2.14.2
116
+ version: 2.23.2
125
117
  type: :development
126
118
  prerelease: false
127
119
  version_requirements: !ruby/object:Gem::Requirement
128
120
  requirements:
129
121
  - - "~>"
130
122
  - !ruby/object:Gem::Version
131
- version: 2.14.2
123
+ version: 2.23.2
132
124
  - !ruby/object:Gem::Dependency
133
125
  name: selenium-webdriver
134
126
  requirement: !ruby/object:Gem::Requirement
@@ -143,20 +135,6 @@ dependencies:
143
135
  - - "~>"
144
136
  - !ruby/object:Gem::Version
145
137
  version: '4.0'
146
- - !ruby/object:Gem::Dependency
147
- name: webdrivers
148
- requirement: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '4.6'
153
- type: :development
154
- prerelease: false
155
- version_requirements: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '4.6'
160
138
  description: Automation Patches / Extensions that allow you to extend your Ruby-based
161
139
  testing frameworks
162
140
  email:
@@ -189,10 +167,7 @@ files:
189
167
  - lib/automation_helpers/patches.rb
190
168
  - lib/automation_helpers/patches/base.rb
191
169
  - lib/automation_helpers/patches/capybara.rb
192
- - lib/automation_helpers/patches/parallel_cucumber.rb
193
170
  - lib/automation_helpers/patches/selenium_logger.rb
194
- - lib/automation_helpers/patches/selenium_manager.rb
195
- - lib/automation_helpers/patches/selenium_options.rb
196
171
  - lib/automation_helpers/version.rb
197
172
  homepage: https://www.github.com/site-prism/automation_helpers
198
173
  licenses:
@@ -209,14 +184,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
184
  requirements:
210
185
  - - ">="
211
186
  - !ruby/object:Gem::Version
212
- version: '2.7'
187
+ version: '3.0'
213
188
  required_rubygems_version: !ruby/object:Gem::Requirement
214
189
  requirements:
215
190
  - - ">="
216
191
  - !ruby/object:Gem::Version
217
192
  version: '0'
218
193
  requirements: []
219
- rubygems_version: 3.1.6
194
+ rubygems_version: 3.2.33
220
195
  signing_key:
221
196
  specification_version: 4
222
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