Skip to content

Commit

Permalink
Add time limit and retry to instantiation of RemoteWebDriver (#381)
Browse files Browse the repository at this point in the history
* Add time limit and retry to instantiation of RemoteWebDriver
Resolves #373

* Update changelog
  • Loading branch information
rnorth authored and bsideup committed Jun 28, 2017
1 parent b98af3f commit 2ac72e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
- Fixed the case when disk's size is bigger than Integer's max value (#379, #380)
- Fix erroneous version reference used during CI testing of shaded dependencies
- Fix leakage of Vibur and Tomcat JDBC test dependencies in `jdbc-test` and `mysql` modules (#382)
- Add timeout and retries for creation of `RemoteWebDriver` (#381, #373, #257)

### Changed
- Added support for Docker networks (#372)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.rnorth.ducttape.timeouts.Timeouts;
import org.rnorth.ducttape.unreliables.Unreliables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.traits.LinkableContainer;
Expand All @@ -20,6 +22,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.concurrent.TimeUnit;

import static com.google.common.base.Preconditions.checkState;
import static java.time.temporal.ChronoUnit.SECONDS;
Expand Down Expand Up @@ -157,7 +160,11 @@ protected void containerIsStarted(InspectContainerResponse containerInfo) {
recordingSidekickContainer.start();
currentVncRecordings.add(recordingSidekickContainer);
}
this.driver = new RemoteWebDriver(getSeleniumAddress(), desiredCapabilities);

driver = Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS,
Timeouts.getWithTimeout(10, TimeUnit.SECONDS,
() ->
() -> new RemoteWebDriver(getSeleniumAddress(), desiredCapabilities)));
}

/**
Expand Down

0 comments on commit 2ac72e0

Please sign in to comment.