@@ -111,6 +111,8 @@ pub trait SeleniumManager {
111
111
112
112
fn get_browser_name ( & self ) -> & str ;
113
113
114
+ fn get_browser_names_in_path ( & self ) -> Vec < & str > ;
115
+
114
116
fn get_http_client ( & self ) -> & Client ;
115
117
116
118
fn set_http_client ( & mut self , http_client : Client ) ;
@@ -229,20 +231,9 @@ pub trait SeleniumManager {
229
231
Some ( Path :: new ( & canon_browser_path) . to_path_buf ( ) )
230
232
} else {
231
233
// Check browser in PATH
232
- let browser_name = self . get_browser_name ( ) ;
233
- self . get_logger ( )
234
- . trace ( format ! ( "Checking {} in PATH" , browser_name) ) ;
235
234
let browser_in_path = self . find_browser_in_path ( ) ;
236
235
if let Some ( path) = & browser_in_path {
237
- let canon_browser_path = self . canonicalize_path ( path. clone ( ) ) ;
238
- self . get_logger ( ) . debug ( format ! (
239
- "Found {} in PATH: {}" ,
240
- browser_name, & canon_browser_path
241
- ) ) ;
242
- self . set_browser_path ( canon_browser_path) ;
243
- } else {
244
- self . get_logger ( )
245
- . debug ( format ! ( "{} not found in PATH" , browser_name) ) ;
236
+ self . set_browser_path ( path_to_string ( path) ) ;
246
237
}
247
238
browser_in_path
248
239
}
@@ -392,10 +383,18 @@ pub trait SeleniumManager {
392
383
}
393
384
394
385
fn find_browser_in_path ( & self ) -> Option < PathBuf > {
395
- let browser_path = self . execute_which_in_shell ( self . get_browser_name ( ) ) ;
396
- if let Some ( path) = browser_path {
397
- return Some ( Path :: new ( & path) . to_path_buf ( ) ) ;
386
+ for browser_name in self . get_browser_names_in_path ( ) . iter ( ) {
387
+ self . get_logger ( )
388
+ . trace ( format ! ( "Checking {} in PATH" , browser_name) ) ;
389
+ let browser_path = self . execute_which_in_shell ( browser_name) ;
390
+ if let Some ( path) = browser_path {
391
+ self . get_logger ( )
392
+ . debug ( format ! ( "Found {} in PATH: {}" , browser_name, & path) ) ;
393
+ return Some ( Path :: new ( & path) . to_path_buf ( ) ) ;
394
+ }
398
395
}
396
+ self . get_logger ( )
397
+ . debug ( format ! ( "{} not found in PATH" , self . get_browser_name( ) ) ) ;
399
398
None
400
399
}
401
400
0 commit comments