Selenium:连接被拒绝,找不到驱动程序

时间:2017-10-31 01:09:57

标签: java selenium

我在本地运行selenium服务器试图在Linux上运行Firefox的一些测试。 我像这样运行服务器命令:

java -Dwebdriver.firefox.bin=/usr/bin/firefox -Dwebdriver.firefox.marionette=/home/niru/selenium/geckodriver -jar /home/niru/selenium/selenium-server-standalone-3.5.0.jar

当我运行测试命令时,我注意到一些问题:
错误:Caused by: org.openqa.selenium.WebDriverException: connection refused
错误:Driver info: driver.version: unknown
问题:输出显示Binding default provider to: Org.openqa.selenium.chrome.ChromeDriverService

关注:https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver我验证并确保我的$ PATH变量有/home/niru/selenium/geckodriver。运行测试时,Firefox浏览器窗口也会打开。

是否有理由使用chromedriverservice并且无法找到驱动程序版本?

例外:

 [testng] Caused by: org.openqa.selenium.WebDriverException: connection refused
   [testng] Build info: version: '3.5.0', revision: '8def36e068', time: '2017-08-10T23:00:22.093Z'
   [testng] System info: host: '<myhost>', ip: '<ip>', os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.45-0.6.wd.865.49.315.metal1.x86_64', java.version: '1.8.0_112'
   [testng] Driver info: driver.version: unknown
   [testng] remote stacktrace: stack backtrace:
   [testng]    0:           0x4f388c - backtrace::backtrace::trace::h736111741fa0878e
   [testng]    1:           0x4f38c2 - backtrace::capture::Backtrace::new::h63b8a5c0787510c9
   [testng]    2:           0x442d88 - webdriver::error::WebDriverError::new::hea6d4dbf778b2b24
   [testng]    3:           0x449f99 - geckodriver::marionette::MarionetteHandler::create_connection::hf8b6061dba65cdd0
   [testng]    4:           0x42ac91 - <webdriver::server::Dispatcher<T, U>>::run::hba9181b5aacf8f04
   [testng]    5:           0x402c59 - std::sys_common::backtrace::__rust_begin_short_backtrace::h19de262639927233
   [testng]    6:           0x40c065 - std::panicking::try::do_call::h6c1659fc4d01af51
   [testng]    7:           0x5e38ec - panic_unwind::__rust_maybe_catch_panic
   [testng]                         at /checkout/src/libpanic_unwind/lib.rs:98
   [testng]    8:           0x420d32 - <F as alloc::boxed::FnBox<A>>::call_box::h953e5f59694972c5
   [testng]    9:           0x5dc00b - alloc::boxed::{{impl}}::call_once<(),()>
   [testng]                         at /checkout/src/liballoc/boxed.rs:661
   [testng]                          - std::sys_common::thread::start_thread
   [testng]                         at /checkout/src/libstd/sys_common/thread.rs:21
   [testng]                          - std::sys::imp::thread::{{impl}}::new::thread_start
   [testng]                         at /checkout/src/libstd/sys/unix/thread.rs:84
   [testng] Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
   [testng] System info: host: '<myhost>', ip: '<myip>', os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.45-0.6....x86_64', java.version: '1.8.0_152'
   [testng] Driver info: driver.version: unknown
   [testng]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   [testng]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
   [testng]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
   [testng]     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
   [testng]     at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
   [testng]     at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
   [testng]     at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:360)
   [testng]     at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
   [testng]     at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
   [testng]     at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
   [testng]     at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
   [testng]     at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
   [testng]     at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
   [testng]     at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
   [testng]     at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
   [testng]     at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
   [testng]     at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:363)
   [testng]     at org.openqa.selenium.remote.server.ServicedSession$Factory.apply(ServicedSession.java:159)
   [testng]     at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$createSession$15(ActiveSessionFactory.java:148)
   [testng]     at java.util.Optional.map(Optional.java:215)
   [testng]     at org.openqa.selenium.remote.server.ActiveSessionFactory.createSession(ActiveSessionFactory.java:148)
   [testng]     at org.openqa.selenium.remote.server.BeginSession.execute(BeginSession.java:69)
   [testng]     at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0(WebDriverServlet.java:231)
   [testng]     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   [testng]     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   [testng]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   [testng]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   [testng]     at java.lang.Thread.run(Thread.java:745)

1 个答案:

答案 0 :(得分:2)

似乎无法加载geckodriver并尝试默认加载chromedriver:

Binding default provider to: Org.openqa.selenium.chrome.ChromeDriverService

您是否正在使用selenium-server-standalone-3.5.0.jar,建议使用geckodriver版本和您使用的浏览器?

无论如何,确保geckodriver是可执行的:

  • chmod + x geckodriver