How can I solve my class from another can with the same structure as another

How can I solve my class from another can with the same structure as another

Note Although the banks in question contain the word selenium , the issue here is not directly related to selenium.

Until a few days ago, PhantomJSDriver was released with selenium-server-standalone-vvvjar . So my class worked fine:

 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-vvvjar does not bind jar for PhantomJSDriver dependency.

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

You can see that the phantomjsdriver-1.1.0.jar is similar to what it was before when it was associated with selenium-server-standalone-vvvjar

PhantomJSDriver

Now, although my class is resolving with:

 import org.openqa.selenium.phantomjs.PhantomJSDriver; 

But I ran into a Runtime exception java.lang.NoClassDefFoundError 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:

 WebDriver driver= new PhantomJSDriver(); 

According to the error I was looking for org.openqa.selenium.browserlaunchers.Proxies in phantomjsdriver-1.1.0.jar, no hint was found.

NoClassDefFoundError

Can anyone help me out?

+7
java jar classnotfoundexception selenium phantomjs
source share
4 answers

Finally, in the response, the User Group responds with nothing more than Simon Stewart .

Answer : There 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. There 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.

Here is a snapshot of Simon's comment:

Simon_stewart

Here is a working solution: PhantomJSDriver_solved

+2
source share

This bank has org.openqa.selenium.browserlaunchers.Proxies, try adding it to your classpath:

https://search.maven.org/remotecontent?filepath=org/seleniumhq/selenium/selenium-api/2.4.0/selenium-api-2.4.0.jar

If you skip other classes, you can search for them by class name using the advanced search in the central repository of Maven: https://search.maven.org/#advancedsearch%7Cgav

+3
source share

An exception indicates that the required class was not found in the classpath. As you mentioned, you add PhantomJSDriver-jar as an external dependency. Make sure you have the right area for the can, and it comes bundled when packing your application.

Refer to this question to better understand the scope.

+2
source share

Even I had the same problem. try the code below. It worked for me;

  WebDriver driver; File src = new File("//PATH"); System.setProperty("phantomjs.binary.path", src.getAbsolutePath()); DesiredCapabilities caps = new DesiredCapabilities(); caps.setJavascriptEnabled(true); caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); driver = new PhantomJSDriver(caps); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); caps = new DesiredCapabilities(); caps.setJavascriptEnabled(true); caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] { "--web-security=no", "--ignore-ssl-errors=yes" }); driver = new PhantomJSDriver(caps); driver.get("URL"); 
+1
source share

All Articles