Close/quit webDriver in future thread #199

Closed
admizh opened this Issue Jul 25, 2015 · 2 comments

Projects

None yet

2 participants

@admizh
Contributor
admizh commented Jul 25, 2015

Hi Andrey,
Sometimes i have problems with calling driver.close () or driver.quit () method, and test always is suspended too long timeout. I think we should close the driver in hockable thread (in com.codeborne.selenide.impl.WebDriverThreadLocalContainer#closeWebDriver(java.lang.Thread))

private synchronized static void closeWithTimer(WebDriver driver) {
        THREAD_DRIVER_STATE_STORAGE.markDriverIsClose();
        Future<?> future = Executors.newSingleThreadExecutor().submit((Runnable) driver::close);
        try {
            future.get(100, SECONDS);
        } catch (InterruptedException | java.util.concurrent.TimeoutException e) {
            throw new SkipException("Long wait for killing browser", e);
        } catch (ExecutionException e) {
            throw new SkipException("Error on browser kill " + e.getMessage(), e);
        }
    }
@admizh admizh changed the title from Close/quit webDriver to Future to Close/quit webDriver in future thread Jul 25, 2015
@asolntsev
Member

Nice! Let's do it.
Actually we also experience problems with closing webdrivers, so it will help us too.

@asolntsev
Member

Done in Selenide 2.20
Timeout is 5 seconds by default. Can be configured via system property selenide.closeBrowserTimeout (default value is 5000).

@asolntsev asolntsev closed this Jul 26, 2015
@asolntsev asolntsev added a commit that referenced this issue Jul 26, 2015
@asolntsev asolntsev #199 1240493
@asolntsev asolntsev added this to the 2.20 milestone Jul 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment