嘿我正在尝试在
上启动Selenium实例我一直收到这个错误。
/var/www/node-bin/portlight-orders/node_modules/selenium-webdriver/lib/webdriver.js:432
throw new error.NoSuchSessionError(
^
NoSuchSessionError: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
at WebDriverError (/var/www/node-bin/portlight-orders/node_modules/selenium-webdriver/lib/error.js:27:5)
at NoSuchSessionError (/var/www/node-bin/portlight-orders/node_modules/selenium-webdriver/lib/error.js:122:5)
at checkHasNotQuit (/var/www/node-bin/portlight-orders/node_modules/selenium-webdriver/lib/webdriver.js:432:15)
at Driver.schedule (/var/www/node-bin/portlight-orders/node_modules/selenium-webdriver/lib/webdriver.js:393:5)
at Driver.quit (/var/www/node-bin/portlight-orders/node_modules/selenium-webdriver/lib/webdriver.js:480:23)
at exitHandler (/var/www/node-bin/portlight-orders/api/services/Selenium.js:12:9)
at emitOne (events.js:96:13)
at process.emit (events.js:188:7)
at process._fatalException (bootstrap_node.js:296:26)
瞥了一眼我发现chromedriver正在运行 http://image.prntscr.com/image/dfc336afbf6f46d59017b4135e9547c3.png
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder()
.forBrowser('chrome')
.build();
module.exports = driver;
function exitHandler(options, err) {
driver.quit()
}
//do something when app is closing
process.on('exit', exitHandler.bind(null,{cleanup:true}));
//catches ctrl+c event
process.on('SIGINT', exitHandler.bind(null, {exit:true}));
//catches uncaught exceptions
process.on('uncaughtException', exitHandler.bind(null, {exit:true}));
答案 0 :(得分:0)
在使用任何驱动程序实例之前,请检查该驱动程序会话是否处于活动状态,我们有两种情况 1.会话ID存在 如果会话ID存在,那么我们可以更进一步 2.会话ID不存在 所以我们不能再进一步停止