bonigarcia / webdrivermanager

Automated driver management and other helper features for Selenium WebDriver in Java
https://bonigarcia.dev/webdrivermanager/
Apache License 2.0
2.57k stars 676 forks source link

WebDriverManager Failed to Run Firefox geckodriver 0.30.0 on linux/amd64 (x86_64) #735

Closed HyunAh-iia closed 2 years ago

HyunAh-iia commented 2 years ago

Description of the problem: WebDriverManager downloaded a Firefox geckodriver 0.30.0 well, but when I run the driver, it occur error.

Browser and version: Firefox 93.0 and geckodriver 0.30.0

Operating system: Ubuntu 18.04 AMD64 (x86_64) Docker on Intel Mac

WebDriverManager version: 5.0.3

WebDriverManager call: WebDriver driver = new FirefoxDriver();

WebDriverManager traces:

2021-10-29 00:47:29.213 [main] [traceId=] DEBUG i.g.b.wdm.cache.ResolutionCache.checkKeyInResolutionCache - Resolution firefox=93 in cache (valid until 01:05:27 29/10/2021 GMT+09:00)
2021-10-29 00:47:29.243 [main] [traceId=] DEBUG i.g.b.wdm.cache.ResolutionCache.checkKeyInResolutionCache - Resolution firefox93=0.30.0 in cache (valid until 00:05:27 30/10/2021 GMT+09:00)
2021-10-29 00:47:29.245 [main] [traceId=] INFO  i.g.bonigarcia.wdm.WebDriverManager.resolveDriverVersion - Using geckodriver 0.30.0 (resolved driver for Firefox 93)
2021-10-29 00:47:29.251 [main] [traceId=] TRACE i.g.b.wdm.cache.CacheHandler.getDriverFromCache - Checking if geckodriver exists in cache
2021-10-29 00:47:29.280 [main] [traceId=] TRACE i.g.b.wdm.cache.CacheHandler.filterCacheBy - Filter cache by geckodriver -- input list [/root/.cache/selenium/geckodriver/linux64/0.30.0/geckodriver, /root/.cache/selenium/resolution.properties] -- output list [/root/.cache/selenium/geckodriver/linux64/0.30.0/geckodriver] 
2021-10-29 00:47:29.285 [main] [traceId=] TRACE i.g.b.wdm.cache.CacheHandler.filterCacheBy - Filter cache by 0.30.0 -- input list [/root/.cache/selenium/geckodriver/linux64/0.30.0/geckodriver] -- output list [/root/.cache/selenium/geckodriver/linux64/0.30.0/geckodriver] 
2021-10-29 00:47:29.289 [main] [traceId=] TRACE i.g.b.wdm.cache.CacheHandler.filterCacheBy - Filter cache by LINUX -- input list [/root/.cache/selenium/geckodriver/linux64/0.30.0/geckodriver] -- output list [/root/.cache/selenium/geckodriver/linux64/0.30.0/geckodriver] 
2021-10-29 00:47:29.293 [main] [traceId=] DEBUG i.g.bonigarcia.wdm.WebDriverManager.manage - Driver geckodriver 0.30.0 found in cache
2021-10-29 00:47:29.295 [main] [traceId=] INFO  i.g.bonigarcia.wdm.WebDriverManager.exportDriver - Exporting webdriver.gecko.driver as /root/.cache/selenium/geckodriver/linux64/0.30.0/geckodriver
1635436049683   geckodriver INFO    Listening on 127.0.0.1:23396
1635436050242   mozrunner::runner   INFO    Running command: "/usr/lib/firefox/firefox" "--marionette" "-no-remote" "-profile" "/tmp/rust_mozprofilebTwlfg"
Error: no DISPLAY environment variable specified
2021-10-29 00:47:30.403 [main] [traceId=] WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext.refresh - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'botController' defined in URL [jar:file:/taling/app.jar!/BOOT-INF/classes!/my/study/ubunturecorder/api/BotController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'FFBrowser' defined in URL [jar:file:/taling/app.jar!/BOOT-INF/classes!/my/study/ubunturecorder/global/components/FFBrowser.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'firefoxDriver' defined in class path resource [my/study/ubunturecorder/global/configurations/WebDriverConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openqa.selenium.WebDriver]: Factory method 'firefoxDriver' threw exception; nested exception is org.openqa.selenium.WebDriverException: Process unexpectedly closed with status 1
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'ec4f631867c6', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.11'
Driver info: driver.version: FirefoxDriver
remote stacktrace: 
2021-10-29 00:47:30.513 [main] [traceId=] ERROR o.s.boot.SpringApplication.reportFailure - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'botController' defined in URL [jar:file:/taling/app.jar!/BOOT-INF/classes!/my/study/ubunturecorder/api/BotController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'FFBrowser' defined in URL [jar:file:/taling/app.jar!/BOOT-INF/classes!/my/study/ubunturecorder/global/components/FFBrowser.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'firefoxDriver' defined in class path resource [my/study/ubunturecorder/global/configurations/WebDriverConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openqa.selenium.WebDriver]: Factory method 'firefoxDriver' threw exception; nested exception is org.openqa.selenium.WebDriverException: Process unexpectedly closed with status 1
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'ec4f631867c6', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.11'
Driver info: driver.version: FirefoxDriver
remote stacktrace: 
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)
    at my.study.ubunturecorder.UbuntuRecorderApplication.main(UbuntuRecorderApplication.java:10)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)

Dockerfile:

FROM ubuntu:18.04

RUN /usr/bin/apt-get update && \
    /usr/bin/apt-get install -y curl && \
    /usr/bin/apt-get update && \
    /usr/bin/apt-get upgrade -y && \
    /usr/bin/apt-get install -y openjdk-11-jdk firefox tzdata wget

# Change Local Time to KST
RUN /bin/ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
HyunAh-iia commented 2 years ago

Sorry. I didn't run headless mode. It works.

    @Bean
    public WebDriver firefoxDriver() {
        FirefoxBinary firefoxBinary = new FirefoxBinary();
        firefoxBinary.addCommandLineOptions("--headless");
        firefoxBinary.addCommandLineOptions("--no-sandbox");
        WebDriverManager.firefoxdriver().setup();
        FirefoxOptions options = new FirefoxOptions();
        options.setBinary(firefoxBinary);
        WebDriver driver = new FirefoxDriver(options);
        driver.get("https://google.com");
        return driver;
    }