NoClassDefFoundError: org/apache/http/HttpEntity in Selenium for ChromeDriver?

前端 未结 2 1151
夕颜
夕颜 2020-12-12 02:01

i am trying to fetch data from a website using Selenium automation when i am trying to access data from that web site i am getting following exception

run         


        
2条回答
  •  北海茫月
    2020-12-12 02:16

    To check your code I tried the following:

    @Test
    public void test1() throws Exception {
        System.setProperty("webdriver.chrome.driver", "t:\\Others\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
    
        String url = "http://www.upmandiparishad.in/commodityWiseAll.aspx";
    
        driver.get(url);
        Thread.sleep(5000);
    
        new Select(driver.findElement(By.id("ctl00_ContentPlaceHolder1_ddl_commodity"))).selectByVisibleText("Paddy");
        Thread.sleep(5000);
    
        driver.findElement(By.id("ctl00_ContentPlaceHolder1_txt_rate")).sendKeys("27/03/2014");
        Thread.sleep(5000);
    
        driver.findElement(By.id("ctl00_ContentPlaceHolder1_btn_show")).click();
        Thread.sleep(5000);
    
        driver.close();
    

    }

    It works fine with FireFox (29.0) and Chrome (34.0) drivers. I used the following jar-s:

    • selenium-server-standalone-2.41.0.jar
    • selenium-java-2.41.0.jar
    • junit-dep-4.11.jar
    • hamcrest-core-1.3.jar

    You should check your project build path and add the appropriate jar-s. But you can find the missing class file in the selenium-server-standalone-2.XY.0.jar if you open it: selenium-server-standalone-2.41.0.jar\org\apache\http\entity\ContentType

    Another way is to use httpcore.jar (httpcore-4.3.jar) that contains the missing class file.

提交回复
热议问题