Skip to content

Commit

Permalink
Upgrade Selenium
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulDoyle-EA committed Aug 17, 2023
1 parent 1f25016 commit a366365
Show file tree
Hide file tree
Showing 25 changed files with 265 additions and 198 deletions.
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
inherit_from: .rubocop_todo.yml

inherit_gem:
defra_ruby_style:
- default.yml

require:
- rubocop-rake
- rubocop-rspec
82 changes: 82 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-08-14 14:02:05 UTC using RuboCop version 1.56.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 8
# Configuration parameters: EnforcedStyle, AllowedGems, Include.
# SupportedStyles: Gemfile, gems.rb, gemspec
# Include: **/*.gemspec, **/Gemfile, **/gems.rb
Gemspec/DevelopmentDependencies:
Exclude:
- 'quke.gemspec'

# Offense count: 1
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'quke.gemspec'

# Offense count: 1
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
Lint/DuplicateBranch:
Exclude:
- 'lib/quke/driver_registration.rb'

# Offense count: 16
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/quke/configuration_spec.rb'
- 'spec/quke/driver_configuration_spec.rb'
- 'spec/quke/driver_registration_spec.rb'

# Offense count: 18
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 22

# Offense count: 2
RSpec/ExpectInHook:
Exclude:
- 'spec/quke/quke_spec.rb'

# Offense count: 2
RSpec/IdenticalEqualityAssertion:
Exclude:
- 'spec/quke/driver_registration_spec.rb'

# Offense count: 2
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive

# Offense count: 10
RSpec/MultipleExpectations:
Max: 17

# Offense count: 6
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 6

# Offense count: 83
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Exclude:
- 'spec/quke/browserstack_configuration_spec.rb'
- 'spec/quke/browserstack_status_reporter_spec.rb'
- 'spec/quke/configuration_spec.rb'
- 'spec/quke/proxy_configuration_spec.rb'

# Offense count: 1
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 4
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.2
3.2.2
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ source "https://rubygems.org"

# Specify your gem's dependencies in quke.gemspec
gemspec

