There is an exception issue which i am facing running selenium webdriver

1,110 views
Skip to first unread message

Sanchit Jalan

unread,
Dec 11, 2017, 9:24:52 PM12/11/17
to Selenium Users
I am facing an exception called  java.lang.IllegalStateException while running selenium webdriver gecko using java in eclipse ide. I have been struggling with this since for the past 5hrs.
Selenium java jar files             : 3.8.1
Mozilla Gecko Driver              :  0.19.0 (http://www.seleniumhq.org/download/)    
Browser                                 : Mozilla 57.0.1 (64-bit)
OS                                        : Ubuntu 16.04 LTS
Using Latest Eclipse IDE

My Code is
package newpackage;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Myclass {

   
    public static void main(String[] args) {
        System.setProperty("webdriver.gecko.driver","/home/sanchit/geckodriver.exe");
        WebDriver driver = new FirefoxDriver(); // Launches Firefox Browser with blank url
        driver.get("https://www.google.com"); // Navigates to the specified URL
        String Title = driver.getTitle();
        System.out.println(Title);
        driver.close(); // Closes the Browser
    }
}

I am facing an exception called  java.lang.IllegalStateException. The exception stack is :
Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: /home/sanchit/geckodriver.exe
    at com.google.common.base.Preconditions.checkState(Preconditions.java:534)
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:136)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:131)
    at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41)
    at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:141)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:339)
    at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:158)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:98)
    at newpackage.Myclass.main(Myclass.java:11)

Krishnan Mahadevan

unread,
Dec 11, 2017, 9:34:45 PM12/11/17
to seleniu...@googlegroups.com

On ubuntu, there’s no file extensions. So you might want to drop the “.exe” in your System.setProperty() and try again.

 

Alternatively I would suggest that you merely have the geckodriver available as part of your PATH variable, so that you can invoke it directly from the command line terminal. Once you have that working, your test should work fine.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/29795a6c-c49f-4c01-9ee8-993c2bb8972f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sanchit Jalan

unread,
Dec 17, 2017, 1:23:07 PM12/17/17
to Selenium Users
Krishnan Mahadevan Sir, thanks for the reply.
Sir currently I am facing the issue that after running the below code, browser is opened but url is unable to open.  SIr, I also want to know, what setting should i do so that i can see the trace level log for the gecko driver.

My code is
package newpackage;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Myclass {

  
    public static void main(String[] args) {
        System.setProperty("webdriver.gecko.driver","/home/sanchit/eclipse-workspace/geckodriver");

        WebDriver driver = new FirefoxDriver(); // Launches Firefox Browser with blank url
        driver.get("https://www.google.com"); // Navigates to the specified URL
        String Title = driver.getTitle();
        System.out.println(Title);
        driver.close(); // Closes the Browser
    }
}

Dec 17, 2017 11:45:04 PM org.openqa.selenium.remote.DesiredCapabilities firefox
INFO: Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting 45 seconds for Firefox to start.
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:14.666Z'
System info: host: 'sanchit-Vostro-3558', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-101-generic', java.version: '1.8.0_151'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:131)
    at org.openqa.selenium.firefox.XpiDriverService.start(XpiDriverService.java:116)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)

    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:106)
    at newpackage.Myclass.main(Myclass.java:15)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:21215/hub/status] to be available after 45016 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
    at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:129)
    ... 8 more
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.FutureTask.get(FutureTask.java:205)
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:147)
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
    ... 9 more

Krishnan Mahadevan

unread,
Dec 18, 2017, 10:08:18 AM12/18/17
to seleniu...@googlegroups.com

Sanchit,

 

Am not quite convinced that you are sharing the proper code.

The code you shared and the exception stacktrace are completely unrelated. The stacktrace seems to indicate that you are forcing Selenium to use the legacy protocol of working with firefox plugin.

 

Am guessing that somewhere you are passing in the JVM argument: 

 

-Dwebdriver.firefox.marionette = false

 

 

When I ran your test code, I noticed the following console logs.

 

1513609401505   geckodriver INFO    geckodriver 0.19.1

1513609401599   geckodriver INFO    Listening on 127.0.0.1:13321

1513609402140   mozrunner::runner   INFO    Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-profile" "/var/folders/mj/81r6v7nn5lqgqgtfl18spfpw0000gn/T/rust_mozprofile.CfNCRwRxoR6t"

1513609402858   Marionette  INFO    Enabled via --marionette

2017-12-18 20:33:23.839 plugin-container[19984:439472] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x15343, name = 'com.apple.tsm.portname'

See /usr/include/servers/bootstrap_defs.h for the error codes.

