WebDriver driver = new FirefoxDriver();

1,487 views
Skip to first unread message

David Ramer

unread,
Apr 4, 2016, 1:33:58 PM4/4/16
to Selenium Users
Folks,

Started making some changes to my framework on a MAC 64 bit.  When I try to run the following I get an exception.

WebDriver driver = new FirefoxDriver();



Selenium versions:  See attachment.



I get this EXCEPTION:


Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException

at org.openqa.selenium.firefox.Preferences.readDefaultPreferences(Preferences.java:96)

at org.openqa.selenium.firefox.Preferences.<init>(Preferences.java:66)

at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:88)

at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:78)

at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:67)

at org.openqa.selenium.firefox.FirefoxDriver.getProfile(FirefoxDriver.java:293)

at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:269)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:221)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:212)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)

at com.common.eTest.eTestScreenCaptureFactory$Test.main(eTestScreenCaptureFactory.java:219)

Caused by: java.lang.ClassNotFoundException: org.json.JSONException

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

... 13 more



thank you for any support




Screen Shot 2016-04-04 at 10.34.19 AM.png

Moises Siles

unread,
Apr 4, 2016, 4:18:31 PM4/4/16
to seleniu...@googlegroups.com
What is your selenium and browser version?

--
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/8473321d-6cb6-408e-984d-8c886ca85e6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Ramer

unread,
Apr 4, 2016, 5:04:00 PM4/4/16
to Selenium Users
firefox is 45.01
Selenium-java-2.35.0.jar

same problem with Chrome.  Do I have to specify where the exe file is located?  FireFox is in the application folder?

THank you for the help

⇜Krishnan Mahadevan⇝

unread,
Apr 4, 2016, 11:51:04 PM4/4/16
to Selenium Users
David,
Selenium 2.35.0 is a very old version. You might want to consider moving to 2.53.0 [ so that you can run tests on the latest version of Firefox ]

The error that you are facing is NOT due to the browser binaries or the driver binaries. Its because of a messed up CLASSPATH.
You are having a mismatch of versions. The screenshot shows that you have both 2.47.1 and 2.35.0. Please ensure that you are uniformedly on the same version of Selenium.

 Selenium moved from org.json to google json libraries as part of Selenium v.2.44 [ See this commit ]


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/

David Ramer

unread,
Apr 5, 2016, 11:57:53 AM4/5/16
to seleniu...@googlegroups.com
Thank you for the support. I ensured I'm only using  Selenium 2.47.1

But now I have to cast:

WebDriver driver = (WebDriver) new FirefoxDriver();





Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/JsonElement

at org.openqa.selenium.firefox.Preferences.readDefaultPreferences(Preferences.java:96)

at org.openqa.selenium.firefox.Preferences.<init>(Preferences.java:66)

at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:88)

at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:78)

at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:67)

at org.openqa.selenium.firefox.FirefoxDriver.getProfile(FirefoxDriver.java:293)

at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:269)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:221)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:212)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)

at com.common.eTest.eTestScreenCaptureFactory$Test.main(eTestScreenCaptureFactory.java:221)

Caused by: java.lang.ClassNotFoundException: com.google.gson.JsonElement

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

... 13 more


David Ramer
​Upwork | Director QA/TS
m: 408.480.0781 | s: dramer.odesk | Alternate m: +591.781.05.212

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/OFqJWSUs6FE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

David Ramer

unread,
Apr 5, 2016, 11:59:46 AM4/5/16
to Selenium Users
thank you so much. I've fixed the jar files and I'm using 2.47.1


Its asking me to cast

 WebDriver driver = (WebDriver) new FirefoxDriver();



With this exception:


Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/JsonElement

at org.openqa.selenium.firefox.Preferences.readDefaultPreferences(Preferences.java:96)

at org.openqa.selenium.firefox.Preferences.<init>(Preferences.java:66)

at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:88)

at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:78)

at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:67)

at org.openqa.selenium.firefox.FirefoxDriver.getProfile(FirefoxDriver.java:293)

at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:269)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:221)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:212)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)

at com.common.eTest.eTestScreenCaptureFactory$Test.main(eTestScreenCaptureFactory.java:221)

Caused by: java.lang.ClassNotFoundException: com.google.gson.JsonElement

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

... 13 more

David Ramer

unread,
Apr 5, 2016, 12:23:56 PM4/5/16
to Selenium Users
I added the gson-2.3.1.jar  that fixed the cast problem with Firefox webdriver,

But now I get this error, any help would be appreciated

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials

at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:89)

at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:63)

at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:58)

at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:97)

at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:276)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:221)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:212)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)