group :development, :test do
gem "rubocop-rake"
gem "rubocop-rspec"
end
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ A very simple overview of how things work is that
- [Selenium](https://github.com/SeleniumHQ/selenium/tree/master/rb) is used to tell the browsers what to do
- each browser has a driver ([Chromedriver](https://chromedriver.chromium.org/), [Geckodriver](https://github.com/mozilla/geckodriver) etc) which can interpret Selenium commands into actual actions

For Quke to work those browser drivers need to be installed. Quke manages this for you using a tool called [Webdrivers](https://github.com/titusfortner/webdrivers). There may be times you want to check the version of these drivers, or force an update to a specific version.

If your project is using [Rake](https://github.com/ruby/rake) add the following to the `Rakefile` and you can then access a series of helper functions, for example `rake webdrivers:chromedriver:version`

```ruby
require "quke"
load "quke/Rakefile"
```

## Development

Expand Down
3 changes: 1 addition & 2 deletions lib/quke.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require "selenium/webdriver"
require "webdrivers"
require "capybara"

require "quke/version"
Expand All @@ -13,7 +12,7 @@
require "quke/driver_configuration"
require "quke/proxy_configuration"

module Quke #:nodoc:
module Quke # :nodoc:

class QukeError < StandardError; end

Expand Down
14 changes: 0 additions & 14 deletions lib/quke/Rakefile

This file was deleted.

4 changes: 2 additions & 2 deletions lib/quke/browserstack_configuration.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module Quke #:nodoc:
module Quke # :nodoc:

# Determines the configuration for browserstack, when selected as the driver
class BrowserstackConfiguration
Expand Down Expand Up @@ -108,7 +108,7 @@ def using_browserstack?
# )
#
def url
return "http://#{@username}:#{@auth_key}@hub.browserstack.com/wd/hub" unless @username == ""
"http://#{@username}:#{@auth_key}@hub.browserstack.com/wd/hub" unless @username == ""
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/quke/browserstack_status_reporter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module Quke #:nodoc:
module Quke # :nodoc:

# Used to update the status of a session in Browserstack to mark it as passed
# or failed. It does this by making a PUT request to Browserstack's REST API
Expand Down
4 changes: 1 addition & 3 deletions lib/quke/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "yaml"

module Quke #:nodoc:
module Quke # :nodoc:

# Manages all configuration for Quke.
class Configuration
Expand Down Expand Up @@ -110,9 +110,7 @@ def pause
def stop_on_error
# This use of Yaml.load to convert a string to a boolean comes from
# http://stackoverflow.com/a/21804027/6117745
# rubocop:disable Security/YAMLLoad
YAML.load(@data["stop_on_error"])
# rubocop:enable Security/YAMLLoad
end

# Returns the value set for +display_failures+.
Expand Down
2 changes: 1 addition & 1 deletion lib/quke/cuke_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "cucumber"

module Quke #:nodoc:
module Quke # :nodoc:

# Handles executing Cucumber, including sorting the arguments we pass to it
class CukeRunner
Expand Down
7 changes: 4 additions & 3 deletions lib/quke/driver_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "quke/configuration"

module Quke #:nodoc:
module Quke # :nodoc:

# Helper class that manages the options, switches and capabilities for each of
# the different drivers.
Expand Down Expand Up @@ -54,8 +54,9 @@ def initialize(config)
def chrome
no_proxy = config.proxy.no_proxy.tr(",", ";")

options = Selenium::WebDriver::Chrome::Options.new
options.headless! if config.headless
args = config.headless ? ["--headless=new"] : []

options = Selenium::WebDriver::Options.chrome(args: args)

options.add_argument("--proxy-server=#{config.proxy.host}:#{config.proxy.port}") if config.proxy.use_proxy?
options.add_argument("--proxy-bypass-list=#{no_proxy}") unless config.proxy.no_proxy.empty?
Expand Down
2 changes: 1 addition & 1 deletion lib/quke/driver_registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "quke/configuration"
require "selenium/webdriver"

module Quke #:nodoc:
module Quke # :nodoc:

# Helper class that contains all methods related to registering drivers with
# Capybara.
Expand Down
2 changes: 1 addition & 1 deletion lib/quke/proxy_configuration.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module Quke #:nodoc:
module Quke # :nodoc:

# Manages all proxy configuration for Quke.
class ProxyConfiguration
Expand Down
2 changes: 1 addition & 1 deletion lib/quke/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Quke #:nodoc:
module Quke # :nodoc:
VERSION = "0.10.0"
end
13 changes: 3 additions & 10 deletions quke.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
spec.files = Dir["{bin,exe,lib}/**/*", "LICENSE", "Rakefile", "README.md"]
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.test_files = Dir["spec/**/*"]

spec.require_paths = ["lib"]

Expand All @@ -33,7 +32,7 @@ Gem::Specification.new do |spec|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
"public gem pushes."
end

spec.required_ruby_version = ">= 2.4"
Expand All @@ -54,14 +53,7 @@ Gem::Specification.new do |spec|

# selenium-webdriver is used to drive browsers like Firefox, Chrome and
# Internet Explorer.
spec.add_dependency "selenium-webdriver", "~> 3.14"

# Needed to use Chrome or Firefox for selenium tests. You can opt
# to install each driver separately. However in an effort to make using this
# gem as simple as possible we have gone with using webdrivers. To quote
# from it "Run Selenium tests more easily with automatic installation and
# updates for all supported webdrivers."
spec.add_dependency "webdrivers", "~> 4.0"
spec.add_dependency "selenium-webdriver", "~> 4.1"

# Experience has shown that keeping tests dry helps make them more
# maintainable over time. One practice that helps is the use of the
Expand Down Expand Up @@ -94,4 +86,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rspec", "~> 3.8"
spec.add_development_dependency "simplecov", "~> 0.17.1"
spec.add_development_dependency "webmock", "~> 3.5"
spec.metadata["rubygems_mfa_required"] = "true"
end
Loading

0 comments on commit a366365

Please sign in to comment.