From 25bfd5bdef638d41cf54da31ac0b6b16ff5912ba Mon Sep 17 00:00:00 2001 From: "Zhuohuan LI (CARPE DIEM)" Date: Thu, 27 Oct 2016 03:38:31 +0800 Subject: [PATCH] selenium find `chromedriver.exe` by default under win32, so we have to specify the `chromedriver`.path in order to make it work with npm module `chromedriver` --- src/puppet-web/browser-driver.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/puppet-web/browser-driver.ts b/src/puppet-web/browser-driver.ts index 795ed248..e458982a 100644 --- a/src/puppet-web/browser-driver.ts +++ b/src/puppet-web/browser-driver.ts @@ -75,15 +75,20 @@ export class BrowserDriver { * issue #56 * only need under win32 with cygwin * and will cause strange error: - * `The previously configured ChromeDriver service is still running. You must shut it down before you may adjust its configuration.` - + * + */ const chrome = require('selenium-webdriver/chrome') const path = require('chromedriver').path const service = new chrome.ServiceBuilder(path).build() - chrome.setDefaultService(service) - - */ + try { + chrome.setDefaultService(service) + } catch (e) { // fail safe + /** + * `The previously configured ChromeDriver service is still running.` + * `You must shut it down before you may adjust its configuration.` + */ + } const options = { args: ['--no-sandbox'] // issue #26 for run inside docker -- GitLab