节点版本:v8.5.0
npm版本:5.3.0
geckodriver:v0.19.0
“selenium-webdriver”:“^ 3.5.0”
我正在尝试在nodejs中测试selenium webdriver,但是我一直收到以下错误:
/home/app_path/node_modules/selenium-webdriver/lib/promise.js:2634
throw error;
^
WebDriverError: connection refused
at Object.throwDecodedError (/home/app_path/node_modules/selenium-webdriver/lib/error.js:497:15)
at parseHttpResponse (/home/app_path/node_modules/selenium-webdriver/lib/http.js:519:13)
at doSend.then.response (/home/app_path/node_modules/selenium-webdriver/lib/http.js:441:30)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
From: Task: WebDriver.createSession()
at Function.createSession (/home/app_path/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/home/app_path/node_modules/selenium-webdriver/firefox/index.js:572:41)
at createDriver (/home/app_path/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (/home/app_path/node_modules/selenium-webdriver/index.js:645:16)
at Object.<anonymous> (/home/app_path/app.js:20:2)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:201:16)
at bootstrap_node.js:626:3
Mozilla firefox窗口刚打开,一段时间后,控制台中会出现此错误。这就是我想要做的事情:
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder()
.forBrowser('firefox')
.build().then(function(){
console.log("log");
driver.get("https://google.co.in");
});
如何解决这个问题?
编辑这是堆栈跟踪
{“value”:{“error”:“unknown error”,“message”:“connection refused”,“stacktrace”:“stack backtrace:\ n 0:0x4f388c - backtrace :: backtrace :: trace :: h736111741fa0878e \ n 1:0x4f38c2 - backtrace :: capture :: Backtrace :: new :: h63b8a5c0787510c9 \ n 2:0x442d88 - webdriver :: error :: WebDriverError :: new :: hea6d4dbf778b2b24 \ n 3:0x449f99 - geckodriver :: marionette: :MarionetteHandler :: create_connection :: hf8b6061dba65cdd0 \ n 4:0x42ac91 - &gt; :: run :: hba9181b5aacf8f04 \ n 5:0x402c59 - std :: sys_common :: backtrace :: __ rust_begin_short_backtrace :: h19de262639927233 \ n 6:0x40c065 - std ::恐慌:: try :: do_call :: h6c1659fc4d01af51 \ n 7:0x5e38ec - panic_unwind :: __ rust_maybe_catch_panic \ n在/checkout/src/libpanic_unwind/lib.rs:98\n 8:0x420d32 - &gt; :: call_box :: h953e5f59694972c5 \ n 9:0x5dc00b - alloc :: boxed :: {{impl}} :: call_once&lt;(),()&gt; \ n at / checkout / src /liballoc/boxed.rs:661\n - std :: sys_common :: thread :: start_thread \ n在/checkout/src/libstd/sys_common/thread.rs:21\n - std :: sys :: imp :: thread :: {{impl}} :: new :: thread_start \ n at /checkout/src/libstd/sys/unix/thread.rs:84“}}