1

I have set the path and firefox bin correctly, still don't know where the problem is. The piece of code to start firefox driver is added below:

System.setProperty("webdriver.gecko.driver", "/opt/config/x_conf_dir/geckodriver");
      System.setProperty("webdriver.firefox.bin", "/opt/config/x_conf_dir/firefox-bin");
      FirefoxOptions options = new FirefoxOptions();
      options.addArguments("start-maximized");
      options.addArguments("headless");
      options.addArguments("window-size=1200,1100");
      LOGGER.warn("Start initiating firefox driver");
      WebDriver driver = new FirefoxDriver(options);
      driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
      driver.get("https://stackoverflow.com");
      LOGGER.warn("Page title is {}", driver.getTitle());
      File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
      FileUtils.copyFile(scrFile, new File("/opt/config/x_conf_dir/screen.png"));

While initiating the firefox driver in java, it gives this exception when marionette is turned to false, else it gives "Unable to find a matching set of capabilities".

org.openqa.selenium.WebDriverException: Timed out waiting 45 seconds for Firefox to start.
            Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
            System info: host: 'csrapp-02', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.77blibli.com', java.version: '1.8.0_101'
            Driver info: driver.version: FirefoxDriver
                at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:132) ~[selenium-firefox-driver-3.12.0.jar:na]
                at org.openqa.selenium.firefox.XpiDriverService.start(XpiDriverService.java:117) ~[selenium-firefox-driver-3.12.0.jar:na]
                at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79) ~[selenium-remote-driver-3.12.0.jar:na]
                at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543) ~[selenium-remote-driver-3.12.0.jar:na]
                at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207) ~[selenium-remote-driver-3.12.0.jar:na]
                at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130) ~[selenium-remote-driver-3.12.0.jar:na]
                at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125) ~[selenium-firefox-driver-3.12.0.jar:na]
                at com.gdn.ext.catalog.rest.web.controller.api.crawler.ConfigurableCrawlerController.startFirefox(ConfigurableCrawlerController.java:278) ~[classes/:na]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101]
                at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
                at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) [servlet-api.jar:na]
                at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [servlet-api.jar:na]
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) [catalina.jar:8.5.4]
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [catalina.jar:8.5.4]
                at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.5.4]
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [catalina.jar:8.5.4]
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [catalina.jar:8.5.4]
                at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [catalina.jar:8.5.4]
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [catalina.jar:8.5.4]
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [catalina.jar:8.5.4]
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) [catalina.jar:8.5.4]
                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:632) [catalina.jar:8.5.4]
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:8.5.4]
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.5.4]
                at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) [catalina.jar:8.5.4]
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.4]
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [catalina.jar:8.5.4]
                at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110) [tomcat-coyote.jar:8.5.4]
                at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.4]
                at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785) [tomcat-coyote.jar:8.5.4]
                at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425) [tomcat-coyote.jar:8.5.4]
                at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.4]
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_101]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_101]
                at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.4]
                at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]
            Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:21425/hub/status] to be available after 45002 ms
                at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100) ~[selenium-remote-driver-3.12.0.jar:na]
                at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:130) ~[selenium-firefox-driver-3.12.0.jar:na]
                ... 50 common frames omitted
            Caused by: java.util.concurrent.TimeoutException: null
                at java.util.concurrent.FutureTask.get(FutureTask.java:205) ~[na:1.8.0_101]
                at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:180) ~[guava-22.0.jar:na]
                at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75) ~[selenium-remote-driver-3.12.0.jar:na]
                ... 51 common frames omitted

try {
      System.setProperty("webdriver.gecko.driver", "/opt/config/x_conf_dir/geckodriver");
      System.setProperty("webdriver.firefox.bin", "/opt/config/x_conf_dir/firefox-bin");
      FirefoxOptions options = new FirefoxOptions();
      options.addArguments("start-maximized");
      options.addArguments("headless");
      LOGGER.warn("Start initiating firefox driver");
      WebDriver driver = new FirefoxDriver(options);
      driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
      driver.get("https://stackoverflow.com");
      LOGGER.warn("Page title is {}", driver.getTitle());
      File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
      FileUtils.copyFile(scrFile, new File("/opt/config/x_conf_dir/screen.png"));

Thanks..

karan ladla
  • 31
  • 1
  • 7
  • 1
    "Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:21425/hub/status] to be available after 45002 ms" seemes pretty clear to me. – pburgr Jul 24 '18 at 05:52

1 Answers1

0

As per your error stack trace you are using Selenium Java Client v3.12.0. So you have to use GeckoDriver and marionette as a mandatory measure. However by default marionette is set to true.

As you mentioned marionatte is turned to false hence you see the error as:

  • Working Code:

    System.setProperty("webdriver.gecko.driver", "C:/path/to/geckodriver.exe");
    DesiredCapabilities dc = new DesiredCapabilities();
    dc.setCapability("marionatte", true);
    FirefoxOptions opt = new FirefoxOptions();
    opt.merge(dc);
    FirefoxDriver driver =  new FirefoxDriver(opt);
    driver.get("https://stackoverflow.com");
    
  • When you use GeckoDriver, marionatte is set to true by default. In that case you can also skip the marionatte capability and you use the following solution as well:

    System.setProperty("webdriver.gecko.driver", "C:/path/to/geckodriver.exe");
    FirefoxDriver driver =  new FirefoxDriver();
    driver.get("https://stackoverflow.com");
    
  • You can find a detailed discussion in org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities while initiating Firefox v37 through Selenium v3.11.0

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • With marionette true, it gives "Unable to find a matching set of capabilities". Could you plz point me in correct direction. – karan ladla Jul 24 '18 at 08:38
  • Checkout my updated answer and let me know the result – undetected Selenium Jul 24 '18 at 08:57
  • After changing the marionatte to true or removing the capability altogether as suggested in your updated solution, it throws org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities. Also I'm running it on linux machine – karan ladla Jul 24 '18 at 10:57
  • Have updated the piece of code using to initiate firefox driver. Plz check and guide what I'm doing wrong. – karan ladla Jul 24 '18 at 11:15