简体   繁体   English

NodeJS Selenium Chrome Webdriver连接被拒绝

[英]NodeJS Selenium Chrome Webdriver Connection Refused

I'm new to NodeJS and Selenium Webdriver and I wanted to launch a simple test code: 我是NodeJS和Selenium Webdriver的新手,我想启动一个简单的测试代码:

 var webdriver = require("selenium-webdriver"); function createDriver() { var driver = new webdriver.Builder() .usingServer('http://localhost:4444/wd/hub') .withCapabilities(webdriver.Capabilities.chrome()) .build(); driver.manage().timeouts().setScriptTimeout(10000); return driver; } var driver = createDriver(); driver.get("http://www.google.com"); driver.getTitle().then(function (title) { console.log(title); }); driver.quit(); 

I have everything setup, the chrome driver and the server launched. 我已完成所有设置,启动了chrome驱动程序和服务器。

But I'm getting this error: 但我收到此错误:

(node:3080) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): WebDriverError: java.net.ConnectException: Connection refused: connect (node:3080) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. (节点:3080)UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝ID:2):WebDriverError:java.net.ConnectException:连接被拒绝:connect(节点:3080)[DEP0018] DeprecationWarning:已弃用未处理的承诺拒绝。 In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 将来,未处理的承诺拒绝将以非零退出代码终止Node.js进程。 (node:3080) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): WebDriverError: java.net.ConnectException: Connection refused: connect (node:3080) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): WebDriverError: java.net.ConnectException: Connection refused: connect (节点:3080)UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝ID:3):WebDriverError:java.net.ConnectException:连接被拒绝:connect(节点:3080)UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝ID:4):WebDriverError:Java。 net.ConnectException:连接被拒绝:connect

Can you guys please help? 你们能帮忙吗? Thanks! 谢谢!

Have you installed all the relevant modules including chromedriver using npm i --save-dev? 您是否已使用npm i --save-dev安装了所有相关模块,包括chromedriver?

Are you able to access the localhost url manually? 您可以手动访问localhost网址吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM