Fix crash when running inside Selenium

@coryvirok