잡동사니

반응형

질문

오류:

org.openqa.selenium.TimeoutException : 연결이 거부되었습니다.빌드 정보 : 버전 : '3.141.59', 개정 : 'e82be7d358', 시간 : '2018-11-14T08 : 25 : 48'시스템 정보 : 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.version : FirefoxDriver

암호:

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()) {
         ...

권장되는 또 다른 질문으로 Java 버전을 변경했습니다 (11에서 8로).

수정 : 해당 게시물 ( Java Selenium Webdriver Connection Refused )이 작동하지 않았습니다.

편집 # 2 : Tomcat 9를 통해 실행 중입니다.

 

답변1

귀하의 코드 블록에는 그러한 문제가 없습니다. 코드를 가져와 다음 구성으로 실행했습니다.


Execution details

다음은 을 사용한 실행 세부 정보입니다.

  • 코드 블록 :

    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");
      }

    }

  • 콘솔 출력 :

    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



 

 

 

 

출처 : https://stackoverflow.com/questions/63143518/org-openqa-selenium-timeoutexception-connection-refused-error-while-running-hea

반응형

이 글을 공유합시다

facebook twitter googleplus kakaoTalk kakaostory naver band