@@ -26,6 +26,8 @@ def self.path(options, service_class)
2626 new ( options , service_class . new ) . driver_path
2727 end
2828
29+ # @param options [Options, nil] when nil driver parsed from Service::EXECUTABLE
30+ # @param service [Service]
2931 def initialize ( options , service )
3032 @options = options
3133 @service = service
@@ -46,24 +48,19 @@ def browser_path?
4648 private
4749
4850 def paths
49- @paths ||= resolve_paths
50- rescue StandardError => e
51- WebDriver . logger . error ( "Exception occurred: #{ e . message } " )
52- WebDriver . logger . error ( "Backtrace:\n \t #{ e . backtrace &.join ( "\n \t " ) } " )
53- raise Error ::NoSuchDriverError , "Unable to obtain #{ @service . class ::EXECUTABLE } "
51+ @paths ||= begin
52+ path = @service . executable_path || resolve_class_path
53+ path ? paths_from_service ( path ) : paths_from_manager
54+ rescue StandardError => e
55+ WebDriver . logger . error ( "Exception occurred: #{ e . message } " )
56+ WebDriver . logger . error ( "Backtrace:\n \t #{ e . backtrace &.join ( "\n \t " ) } " )
57+ raise Error ::NoSuchDriverError , "Unable to obtain #{ @service . class ::EXECUTABLE } "
58+ end
5459 end
5560
56- def resolve_paths
61+ def resolve_class_path
5762 path = @service . class . driver_path
58- path = path . call if path . is_a? ( Proc )
59- result = path ? paths_from_service ( path ) : paths_from_manager
60-
61- # A binary (whether user-supplied or resolved by Selenium Manager) is the
62- # source of truth for the browser version, so drop any named version that
63- # would otherwise conflict with what the binary actually is.
64- @options . browser_version = nil if @options . respond_to? ( :binary ) && @options . binary
65-
66- result
63+ path . is_a? ( Proc ) ? path . call : path
6764 end
6865
6966 def paths_from_service ( path )
@@ -79,11 +76,12 @@ def paths_from_manager
7976 browser_path : Platform . cygwin_path ( output [ 'browser_path' ] , only_cygwin : true ) }
8077 Platform . assert_executable ( formatted [ :driver_path ] )
8178 Platform . assert_executable ( formatted [ :browser_path ] )
82- @options . binary ||= formatted [ :browser_path ] if @options . respond_to? ( :binary )
8379 formatted
8480 end
8581
8682 def to_args
83+ return [ '--driver' , @service . class ::EXECUTABLE ] unless @options
84+
8785 args = [ '--browser' , @options . browser_name ]
8886 if @options . browser_version
8987 args << '--browser-version'
0 commit comments