执行量角器测试时,它在--headless
模式下成功,但是当我删除--headless
选项时,它失败了,指出:user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
。
如您所见,我没有使用那个特定的论点,所以我不知道该怎么做。
更新:当crome浏览器选项卡打开时,data:,
位于地址栏中。
错误
$ protractor conf.js
[14:10:17] I/launcher - Running 1 instances of WebDriver
[14:10:17] I/direct - Using ChromeDriver directly...
[14:10:18] E/launcher - invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
(Driver info: chromedriver=79.0.3945.16 (93fcc21110c10dbbd49bbff8f472335360e31d05-refs/branch-heads/3945@{#262}),platform=Windows NT 10.0.17763 x86_64)
[14:10:18] E/launcher - WebDriverError: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
(Driver info: chromedriver=79.0.3945.16 (93fcc21110c10dbbd49bbff8f472335360e31d05-refs/branch-heads/3945@{#262}),platform=Windows NT 10.0.17763 x86_64)
at Object.checkLegacyResponse (C:Installnode-v12.13.1-win-x64node_modulesprotractornode_modulesselenium-webdriverliberror.js:546:15)
at parseHttpResponse (C:Installnode-v12.13.1-win-x64node_modulesprotractornode_modulesselenium-webdriverlibhttp.js:509:13)
at C:Installnode-v12.13.1-win-x64node_modulesprotractornode_modulesselenium-webdriverlibhttp.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:93:5)
From: Task: WebDriver.createSession()
at Function.createSession (C:Installnode-v12.13.1-win-x64node_modulesprotractornode_modulesselenium-webdriverlibwebdriver.js:769:24)
at Function.createSession (C:Installnode-v12.13.1-win-x64node_modulesprotractornode_modulesselenium-webdriverchrome.js:761:15)
at Direct.getNewDriver (C:Installnode-v12.13.1-win-x64node_modulesprotractorbuiltdriverProvidersdirect.js:77:33)
at Runner.createBrowser (C:Installnode-v12.13.1-win-x64node_modulesprotractorbuiltrunner.js:195:43)
at C:Installnode-v12.13.1-win-x64node_modulesprotractorbuiltrunner.js:339:29
at _fulfilled (C:Installnode-v12.13.1-win-x64node_modulesprotractornode_modulesqq.js:834:54)
at C:Installnode-v12.13.1-win-x64node_modulesprotractornode_modulesqq.js:863:30
at Promise.promise.promiseDispatch (C:Installnode-v12.13.1-win-x64node_modulesprotractornode_modulesqq.js:796:13)
at C:Installnode-v12.13.1-win-x64node_modulesprotractornode_modulesqq.js:556:49
at runSingle (C:Installnode-v12.13.1-win-x64node_modulesprotractornode_modulesqq.js:137:13)
[14:10:18] E/launcher - Process exited with error code 199
配置
exports.config = {
chromeOnly: true,
directConnect: true,
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox', "--headless", "--disable-gpu", "--window-size=800,600"]
},
},
specs: ['login.jenkins.js']
};
此错误的原因是在不同的配置文件上运行多个 chrome 浏览器实例。当量角器启动测试时,Chrome 会创建一个默认配置文件,并在该配置文件上运行测试。如果有多个 chrome 实例正在运行,Chrome 会在 --user-data-dir 参数中询问您的用户定义的配置文件。
这意味着在开始测试之前,您应该确保没有挂起的 chrome 进程正在运行。检查正在运行的进程并删除这些进程。然后,请确保在配置文件中添加如下所示的onComplete部分,以便在测试完成后关闭Chrome浏览器实例。这是代码片段。
onComplete: async () => {
await browser.driver.close();
await browser.driver.quit();
}
尝试一次!可能会解决您面临的问题。