(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) [DEP0018] 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
给个方向就可以了!!谢谢作者: zhangweiyang 时间: 2018-6-7 15:42
经过一些探索,我感觉是浏览器驱动版本跟不上,不兼容的问题,我再尝试一下。