Problem with Selenium Dependencies

0

I have a problem with selenium with Java, I have developed a code that goes to a website and searches for it. It is giving this error:

Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE 
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:57)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:60)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:252)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(ApacheHttpClient.java:229)
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:96)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:70)
at org.openqa.selenium.phantomjs.PhantomJSCommandExecutor.<init>(PhantomJSCommandExecutor.java:62)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:115)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:104)

I searched and only found that it is a dependency problem, but I added all the jar, and it continues giving error. Below is my code.

 public String Token(String url) {
        try {
            URL caminhoUrl = new URL(url);

            DesiredCapabilities dc = caminho();
            WebDriver driver = new PhantomJSDriver(dc);


            driver.get(url);
            wait(driver,30);
            WebElement botaoAceito = driver.findElement(By.name("allow_access"));
            botaoAceito.click();
            wait(driver,30);
            String token = driver.findElement(By.tagName("input")).getAttribute("data-token");
            System.out.println(token);
            driver.quit();
        } catch (MalformedURLException ex) {
            Logger.getLogger(RecuperarTokenDropBox.class.getName()).log(Level.SEVERE, null, ex);
        }
        return "";
    }

    private DesiredCapabilities caminho() {

        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setJavascriptEnabled(true);
        cap.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "caminho phantomjs");

        return cap;
    }

    private void wait(WebDriver driver, int minutos){
        (new WebDriverWait(driver, minutos)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
                return d.getTitle().toLowerCase().startsWith("cheese!");
            }
        });
    }
    
asked by anonymous 23.06.2016 / 21:04

0 answers