gpt4 book ai didi

node.js - Selenium 与 PhantomJs 和 NodeJs

转载 作者:太空宇宙 更新时间:2023-11-04 02:32:57 24 4
gpt4 key购买 nike

我使用 Express 创建了一个项目,现在我尝试使用 Phantomjs 运行 selenium 代码。

我有:

var app = express();

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.phantomjs()).
build();

但是当我尝试运行时出现此错误:

path/node_modules/selenium-webdriver/phantomjs.js:72
throw Error(
^
Error: The PhantomJS executable could not be found on the current PATH. Please download the latest version from http://phantomjs.org/download.html and ensure it can be found on your PATH. For more information, see https://github.com/ariya/phantomjs/wiki
at Error (<anonymous>)
at findExecutable (/home/antonio/node_modules/selenium-webdriver/phantomjs.js:72:11)
at Object.createDriver (/home/antonio/node_modules/selenium-webdriver/phantomjs.js:108:13)
at createNativeDriver (/home/antonio/node_modules/selenium-webdriver/builder.js:43:24)
at Builder.build (/home/antonio/node_modules/selenium-webdriver/builder.js:96:18)
at Object.<anonymous> (/home/antonio/projectNode/ExpressProject/app.js:18:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

最佳答案

你需要为你的操作系统安装 Phantom JS 包,我使用的是 Ubuntu,所以我这样做了

sudo apt-get install phantomjs

这个错误消失了,如果你已经安装了 phantomjs 包,那么你的路径设置出了问题,请为 phantomjs 设置路径变量

关于node.js - Selenium 与 PhantomJs 和 NodeJs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24883520/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com