我有以下 Javascript 代码,它使用由指定的 Chrome 路径启动 ChromePATH
环境变量。
let driver = await new Builder()
.forBrowser('chrome')
.build();
如何使用 Chrome 的特定路径启动 Chrome?我会喜欢这样的东西:
let driver = await new Builder()
.forBrowser('chrome')
.withPath('C:\\temp\\chrome.exe')
.build();
您可能需要使用 ChromeOptions 来设置自定义 chrome.exe
const webdriver = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const builder = new webdriver.Builder().forBrowser('chrome');
const chromeOptions = new chrome.Options();
chromeOptions.setChromeBinaryPath("/path/to/chrome.exe");
builder.setChromeOptions(chromeOptions);
const driver = builder.build();
文档 https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/chrome_exports_Options.html for chrome.选项
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)