Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/org/labkey/test/BaseWebDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
import org.labkey.remoteapi.CommandException;
import org.labkey.remoteapi.CommandResponse;
import org.labkey.remoteapi.Connection;
import org.labkey.remoteapi.admin.ClearCachesCommand;
import org.labkey.remoteapi.SimpleGetCommand;
import org.labkey.remoteapi.SimplePostCommand;
import org.labkey.remoteapi.admin.ClearCachesCommand;
import org.labkey.remoteapi.collections.CaseInsensitiveHashMap;
import org.labkey.remoteapi.query.ContainerFilter;
import org.labkey.remoteapi.query.Filter;
Expand Down Expand Up @@ -2929,17 +2929,41 @@ private void tearDown(boolean closeOldBrowser)
}
finally
{
clear();
clear(closeOldBrowser);
}
}

private void clear()
{
if (getDriverService() != null && getDriverService().isRunning())
clear(true);
}

private void clear(boolean closedOldBrowser)
{
if (getDriverService() != null && getDriverService().isRunning() && !shouldLeaveDriverServiceRunning(closedOldBrowser))
getDriverService().stop();
// Don't clear _downloadDir. Cleanup steps might still need it after tearDown
_driverAndService = new ImmutablePair<>(null, null);
}

/**
* Starting with Geckodriver v0.37.0, shutting down the driver service also shuts down the browser.
* We need to leave the FirefoxDriverService running after test failures to allow manual inspection of the
* browser state.
* We can remove this if they add a 'detach' flag to Geckodriver, similar to the one in Chromedriver.
* https://github.com/mozilla/geckodriver/issues/2247
* https://bugzilla.mozilla.org/show_bug.cgi?id=2046321
*
* @param closedOldBrowser Indicates that WebDriver was closed
* @return true if the DriverService should be left running
*/
private boolean shouldLeaveDriverServiceRunning(boolean closedOldBrowser)
{
return !closedOldBrowser // Don't leave DriverService running if browser was closed
&& BrowserType.FIREFOX.matchesDriver(getWebDriver())
&& TestProperties.allowZombieGeckodriver()
&& !TestProperties.isTestRunningOnTeamCity();
}
}

private static class CspCheckPageLoadListener implements PageLoadListener
Expand Down
5 changes: 5 additions & 0 deletions src/org/labkey/test/TestProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public static boolean isNewWebDriverForEachTest()
return !getBooleanProperty("selenium.reuseWebDriver", false);
}

public static boolean allowZombieGeckodriver()
{
return getBooleanProperty("webtest.allowZombieGeckodriver", false);
}

public static boolean isViewCheckSkipped()
{
return !getBooleanProperty("viewCheck", true);
Expand Down
3 changes: 3 additions & 0 deletions test.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ cleanOnly=false
#webtest.log.level=DEBUG
## Set whether DeferredErrorCollector should fail immediately when errors are encountered (default: false)
#webtest.checker.fatal=true
## Set to leave Geckodriver running after test failures (https://github.com/mozilla/geckodriver/issues/2247)
## Note: requires you to manually kill 'geckodriver' processes (`killall geckodriver`)
#webtest.allowZombieGeckodriver=true


#==============================================================================
Expand Down