简体   繁体   English

org.openqa.selenium.TimeoutException:在使用 AutoCloseable 在 Ubuntu 中运行无头 firefox 浏览器时连接被拒绝错误

[英]org.openqa.selenium.TimeoutException: connection refused error while running headless firefox browser in Ubuntu using AutoCloseable

Error:错误:

org.openqa.selenium.TimeoutException: connection refused Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48' System info: host: 'ubuntu', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-112-generic', java.version: '1.8.0_252' Driver info: driver.version: FirefoxDriver org.openqa.selenium.TimeoutException:连接被拒绝构建信息:版本:'3.141.59',修订版:'e82be7d358',时间:'2018-11-14T08:25:48' 系统信息:主机:'ubuntu',Z94535B52768FCAD39D28 : '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-112-generic', java.version: '1.8.0_252' 驱动程序信息:驱动程序.version: FirefoxDriver

Code:代码:

System.setProperty("webdriver.gecko.driver", "/usr/bin/geckodriver");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setHeadless(true);

java.util.logging.Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF);
System.out.println(1);

WebDriver driver = new FirefoxDriver(firefoxOptions);
// code does not reach this point. Look like its freezing at the initialisation of 'driver'.
try (AutoCloseable autoCloseable = () -> driver.close()) {
         ...

I have changed Java Version as another question recommended (from 11 to 8).我已将 Java 版本更改为另一个建议的问题(从 11 到 8)。

EDIT: That post ( Java Selenium Webdriver Connection Refused ) did not work.编辑:那个帖子( Java Selenium Webdriver Connection Refused )没有工作。

EDIT #2: I am running it through Tomcat 9.编辑#2:我通过 Tomcat 9 运行它。

I don't see any such issue with your code block.我没有看到您的代码块有任何此类问题。 I took your code and executed with the following configuration:我采用了您的代码并使用以下配置执行:


Execution details执行细节

Here are the execution details using :以下是使用的执行细节:

  • Code Block:代码块:

     import java.util.logging.Level; import org.openqa.selenium.firefox.FirefoxDriver; //import org.openqa.selenium.firefox.FirefoxDriverLogLevel; import org.openqa.selenium.firefox.FirefoxOptions; public class AutoCloseableSelenium { public static void main(String[] args) throws Exception { System.setProperty("webdriver.gecko.driver","C:\\WebDrivers\\geckodriver.exe"); FirefoxOptions options = new FirefoxOptions(); options.setHeadless(true); //options.setLogLevel(FirefoxDriverLogLevel.TRACE); java.util.logging.Logger.getLogger("org.openqa.selenium").setLevel(Level.OFF); System.out.println(1); FirefoxDriver driver = new FirefoxDriver(options); try (AutoCloseable autoCloseable = () -> driver.quit()) { } System.out.println("Exiting program"); }

    } }

  • Console Output:控制台 Output:

     1 1595977246813 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-headless" "-foreground" "-no-remote" "-profile" "C:\\Users\\SOMABH~1\\AppData\\Local\\Temp\\rust_mozprofile345iC4" *** You are running in headless mode. JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. console.error: SearchCache: "_readCacheFile: Error reading cache file:" (new Error("", "(unknown module)")) 1595977254325 Marionette INFO Listening on port 53331 1595977254676 Marionette WARN TLS certificate errors will be ignored for this session 1595977254896 Marionette INFO Stopped listening on port 53331 JavaScript error: resource://activity-stream/lib/ActivityStreamPrefs.jsm, line 27: NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIPrefBranch.removeObserver] console.warn: services.settings: main/messaging-experiments sync interrupted by shutdown JavaScript error: resource://services-settings/IDBHelpers.jsm, line 24: Error: IndexedDB: main/fxmonitor-breaches list() IndexedDB: execute() The application is shutting down JavaScript error: resource://gre/modules/Sqlite.jsm, line 928: Error: Connection is not open. Exiting program

暂无
暂无

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

相关问题 org.openqa.selenium.WebDriverException:使用Selenium Java和Webdriver时连接被拒绝(Linux头没有Xvfb) - org.openqa.selenium.WebDriverException: connection refused while using Selenium Java and webdriver (linux headless with Xvfb) 失败的配置:@BeforeTest设置org.openqa.selenium.TimeoutException:使用Selenium ChromeDriver和Chrome登录时超时 - FAILED CONFIGURATION: @BeforeTest setup org.openqa.selenium.TimeoutException: timeout while sign in with Selenium ChromeDriver and Chrome org.openqa.selenium.WebDriverException:通过Selenium v​​3.4.0和geckodriver-v0.20.1启动Firefox浏览器45.0.1时,连接被拒绝 - org.openqa.selenium.WebDriverException: connection refused while launching Firefox Browser 45.0.1 through Selenium v3.4.0 and geckodriver-v0.20.1 org.openqa.selenium.TimeoutException:预期条件失败:等待By.xpath定位的元素的可见性: - org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.xpath: org.openqa.selenium.TimeoutException:超时:从渲染器接收消息超时:19.083 - org.openqa.selenium.TimeoutException: timeout: Timed out receiving message from renderer: 19.083 org.openqa.selenium.TimeoutException:预期条件失败:等待所有条件有效 - org.openqa.selenium.TimeoutException: Expected condition failed: waiting for all conditions to be valid NoClassDefFoundError: org/openqa/selenium/virtualauthenticator/HasVirtualAuthenticator 在使用 TestNG 和 Maven 运行测试时出错 - NoClassDefFoundError: org/openqa/selenium/virtualauthenticator/HasVirtualAuthenticator error while running test using TestNG and Maven org.openqa.selenium.ElementClickInterceptedException:在无头模式下使用 Selenium 和 Java 元素点击拦截错误 - org.openqa.selenium.ElementClickInterceptedException: element click intercepted error using Selenium and Java in headless mode 启动appium浏览器时出错:-org.openqa.selenium.WebDriverException:运行Appium命令时出错:path.resolve的参数必须是字符串 - Error While launching appium browser:- org.openqa.selenium.WebDriverException: ERROR running Appium command: Arguments to path.resolve must be strings org.openqa.selenium.WebDriverException:未知错误:.net::ERR_CONNECTION_REFUSED - org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM