How can I resolve the PhantomJSDriver() from a different jar with same structure like selenium

791 views
Skip to first unread message

Debanjan Bhattacharjee

unread,
Jan 11, 2018, 1:40:15 AM1/11/18
to webdriver
Hello Everybody,

Till a few days back PhantomJSDriver was released bundled along with selenium-server-standalone-v.v.v.jar. So my Class was working fine as :

import java.io.File;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;

public class A_PhantomJS
{
    public static void main(String[] args) 
    {
          File path=new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
          System.setProperty("phantomjs.binary.path",path.getAbsolutePath());
          WebDriver driver= new PhantomJSDriver();
          driver.manage().window().maximize();
          driver.get("https://www.google.co.in");
    }
}

Now selenium-server-standalone-v.v.v.jar doesn't bundles the jar for PhantomJSDriverdependency.

So I have downloaded the jar phantomjsdriver-1.1.0.jar and added as an external jar to my project.

You can see the structure of the phantomjsdriver-1.1.0.jar is similar to what it was earlier when it was bundled with selenium-server-standalone-v.v.v.jar



Now, though my Class gets resolved through :

import org.openqa.selenium.phantomjs.PhantomJSDriver;

But I am facing a Runtime exception of java.lang.NoClassDefFoundError exception caused by java.lang.ClassNotFoundException as follows :

Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/browserlaunchers/Proxies
    at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService(PhantomJSDriverService.java:178)
    at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
    at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:89)
    at demo.A_PhantomJS.main(A_PhantomJS.java:15)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.browserlaunchers.Proxies
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 4 more

Line 15 being :

WebDriver driver= new PhantomJSDriver();

As per the error I have searched for org.openqa.selenium.browserlaunchers.Proxies within the phantomjsdriver-1.1.0.jar unable to find any clue.



Can anyone help me out please?

Thanks and Regards
DebanjanB

⇜Krishnan Mahadevan⇝

unread,
Jan 11, 2018, 1:45:27 AM1/11/18
to webdriver
I am guessing you are basically encountering conflicts of versions.

PhantomJSdriver was basically built with an older version of Selenium and in the latest released version of Selenium, org.openqa.selenium.browserlaunchers.Proxies is not present which explains the Runtime error.

The easiest way of fixing this problem would be to create the same package in your codebase, copy paste the contents of Proxies.java [ you can find it from github by switching over to an appropriate tag version wherein this class still existed ] and then work with it.


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 "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+unsubscribe@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at https://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/d/optout.

Simon Stewart

unread,
Jan 17, 2018, 7:38:48 AM1/17/18
to webdriver
There's a version of phantomjsdriver ('com.codeborne:phantomjsdriver:jar:1.4.4') that appears to be kept up to date with latest selenium releases. I'd suggest using that.

Kind regards,

Simon

On Thu, Jan 11, 2018 at 6:45 AM, ⇜Krishnan Mahadevan⇝ <krishnan.ma...@gmail.com> wrote:
I am guessing you are basically encountering conflicts of versions.

PhantomJSdriver was basically built with an older version of Selenium and in the latest released version of Selenium, org.openqa.selenium.browserlaunchers.Proxies is not present which explains the Runtime error.

The easiest way of fixing this problem would be to create the same package in your codebase, copy paste the contents of Proxies.java [ you can find it from github by switching over to an appropriate tag version wherein this class still existed ] and then work with it.


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/

Debanjan Bhattacharjee

unread,
Jan 18, 2018, 9:47:10 AM1/18/18
to webdriver
Thanks for the suggestion @Krishnan

Regards
Debanjan-B
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

Debanjan Bhattacharjee

unread,
Jan 18, 2018, 10:00:52 AM1/18/18
to webdriver
Ohhh you beauty @SimonStewart "Take a Bow"



Thanks and Regards
Debanjan-B


On Wednesday, January 17, 2018 at 6:08:48 PM UTC+5:30, Simon Stewart wrote:
There's a version of phantomjsdriver ('com.codeborne:phantomjsdriver:jar:1.4.4') that appears to be kept up to date with latest selenium releases. I'd suggest using that.

Kind regards,

Simon
On Thu, Jan 11, 2018 at 6:45 AM, ⇜Krishnan Mahadevan⇝ <krishnan.ma...@gmail.com> wrote:
I am guessing you are basically encountering conflicts of versions.

PhantomJSdriver was basically built with an older version of Selenium and in the latest released version of Selenium, org.openqa.selenium.browserlaunchers.Proxies is not present which explains the Runtime error.

The easiest way of fixing this problem would be to create the same package in your codebase, copy paste the contents of Proxies.java [ you can find it from github by switching over to an appropriate tag version wherein this class still existed ] and then work with it.


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/
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

To post to this group, send email to webd...@googlegroups.com.
Visit this group at https://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages