Skip to content

Commit 2ac72e0

Browse files
rnorthbsideup
authored andcommitted
Add time limit and retry to instantiation of RemoteWebDriver (#381)
* Add time limit and retry to instantiation of RemoteWebDriver Resolves #373 * Update changelog
1 parent b98af3f commit 2ac72e0

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
66
- Fixed the case when disk's size is bigger than Integer's max value (#379, #380)
77
- Fix erroneous version reference used during CI testing of shaded dependencies
88
- Fix leakage of Vibur and Tomcat JDBC test dependencies in `jdbc-test` and `mysql` modules (#382)
9+
- Add timeout and retries for creation of `RemoteWebDriver` (#381, #373, #257)
910

1011
### Changed
1112
- Added support for Docker networks (#372)

modules/selenium/src/main/java/org/testcontainers/containers/BrowserWebDriverContainer.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import org.openqa.selenium.remote.BrowserType;
77
import org.openqa.selenium.remote.DesiredCapabilities;
88
import org.openqa.selenium.remote.RemoteWebDriver;
9+
import org.rnorth.ducttape.timeouts.Timeouts;
10+
import org.rnorth.ducttape.unreliables.Unreliables;
911
import org.slf4j.Logger;
1012
import org.slf4j.LoggerFactory;
1113
import org.testcontainers.containers.traits.LinkableContainer;
@@ -20,6 +22,7 @@
2022
import java.util.ArrayList;
2123
import java.util.Collection;
2224
import java.util.Date;
25+
import java.util.concurrent.TimeUnit;
2326

2427
import static com.google.common.base.Preconditions.checkState;
2528
import static java.time.temporal.ChronoUnit.SECONDS;
@@ -157,7 +160,11 @@ protected void containerIsStarted(InspectContainerResponse containerInfo) {
157160
recordingSidekickContainer.start();
158161
currentVncRecordings.add(recordingSidekickContainer);
159162
}
160-
this.driver = new RemoteWebDriver(getSeleniumAddress(), desiredCapabilities);
163+
164+
driver = Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS,
165+
Timeouts.getWithTimeout(10, TimeUnit.SECONDS,
166+
() ->
167+
() -> new RemoteWebDriver(getSeleniumAddress(), desiredCapabilities)));
161168
}
162169

163170
/**

0 commit comments

Comments
 (0)