From 51fb6332c763de5ba3b6bafe306938c1486f644e Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Thu, 27 Jun 2019 18:18:16 -0700 Subject: [PATCH] autoload all browser specific classes to fix circular dependency --- rb/lib/selenium/server.rb | 2 +- rb/lib/selenium/webdriver/chrome.rb | 13 ++++++------- rb/lib/selenium/webdriver/edge.rb | 20 ++++++++++---------- rb/lib/selenium/webdriver/firefox.rb | 21 +++++++++------------ rb/lib/selenium/webdriver/ie.rb | 9 ++++----- rb/lib/selenium/webdriver/remote.rb | 26 ++++++++++++++++---------- rb/lib/selenium/webdriver/safari.rb | 11 +++++------ 7 files changed, 51 insertions(+), 51 deletions(-) diff --git a/rb/lib/selenium/server.rb b/rb/lib/selenium/server.rb index 2f78325b9c603..d564025d38e36 100644 --- a/rb/lib/selenium/server.rb +++ b/rb/lib/selenium/server.rb @@ -85,7 +85,7 @@ def download(required_version) segment_count += 1 if (segment_count % 15).zero? - percent = (progress.to_f / total.to_f) * 100 + percent = progress.fdiv(total) * 100 print "#{CL_RESET}Downloading #{download_file_name}: #{percent.to_i}% (#{progress} / #{total})" segment_count = 0 end diff --git a/rb/lib/selenium/webdriver/chrome.rb b/rb/lib/selenium/webdriver/chrome.rb index e57543dd43f21..02c9a7f48cc2f 100644 --- a/rb/lib/selenium/webdriver/chrome.rb +++ b/rb/lib/selenium/webdriver/chrome.rb @@ -19,13 +19,15 @@ require 'net/http' -require 'selenium/webdriver/chrome/driver' -require 'selenium/webdriver/chrome/profile' -require 'selenium/webdriver/chrome/options' - module Selenium module WebDriver module Chrome + autoload :Bridge, 'selenium/webdriver/chrome/bridge' + autoload :Driver, 'selenium/webdriver/chrome/driver' + autoload :Profile, 'selenium/webdriver/chrome/profile' + autoload :Options, 'selenium/webdriver/chrome/options' + autoload :Service, 'selenium/webdriver/chrome/service' + def self.driver_path=(path) WebDriver.logger.deprecate 'Selenium::WebDriver::Chrome#driver_path=', 'Selenium::WebDriver::Chrome::Service#driver_path=' @@ -49,6 +51,3 @@ def self.path end # Chrome end # WebDriver end # Selenium - -require 'selenium/webdriver/chrome/service' -require 'selenium/webdriver/chrome/bridge' diff --git a/rb/lib/selenium/webdriver/edge.rb b/rb/lib/selenium/webdriver/edge.rb index ce2583c1f74ce..559a1cd651614 100644 --- a/rb/lib/selenium/webdriver/edge.rb +++ b/rb/lib/selenium/webdriver/edge.rb @@ -19,16 +19,13 @@ require 'net/http' -require 'selenium/webdriver/edge_html/driver' -require 'selenium/webdriver/edge_html/options' -require 'selenium/webdriver/edge_chrome/bridge' -require 'selenium/webdriver/edge_chrome/driver' -require 'selenium/webdriver/edge_chrome/profile' -require 'selenium/webdriver/edge_chrome/options' - module Selenium module WebDriver module EdgeHtml + autoload :Driver, 'selenium/webdriver/edge_html/driver' + autoload :Options, 'selenium/webdriver/edge_html/options' + autoload :Service, 'selenium/webdriver/edge_html/service' + def self.driver_path=(path) WebDriver.logger.deprecate 'Selenium::WebDriver::Edge#driver_path=', 'Selenium::WebDriver::Edge::Service#driver_path=' @@ -43,6 +40,12 @@ def self.driver_path end # EdgeHtml module EdgeChrome + autoload :Bridge, 'selenium/webdriver/edge_chrome/bridge' + autoload :Driver, 'selenium/webdriver/edge_chrome/driver' + autoload :Profile, 'selenium/webdriver/edge_chrome/profile' + autoload :Options, 'selenium/webdriver/edge_chrome/options' + autoload :Service, 'selenium/webdriver/edge_chrome/service' + def self.path=(path) Platform.assert_executable path @path = path @@ -56,6 +59,3 @@ def self.path Edge = EdgeHtml # Alias EdgeHtml as Edge for now end # WebDriver end # Selenium - -require 'selenium/webdriver/edge_html/service' -require 'selenium/webdriver/edge_chrome/service' diff --git a/rb/lib/selenium/webdriver/firefox.rb b/rb/lib/selenium/webdriver/firefox.rb index d06b8db02175b..02bba43c3d4b7 100644 --- a/rb/lib/selenium/webdriver/firefox.rb +++ b/rb/lib/selenium/webdriver/firefox.rb @@ -21,19 +21,18 @@ require 'socket' require 'rexml/document' -require 'selenium/webdriver/firefox/driver' - -require 'selenium/webdriver/firefox/extension' -require 'selenium/webdriver/firefox/binary' -require 'selenium/webdriver/firefox/profiles_ini' -require 'selenium/webdriver/firefox/profile' -require 'selenium/webdriver/firefox/bridge' -require 'selenium/webdriver/firefox/driver' -require 'selenium/webdriver/firefox/options' - module Selenium module WebDriver module Firefox + autoload :Extension, 'selenium/webdriver/firefox/extension' + autoload :Binary, 'selenium/webdriver/firefox/binary' + autoload :ProfilesIni, 'selenium/webdriver/firefox/profiles_ini' + autoload :Profile, 'selenium/webdriver/firefox/profile' + autoload :Bridge, 'selenium/webdriver/firefox/bridge' + autoload :Driver, 'selenium/webdriver/firefox/driver' + autoload :Options, 'selenium/webdriver/firefox/options' + autoload :Service, 'selenium/webdriver/firefox/service' + DEFAULT_PORT = 7055 DEFAULT_ENABLE_NATIVE_EVENTS = Platform.os == :windows DEFAULT_SECURE_SSL = false @@ -58,5 +57,3 @@ def self.path=(path) end # Firefox end # WebDriver end # Selenium - -require 'selenium/webdriver/firefox/service' diff --git a/rb/lib/selenium/webdriver/ie.rb b/rb/lib/selenium/webdriver/ie.rb index e4573af8a8b21..3d88593e9fd5d 100644 --- a/rb/lib/selenium/webdriver/ie.rb +++ b/rb/lib/selenium/webdriver/ie.rb @@ -17,12 +17,13 @@ # specific language governing permissions and limitations # under the License. -require 'selenium/webdriver/ie/driver' -require 'selenium/webdriver/ie/options' - module Selenium module WebDriver module IE + autoload :Driver, 'selenium/webdriver/ie/driver' + autoload :Options, 'selenium/webdriver/ie/options' + autoload :Service, 'selenium/webdriver/ie/service' + def self.driver_path=(path) WebDriver.logger.deprecate 'Selenium::WebDriver::IE#driver_path=', 'Selenium::WebDriver::IE::Service#driver_path=' @@ -37,5 +38,3 @@ def self.driver_path end # IE end # WebDriver end # Selenium - -require 'selenium/webdriver/ie/service' diff --git a/rb/lib/selenium/webdriver/remote.rb b/rb/lib/selenium/webdriver/remote.rb index f192220826433..86bed24d35e40 100644 --- a/rb/lib/selenium/webdriver/remote.rb +++ b/rb/lib/selenium/webdriver/remote.rb @@ -19,13 +19,19 @@ require 'uri' -require 'selenium/webdriver/remote/bridge' -require 'selenium/webdriver/remote/driver' -require 'selenium/webdriver/remote/response' -require 'selenium/webdriver/remote/server_error' -require 'selenium/webdriver/remote/http/common' -require 'selenium/webdriver/remote/http/default' - -require 'selenium/webdriver/remote/bridge' -require 'selenium/webdriver/remote/capabilities' -require 'selenium/webdriver/remote/commands' +module Selenium + module WebDriver + module Remote + autoload :Bridge, 'selenium/webdriver/remote/bridge' + autoload :Driver, 'selenium/webdriver/remote/driver' + autoload :Response, 'selenium/webdriver/remote/response' + autoload :ServerError, 'selenium/webdriver/remote/server_error' + autoload :Capabilities, 'selenium/webdriver/remote/capabilities' + autoload :COMMANDS, 'selenium/webdriver/remote/commands' + module Http + autoload :Common, 'selenium/webdriver/remote/http/common' + autoload :Default, 'selenium/webdriver/remote/http/default' + end + end + end +end diff --git a/rb/lib/selenium/webdriver/safari.rb b/rb/lib/selenium/webdriver/safari.rb index d1a125650b5d7..6f82e9d521d02 100644 --- a/rb/lib/selenium/webdriver/safari.rb +++ b/rb/lib/selenium/webdriver/safari.rb @@ -17,13 +17,14 @@ # specific language governing permissions and limitations # under the License. -require 'selenium/webdriver/safari/bridge' -require 'selenium/webdriver/safari/driver' -require 'selenium/webdriver/safari/options' - module Selenium module WebDriver module Safari + autoload :Bridge, 'selenium/webdriver/safari/bridge' + autoload :Driver, 'selenium/webdriver/safari/driver' + autoload :Options, 'selenium/webdriver/safari/options' + autoload :Service, 'selenium/webdriver/safari/service' + class << self def technology_preview "/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver" @@ -61,5 +62,3 @@ def driver_path end # Safari end # WebDriver end # Selenium - -require 'selenium/webdriver/safari/service'