From 27e7f187f674e306b9a69a3e92d8275871334a10 Mon Sep 17 00:00:00 2001 From: amiralam0 Date: Sun, 21 Aug 2022 01:00:39 -0700 Subject: [PATCH] custom chrome binary options If somebody didnt have chrome installed and want to pass the chrome path explicitly he/she can pass the binary path and the driver will still work --- lib/browser.js | 4 +++- lib/jwebdriver.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/browser.js b/lib/browser.js index 17535d5..311aaae 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -141,11 +141,12 @@ const Browser = PromiseClass.create({ * @param {String} platform * @param {Function} done callback function */ - constructor(driver, browserName, version, platform){ + constructor(driver, browserName, version, binaryPath,platform){ let self = this; self._driver = driver; self.browserName = browserName; self.version = version; + self.binaryPath = binaryPath; self.platform = platform; }, @@ -219,6 +220,7 @@ const Browser = PromiseClass.create({ args: ['--enable-automation', '--incognito'], }, } + if(self.binaryPath) sessionInfo.chromeOptions['binary'] = self.binaryPath; } if (sessionInfo.browserName !== 'chrome' && sessionInfo.chromeOptions) { delete sessionInfo.chromeOptions; diff --git a/lib/jwebdriver.js b/lib/jwebdriver.js index 2276654..7ccead4 100644 --- a/lib/jwebdriver.js +++ b/lib/jwebdriver.js @@ -297,7 +297,7 @@ const JWebDriver = PromiseClass.create({ * @param {Function} done callback function * @return {Browser} Browser object */ - session(browserName, version, platform, done){ + session(browserName, version, platform, binaryPath = false,done){ var self = this; if(typeof version === 'function'){ version = undefined; @@ -307,7 +307,7 @@ const JWebDriver = PromiseClass.create({ platform = undefined; } done = getDone(arguments); - let browser = new Browser(self, browserName, version, platform); + let browser = new Browser(self, browserName, version, binaryPath,platform); browser.init(function(error){ self.lastBrowser = browser; done(error, browser);