@@ -171,18 +171,13 @@ public INewWebDriver getDriver() {
171
171
protected abstract INewWebDriver getDriver ();
172
172
}
173
173
174
- private static <T extends RemoteWebDriver > void downloadNewestOrGivenVersionOfWebDriver (Class <T > webDriverType ) {
175
- String proxy = DriverManager .propertiesSelenium .getProxy ();
176
- String webDriversPath = DriverManager .propertiesSelenium .getWebDrivers ();
174
+ private static <T extends RemoteWebDriver > void downloadNewestOrGivenVersionOfWebDriver (Class <T > webDriverType , String browserPath ) {
177
175
try {
178
- System .setProperty ("wdm.targetPath" , webDriversPath );
179
- System .setProperty ("wdm.useBetaVersions" , "false" );
180
-
181
- WebDriverManager .getInstance (webDriverType )
182
- .proxy (proxy )
183
- .setup ();
184
- BFLogger .logDebug ("Downloaded version of driver=" + WebDriverManager .getInstance (webDriverType ).getDownloadedDriverVersion ());
185
-
176
+ WebDriverManager wdm = WebDriverManager .getInstance (webDriverType );
177
+ wdm .config ().setUseBetaVersions (false ).setClearDriverCache (true ).setCachePath (DOWNLOAD_DIR );
178
+ wdm .setup ();
179
+ BFLogger .logDebug ("Downloaded version of driver=" + wdm .getDownloadedDriverVersion ());
180
+ OperationsOnFiles .moveWithPruneEmptydirectories (wdm .getDownloadedDriverPath (), browserPath );
186
181
} catch (WebDriverManagerException e ) {
187
182
BFLogger .logError ("Unable to download driver automatically. "
188
183
+ "Please try to set up the proxy in properties file. "
@@ -293,8 +288,7 @@ private static INewWebDriver getChromeDriver(ChromeOptions chromeOptions) {
293
288
if (!DriverManager .propertiesSelenium .getChromeDriverVersion ().isEmpty ()) {
294
289
System .setProperty ("wdm.chromeDriverVersion" , DriverManager .propertiesSelenium .getChromeDriverVersion ());
295
290
}
296
- downloadNewestOrGivenVersionOfWebDriver (ChromeDriver .class );
297
- OperationsOnFiles .moveWithPruneEmptydirectories (WebDriverManager .getInstance (ChromeDriver .class ).getDownloadedDriverPath (), browserPath );
291
+ downloadNewestOrGivenVersionOfWebDriver (ChromeDriver .class , browserPath );
298
292
}
299
293
driverDownloadedChrome = true ;
300
294
}
@@ -314,8 +308,7 @@ private static INewWebDriver getEdgeDriver(EdgeOptions edgeOptions) {
314
308
if (!DriverManager .propertiesSelenium .getEdgeDriverVersion ().isEmpty ()) {
315
309
System .setProperty ("wdm.edgeVersion" , DriverManager .propertiesSelenium .getEdgeDriverVersion ());
316
310
}
317
- downloadNewestOrGivenVersionOfWebDriver (EdgeDriver .class );
318
- OperationsOnFiles .moveWithPruneEmptydirectories (WebDriverManager .getInstance (EdgeDriver .class ).getDownloadedDriverPath (), browserPath );
311
+ downloadNewestOrGivenVersionOfWebDriver (EdgeDriver .class , browserPath );
319
312
}
320
313
driverDownloadedMicrosoftEdge = true ;
321
314
}
@@ -335,8 +328,7 @@ private static INewWebDriver getFirefoxDriver(FirefoxOptions firefoxOptions) {
335
328
if (!DriverManager .propertiesSelenium .getGeckoDriverVersion ().isEmpty ()) {
336
329
System .setProperty ("wdm.geckoDriverVersion" , DriverManager .propertiesSelenium .getGeckoDriverVersion ());
337
330
}
338
- downloadNewestOrGivenVersionOfWebDriver (FirefoxDriver .class );
339
- OperationsOnFiles .moveWithPruneEmptydirectories (WebDriverManager .getInstance (FirefoxDriver .class ).getDownloadedDriverPath (), browserPath );
331
+ downloadNewestOrGivenVersionOfWebDriver (FirefoxDriver .class , browserPath );
340
332
}
341
333
driverDownloadedFirefox = true ;
342
334
}
@@ -358,9 +350,7 @@ private static INewWebDriver getInternetExplorerDriver(InternetExplorerOptions i
358
350
.equals ("" )) {
359
351
System .setProperty ("wdm.internetExplorerDriverVersion" , DriverManager .propertiesSelenium .getInternetExplorerDriverVersion ());
360
352
}
361
- downloadNewestOrGivenVersionOfWebDriver (InternetExplorerDriver .class );
362
- OperationsOnFiles .moveWithPruneEmptydirectories (WebDriverManager .getInstance (InternetExplorerDriver .class ).getDownloadedDriverPath ()
363
- , browserPath );
353
+ downloadNewestOrGivenVersionOfWebDriver (InternetExplorerDriver .class , browserPath );
364
354
}
365
355
driverDownloadedInternetExplorer = true ;
366
356
}
0 commit comments