at com.common.eTest.eTestScreenCaptureFactory$Test.main(eTestScreenCaptureFactory.java:221)

Caused by: java.lang.ClassNotFoundException: org.apache.http.auth.Credentials

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

... 11 more

David Ramer

unread,
Apr 5, 2016, 12:51:08 PM4/5/16
to Selenium Users
added the HTTPClient 4.2.5 and httpComponents 4.5.2


Now I get this exception. Looks like its trying to launch FireFox. Is this exception not finding the firefox exe?

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/exec/Executor

at org.openqa.selenium.os.CommandLine.<init>(CommandLine.java:47)

at org.openqa.selenium.firefox.FirefoxBinary.startProfile(FirefoxBinary.java:97)

at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:110)

at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:276)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:221)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:212)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)

at com.common.eTest.eTestScreenCaptureFactory$Test.main(eTestScreenCaptureFactory.java:221)

Caused by: java.lang.ClassNotFoundException: org.apache.commons.exec.Executor

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

... 10 more


On Monday, April 4, 2016 at 10:33:58 AM UTC-7, David Ramer wrote:

⇜Krishnan Mahadevan⇝

unread,
Apr 5, 2016, 1:05:33 PM4/5/16
to Selenium Users
David,

Looks like you opened up the Pandora's box with CLASSPATH conflicts :)

Would it be possible for you to share the following ?

1. How are you managing your CLASSPATH. Are you having your jars made available manually or are you using a build tool to help manage your dependencies ?
2. If you are using a build tool, can you please share the build file ? [ build.xml (or) pom.xml or the gradle build file ] 

That should basically help us figure out what is causing all of this plethora of issues for you...




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.

⇜Krishnan Mahadevan⇝

unread,
Apr 5, 2016, 1:07:10 PM4/5/16
to Selenium Users
David,
I looked at the screenshot again... Looks like you use Maven. Can you please share your pom file [ especially the dependencies section ? ]

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/

David Ramer

unread,
Apr 5, 2016, 1:11:30 PM4/5/16
to Selenium Users
don't use Maven, I like to update my jar files on my own.  Attached are my jar files.
Screen Shot 2016-04-05 at 10.13.41 AM.png

⇜Krishnan Mahadevan⇝

unread,
Apr 6, 2016, 12:06:50 AM4/6/16
to Selenium Users
David,

Its going to be hard to debug that way. I would suggest that you please consider using a build tool such as Maven or Gradle.
The advantage of using the build tool is that, it helps you in converging on your dependencies and also helps you manage jar conflicts.

When you manage your jars, you really don't have much of a control in the order of jars which can become important if the same class is being provided via two jars.

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/

David Ramer

unread,
Apr 6, 2016, 8:45:38 AM4/6/16
to Selenium Users
Krishnan,

Thank you for the support.  I'm just trying to run this line of code on my MAC

WebDriver driver = new ChromeDriver();



I keep getting exceptions:



Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/exec/Executor

at org.openqa.selenium.os.CommandLine.<init>(CommandLine.java:38)

at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:161)

at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:63)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568)

at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:141)

at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)

at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)

at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)

at com.common.eTest.eTestScreenCaptureFactory$Test.main(eTestScreenCaptureFactory.java:223)

Caused by: java.lang.ClassNotFoundException: org.apache.commons.exec.Executor

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

... 11 more



I would think I just need to add the selenium jar files into my project and it should work. Changing to a POM file will not change how I debug items.


Question:


Do I need to set some system variables to the exe? I never did that before?


System.setProperty("webdriver.chrome.driver", "/Applications/Google Chrome.app");



thank you for the help.




On Monday, April 4, 2016 at 10:33:58 AM UTC-7, David Ramer wrote:

⇜Krishnan Mahadevan⇝

unread,
Apr 7, 2016, 5:00:21 AM4/7/16
to Selenium Users
David,

>>>>>I would think I just need to add the selenium jar files into my project and it should work. Changing to a POM file will not change how I debug items.

Yes that is true, but the reason why I was suggesting that you please move over to using a build tool is to simplify the process of "adding some selenium jar files". Changing to a pom file is not supposed to be to change the way you debug items, but only to make the process of debugging a lot more easier. So I am going to have to repeat what I said earlier. You would need to strongly consider using a build tool. Without that, its going to be difficult for me or for anyone to basically resolve CLASSPATH issues.


>>>>>Do I need to set some system variables to the exe? I never did that before?
Nope. You don't. The error messages that you are seeing are related to CLASSPATH and dont have anything to do with System Variables.


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.
Reply all
Reply to author
Forward
0 new messages