1513609404299   Marionette  INFO    Listening on port 59834

1513609404304   Marionette  WARN    TLS certificate errors will be ignored for this session

1513609404369   Marionette  DEBUG   Register listener.js for window 2147483649

Dec 18, 2017 8:33:24 PM org.openqa.selenium.remote.ProtocolHandshake createSession

INFO: Detected dialect: W3C

1513609404453   Marionette  DEBUG   Received DOM event "beforeunload" for "about:blank"

1513609405299   Marionette  DEBUG   Received DOM event "pagehide" for "about:blank"

1513609405300   Marionette  DEBUG   Received DOM event "unload" for "about:blank"

1513609405501   Marionette  DEBUG   Received DOM event "DOMContentLoaded" for "https://www.google.co.in/?gfe_rd=cr&dcr=0&ei=vNg3WoeKMd2i4wKDzavIDw"

1513609406329   Marionette  DEBUG   Received DOM event "pageshow" for "https://www.google.co.in/?gfe_rd=cr&dcr=0&ei=vNg3WoeKMd2i4wKDzavIDw"

Google

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <seleniu...@googlegroups.com> on behalf of Sanchit Jalan <sanchit...@gmail.com>


Reply-To: <seleniu...@googlegroups.com>
Date: Sunday, December 17, 2017 at 11:53 PM
To: Selenium Users <seleniu...@googlegroups.com>

Subject: [selenium-users] Re: There is an exception issue which i am facing running selenium webdriver

nags...@gmail.com

unread,
Dec 18, 2017, 10:25:33 AM12/18/17
to Selenium Users
i too initially faced similar kind of challenges with firefox browser.

Option # 1  - download previous version of selenium and gecho driver
Option # 2  - revert back firefox version to 46 or 48
Option # 3 - it's a work around use chrome browser.

hope it might helps...

On Tuesday, December 12, 2017 at 7:54:52 AM UTC+5:30, Sanchit Jalan wrote:

Sanchit Jalan

unread,
Dec 18, 2017, 1:24:13 PM12/18/17
to Selenium Users
Krishnan Mahadevan Sir,

Sir, I agree the mismatch of test code and error. Actually there was something wrong related in my project workspace which I realised when I had removed the test code and just coded to print "hello world" and again resulted in showing the same stack trace as with the original code, which was completely unexpected.

I dereference all the selenium-java jar files from my project, then checked the working of code printing on console and it worked. Then again i added those jar in my project and ran the original test code, it showed the expected result with below log.

1513619576122    geckodriver    INFO    geckodriver 0.19.0
1513619576142    geckodriver    INFO    Listening on 127.0.0.1:13578
1513619576990    mozrunner::runner    INFO    Running command: "/usr/lib/firefox/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.nZDfs1u3JcCR"
1513619579863    Marionette    INFO    Enabled via --marionette
1513619585600    Marionette    INFO    Listening on port 35750
1513619585796    Marionette    WARN    TLS certificate errors will be ignored for this session
1513619585895    Marionette    DEBUG    Register listener.js for window 2147483649
Dec 18, 2017 11:23:06 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
1513619586432    Marionette    DEBUG    Received DOM event "beforeunload" for "about:blank"
1513619589629    Marionette    DEBUG    Received DOM event "pagehide" for "about:blank"
1513619589629    Marionette    DEBUG    Received DOM event "unload" for "about:blank"
1513619590703    Marionette    DEBUG    Received DOM event "DOMContentLoaded" for "https://www.google.co.in/?gfe_rd=cr&dcr=0&ei=hQA4WujhAcucX9fpp7AI"
1513619603909    Marionette    DEBUG    Received DOM event "pageshow" for "https://www.google.co.in/?gfe_rd=cr&dcr=0&ei=hQA4WujhAcucX9fpp7AI"
Google
 
Sir, thanks a lot for the effort you put in for helping me. Finally seeing my test code run after 6 days, made me very happy. If i will encounter any further problem in testing, I will seek your help sir.

Thank you.

Regards,
Sanchit Jalan



On Tuesday, December 12, 2017 at 7:54:52 AM UTC+5:30, Sanchit Jalan wrote:

Sindhu Jvs

unread,
Aug 22, 2018, 5:22:32 AM8/22/18
to Selenium Users
Sanchit Jalan,
 Replace the code as below ...
           System.setProperty("webdriver.firefox.marionette","/home/sanchit/geckodriver.exe");
      
          

On Tuesday, December 12, 2017 at 7:54:52 AM UTC+5:30, Sanchit Jalan wrote:
Reply all
Reply to author
Forward
0 new messages