mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Reconnect to webdriver after 100 test runs
This commit is contained in:
parent
0aa8f8bda7
commit
9f05eaef21
|
@ -39,6 +39,7 @@ public class SeleniumRunStrategy implements TestRunStrategy {
|
|||
private URL url;
|
||||
private File directory;
|
||||
private ThreadLocal<WebDriver> webDriver = new ThreadLocal<>();
|
||||
private ThreadLocal<Integer> commandsSent = new ThreadLocal<>();
|
||||
|
||||
public SeleniumRunStrategy(URL url, File directory) {
|
||||
this.url = url;
|
||||
|
@ -49,6 +50,7 @@ public class SeleniumRunStrategy implements TestRunStrategy {
|
|||
public void beforeThread() {
|
||||
RemoteWebDriver driver = new RemoteWebDriver(url, DesiredCapabilities.firefox());
|
||||
webDriver.set(driver);
|
||||
commandsSent.set(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,6 +61,13 @@ public class SeleniumRunStrategy implements TestRunStrategy {
|
|||
|
||||
@Override
|
||||
public String runTest(Log log, String runtimeScript, TestCase testCase) throws IOException {
|
||||
commandsSent.set(commandsSent.get() + 1);
|
||||
if (commandsSent.get().equals(100)) {
|
||||
commandsSent.set(0);
|
||||
webDriver.get().close();
|
||||
webDriver.set(new RemoteWebDriver(url, DesiredCapabilities.firefox()));
|
||||
}
|
||||
|
||||
webDriver.get().manage().timeouts().setScriptTimeout(2, TimeUnit.SECONDS);
|
||||
JavascriptExecutor js = (JavascriptExecutor) webDriver.get();
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue
Block a user