当前位置: 首页 > 知识库问答 >
问题:

geckodriver连接被拒绝

丁钟展
2023-03-14

我试着让我的selenium测试在debian服务器上运行,但是我一直从我的GeckoDriver得到连接拒绝错误。在运行Ubuntu的本地机器上,它运行得很好。你们谁知道怎么了?我找不到任何有用的东西。

OS:Debian Jessie
构建工具:Gradle
Java-版本:8

设置方法

    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)
    

共有1个答案

葛浩阔
2023-03-14

我终于知道是什么导致了这个问题,我通过ssh开始了测试,因此geckodriver没有工作。您必须添加export display=:0才能使其正常工作。这告诉Firefox如何使用显示服务器。

 类似资料:
  • 问题内容: 我已经下载了最新版本的Firefox,即Quantum。对于Selenium,以前不需要为Firefox下载任何可执行文件来打开URL,但现在它抛出了为GeckoDriver设置属性的错误。 因此,我下载了最新版本的 geckodriver-v0.20.1-arm7hf.tar.gz 并将其放入,因此抛出了连接拒绝错误。 因此,我使用了替代方法在Chrome上打开URL。下载了chro

  • 问题内容: 我是 HBase 和 Hadoop的 新手。我已经完全设置了HBase并完美启动。现在,当我尝试使用Java客户端从 p1 连接到HBase(HBase安装在 p2上 )时,它抛出了一个奇怪的异常。 问题答案: 我找到了解决方案。 通过仅从我的 主机中 删除 localhost 条目。现在我的本地主机条目就像 192.169.19.50 [这是我的hbase IP] =本地主机,而不是

  • 问题内容: 我正在尝试实现TCP连接,从服务器端一切正常,但是当我运行客户端程序(从客户端计算机)时,出现以下错误: 我尝试更改套接字号以防万一,但无济于事,有谁知道导致此错误的原因和解决方法。 服务器代码: 客户代码: 问题答案: 此异常意味着你尝试连接的IP /端口上没有侦听服务: 你试图连接到错误的IP /主机或端口。 你尚未启动服务器。 你的服务器没有监听连接。 在Windows服务器上,

  • 我无法连接到RabbitMQ。RabbitMQ不在本地计算机上。 我的应用程序.属性看起来像 我可以使用https://urltologinscreen:15671访问Rabbitmq gui 我得到以下错误 如何解决问题?

  • 我试图通过Jedis客户端连接到redis服务器,但在连接时我得到了以下异常和堆栈跟踪- redisconnectionFailureException:无法获得Jedis连接;嵌套异常是redis.clients.jedis.exceptions.jedisconnectionException:无法从位于org.springframework.data.redis.connection.jed

  • 我正在尝试运行卡桑德拉,但每次它在连接时都会给出相同的错误...有什么我需要在配置文件或属性文件中编辑的吗? ('无法连接到任何服务器',{'127.0.0.1:9042 ':错误(61,"尝试连接到[('127.0.0.1 ',9042)]。最后一个错误:连接被拒绝")}) 启动cassandra时出错