How can I resolve my class from a different jar with same structure like another

前端 未结 4 1268
后悔当初
后悔当初 2020-12-11 18:12

How can I resolve my class from a different jar with same structure like another

Note : Though the jars in question contains the word

相关标签:
4条回答
  • 2020-12-11 18:21

    The exception tells that the required class was not found in the classpath. As you have mentioned that you are adding PhantomJSDriver-jar as an external dependency. Make sure you have the correct scope for the jar and it is bundled when you package your application.

    Refer to this question to get better understanding of the scope.

    0 讨论(0)
  • 2020-12-11 18:25

    This jar includes 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 miss other classes, you can search them by classname with Advanced Search on Maven Central Repository: https://search.maven.org/#advancedsearch%7Cgav

    0 讨论(0)
  • 2020-12-11 18:26

    Finally the Question is Answered in a User Group by none other than Simon Stewart.

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

    Here is the snapshot of Simon's comment :

    Here is the working solution:

    0 讨论(0)
  • 2020-12-11 18:38

    even i had the same issue. try the below code. 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");
    
    0 讨论(0)
提交回复
热议问题