0

我正在尝试使用 Protractor 和 Cucumber 对 Angular 项目进行 E2E 测试。我安装了量角器 v5.4.4。我第一次运行ng e2e测试运行成功,第二次出现此错误:

EPERM: operation not permitted, rename 'C:\Users\dmdum\Projects\angular-project\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver.exe' -> 'C:\Users\dmdum\Projects\angular-project\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_96.0.4664.45.exe'
Error: EPERM: operation not permitted, rename 'C:\Users\dmdum\Projects\angular-project\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver.exe' -> 'C:\Users\dmdum\Projects\angular-project\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_96.0.4664.45.exe'
    at Object.renameSync (fs.js:741:3)
    at unzip (C:\Users\dmdum\Projects\angular-project\node_modules\protractor\node_modules\webdriver-manager\built\lib\cmds\update.js:240:8)
    at C:\Users\dmdum\Projects\angular-project\node_modules\protractor\node_modules\webdriver-manager\built\lib\cmds\update.js:205:13
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 0)

chromedriver_96.0.4664.45.exe已存在于指定路径

为了让我再次成功运行测试,我需要删除selenium路径中指定的文件夹,然后npx webdriver-manager update再次运行,然后ng e2e

但这不是处理问题的好方法。任何帮助/建议将不胜感激。谢谢!

4

1 回答 1

0

看起来您的 webdriver 没有正确安装,请尝试在您的项目根目录中运行它以清理并获取所有 web 驱动程序: npx webdriver-manager update

您还可以将其作为postinstall脚本添加到您的中package.json,以便在每个npm i(或npm ci)之后运行:

包.json:

...
"scripts": {
    ...
    "update-webdriver": "npx webdriver-manager update",
    "postinstall": "echo 'Now updating web drivers' && npm run update-webdriver",
    ...
}
...
于 2022-01-04T15:03:52.730 回答