As of version 1.6.0 the option of forcing the driver to refer to what is cached locally became an option. I was wondering what would happen if there's nothing cached yet?
I'm asking because I have a project that relies on this which several people in our organization rely on if they're running this for the first time and nothing is cached, would .forceCache() fail or would it fall back on going to the remote repository for the driver?
Otherwise, I would guess I'll need an initialization method that goes out and gets them the first time. Thanks for any help or information.
If forceCache()
method is used and there is nothing cached, WebDriverManager downloads the latest version from the online repository.
Unfortunately, there was a bug version 1.6.0 that makes this method (forceCache()
) useless (it doesn't work properly). Fortunately, this has been fixed in version 1.6.1, just released at the time of this writing.
For example, the following test case:
public class ChromeTest {
private WebDriver driver;
@BeforeClass
public static void setupClass() {
ChromeDriverManager.getInstance().forceCache().setup();
}
@Before
public void setupTest() {
driver = new ChromeDriver();
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test() {
// test code here
}
}
... running by the first time (and without any chromedriver cached) will download the latest version of chromedriver. See the log:
[2017-03-08 17:27:27:574] [main] INFO BrowserManager - Reading https://chromedriver.storage.googleapis.com/ to seek [chromedriver]
[2017-03-08 17:27:29:728] [main] INFO BrowserManager - Latest version of [chromedriver] is 2.27
[2017-03-08 17:27:29:730] [main] INFO Downloader - Downloading https://chromedriver.storage.googleapis.com/2.27/chromedriver_linux64.zip to /home/boni/.m2/repository/webdriver/chromedriver/linux64/2.27/chromedriver_linux64.zip
[2017-03-08 17:27:30:354] [main] INFO BrowserManager - Exporting webdriver.chrome.driver as /home/boni/.m2/repository/webdriver/chromedriver/linux64/2.27/chromedriver
Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 3907
Only local connections are allowed.
Mar 08, 2017 5:27:31 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
... when running the same test the second time, then the cached version will be used:
[2017-03-08 17:27:37:124] [main] INFO BrowserManager - Found chromedriver in cache: /home/boni/.m2/repository/webdriver/chromedriver/linux64/2.27/chromedriver
[2017-03-08 17:27:37:125] [main] INFO BrowserManager - Exporting webdriver.chrome.driver as /home/boni/.m2/repository/webdriver/chromedriver/linux64/2.27/chromedriver
Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 31776
Only local connections are allowed.
Mar 08, 2017 5:27:38 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS