zhangweiyang 发表于 2018-6-7 14:14:49

新人求教:js脚本启动Chrome浏览器崩溃

大神们,想请教一下我用js脚本启动浏览器一直失败,我感觉又不是版本不兼容问题,但是一直没有头绪。有大神给个方向吗?谢谢各位!!
----------------------------脚本代码-----------------------------
const {Builder, By, Key, until} = require('selenium-webdriver');

(async function example() {
let driver = await new Builder().forBrowser('chrome').build();
try {
    await driver.get('https://www.baidu.com/');
    await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
    await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
} finally {
    await driver.quit();
}
})();
----------------------------错误代码-----------------------------
D:\Documents\Downloads\test>node Untitled-1.js
(node:11576) UnhandledPromiseRejectionWarning: WebDriverError: unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)
    at Object.checkLegacyResponse (D:\Documents\Downloads\test\node_modules\selenium-webdriver\lib\error.js:585:15)
    at parseHttpResponse (D:\Documents\Downloads\test\node_modules\selenium-webdriver\lib\http.js:533:13)
    at Executor.execute (D:\Documents\Downloads\test\node_modules\selenium-webdriver\lib\http.js:468:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:11576) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11576) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

zhangweiyang 发表于 2018-6-7 14:16:07

给个方向就可以了!!谢谢

zhangweiyang 发表于 2018-6-7 15:42:21

经过一些探索,我感觉是浏览器驱动版本跟不上,不兼容的问题,我再尝试一下。
页: [1]
查看完整版本: 新人求教:js脚本启动Chrome浏览器崩溃