我尝试在debian服务器上运行我的selenium测试,但我一直从我的geckodriver获得连接拒绝错误。在我的本地机器上运行Ubuntu完美运行。你们有谁知道出了什么问题?我找不到任何有用的东西。
操作系统:Debian Jessie设置方法
public static void setUp() { //System.setProperty("webdriver.gecko.driver", "geckodriver.exe"); //For debugging in windows System.setProperty("webdriver.gecko.driver", "geckodriver"); //for execution on linux //Bypass System.err while loading Webdriver PrintStream err = System.err; System.setErr(new PrintStream(new NullOutputStream())); driver = new FirefoxDriver(); System.setErr(err); webDriverWait = new WebDriverWait(driver, 1000); }
错误消息
org.openqa.selenium.WebDriverException: connection refused 14:44:04.899 [DEBUG] [TestEventLogger] Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' 14:44:04.899 [DEBUG] [TestEventLogger] System info: host: 'security', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-4-amd64', java.version: '1.8.0_131' 14:44:04.899 [DEBUG] [TestEventLogger] Driver info: driver.version: FirefoxDriver 14:44:04.899 [DEBUG] [TestEventLogger] remote stacktrace: stack backtrace: 14:44:04.899 [DEBUG] [TestEventLogger] 0: 0x4fa94d - backtrace::backtrace::trace::h45ace4059cd74233 14:44:04.899 [DEBUG] [TestEventLogger] 1: 0x4fae32 - backtrace::capture::Backtrace::new::hb5a725a088a2a2fc 14:44:04.900 [DEBUG] [TestEventLogger] 2: 0x4349d9 - webdriver::error::WebDriverError::new::h449345a591a119fd 14:44:04.900 [DEBUG] [TestEventLogger] 3: 0x43f6b0 - geckodriver::marionette::MarionetteHandler::create_connection::h53f581202e4008b4 14:44:04.900 [DEBUG] [TestEventLogger] 4: 0x442839 - >::handle_command::hd89c5efbeb4c7cd5 14:44:04.900 [DEBUG] [TestEventLogger] 5: 0x434e94 - webdriver::server::start::{{closure}}::h5e71183f67357de6 14:44:04.900 [DEBUG] [TestEventLogger] 6: 0x408627 - std::panicking::try::do_call::h8c30e6af4c7f85af 14:44:04.904 [DEBUG] [TestEventLogger] 7: 0x5b77fa - panic_unwind::__rust_maybe_catch_panic 14:44:04.904 [DEBUG] [TestEventLogger] at /buildslave/rust-buildbot/slave/stable-dist-rustc-musl-linux/build/src/libpanic_unwind/lib.rs:98 14:44:04.907 [DEBUG] [TestEventLogger] 8: 0x416e57 - >::call_box::h3f273b2445d78deb 14:44:04.907 [DEBUG] [TestEventLogger] 9: 0x5b0014 - alloc::boxed::{{impl}}::call_once<(),()> 14:44:04.907 [DEBUG] [TestEventLogger] at /buildslave/rust-buildbot/slave/stable-dist-rustc-musl-linux/build/src/liballoc/boxed.rs:624 14:44:04.907 [DEBUG] [TestEventLogger] - std::sys_common::thread::start_thread 14:44:04.907 [DEBUG] [TestEventLogger] at /buildslave/rust-buildbot/slave/stable-dist-rustc-musl-linux/build/src/libstd/sys_common/thread.rs:21 14:44:04.907 [DEBUG] [TestEventLogger] - std::sys::imp::thread::{{impl}}::new::thread_start 14:44:04.908 [DEBUG] [TestEventLogger] at /buildslave/rust-buildbot/slave/stable-dist-rustc-musl-linux/build/src/libstd/sys/unix/thread.rs:84 14:44:04.908 [DEBUG] [TestEventLogger] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 14:44:04.908 [DEBUG] [TestEventLogger] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 14:44:04.908 [DEBUG] [TestEventLogger] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 14:44:04.908 [DEBUG] [TestEventLogger] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 14:44:04.908 [DEBUG] [TestEventLogger] at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57) 14:44:04.908 [DEBUG] [TestEventLogger] at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104) 14:44:04.908 [DEBUG] [TestEventLogger] at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$22(ProtocolHandshake.java:365) 14:44:04.908 [DEBUG] [TestEventLogger] at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) 14:44:04.908 [DEBUG] [TestEventLogger] at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958) 14:44:04.909 [DEBUG] [TestEventLogger] at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) 14:44:04.909 [DEBUG] [TestEventLogger] at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498) 14:44:04.909 [DEBUG] [TestEventLogger] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) 14:44:04.909 [DEBUG] [TestEventLogger] at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) 14:44:04.910 [DEBUG] [TestEventLogger] at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152) 14:44:04.910 [DEBUG] [TestEventLogger] at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) 14:44:04.911 [DEBUG] [TestEventLogger] at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464) 14:44:04.911 [DEBUG] [TestEventLogger] at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:368) 14:44:04.911 [DEBUG] [TestEventLogger] at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159) 14:44:04.911 [DEBUG] [TestEventLogger] at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) 14:44:04.911 [DEBUG] [TestEventLogger] at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) 14:44:04.912 [DEBUG] [TestEventLogger] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637) 14:44:04.914 [DEBUG] [TestEventLogger] at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250) 14:44:04.914 [DEBUG] [TestEventLogger] at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236) 14:44:04.798 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor] Executing test class ch.siroop.security.test.a2.Cookies_Session 14:44:04.922 [DEBUG] [TestEventLogger] at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137) 14:44:04.922 [DEBUG] [TestEventLogger] at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:191) 14:44:04.922 [DEBUG] [TestEventLogger] at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:108) 14:44:04.923 [DEBUG] [TestEventLogger] at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:104) 14:44:04.923 [DEBUG] [TestEventLogger] at ch.siroop.security.test.a2.Login.setUp(Login.java:40) 14:44:04.923 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 14:44:04.923 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 14:44:04.923 [DEBUG] [TestEventLogger] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 14:44:04.923 [DEBUG] [TestEventLogger] at java.lang.reflect.Method.invoke(Method.java:498) 14:44:04.923 [DEBUG] [TestEventLogger] at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 14:44:04.924 [DEBUG] [TestEventLogger] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 14:44:04.924 [DEBUG] [TestEventLogger] at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 14:44:04.926 [DEBUG] [TestEventLogger] at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) 14:44:04.926 [DEBUG] [TestEventLogger] at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) 14:44:04.927 [DEBUG] [TestEventLogger] at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 14:44:04.927 [DEBUG] [TestEventLogger] at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114) 14:44:04.927 [DEBUG] [TestEventLogger] at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57) 14:44:04.927 [DEBUG] [TestEventLogger] at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66) 14:44:04.927 [DEBUG] [TestEventLogger] at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) 14:44:04.927 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 14:44:04.927 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 14:44:04.927 [DEBUG] [TestEventLogger] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 14:44:04.927 [DEBUG] [TestEventLogger] at java.lang.reflect.Method.invoke(Method.java:498) 14:44:04.927 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 14:44:04.927 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 14:44:04.930 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) 14:44:04.930 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) 14:44:04.934 [DEBUG] [TestEventLogger] at com.sun.proxy.$Proxy3.processTestClass(Unknown Source) 14:44:04.934 [DEBUG] [TestEventLogger] at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109) 14:44:04.936 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 14:44:04.937 [DEBUG] [TestEventLogger] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 14:44:04.937 [DEBUG] [TestEventLogger] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 14:44:04.937 [DEBUG] [TestEventLogger] at java.lang.reflect.Method.invoke(Method.java:498) 14:44:04.937 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 14:44:04.937 [DEBUG] [TestEventLogger] at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 14:44:04.937 [DEBUG] [TestEventLogger] at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377) 14:44:04.937 [DEBUG] [TestEventLogger] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) 14:44:04.937 [DEBUG] [TestEventLogger] at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) 14:44:04.937 [DEBUG] [TestEventLogger] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 14:44:04.937 [DEBUG] [TestEventLogger] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 14:44:04.937 [DEBUG] [TestEventLogger] at java.lang.Thread.run(Thread.java:748)
答案 0 :(得分:1)
我终于弄明白是什么导致了这个问题,我通过ssh开始了测试,因此gecko驱动程序无法正常工作。您必须添加导出DISPLAY:= 0才能使其正常工作。
答案 1 :(得分:0)
确保您的gecko驱动程序和Firefox版本相同,即两者都应为32位或64位。