gpt4 book ai didi

selenium - NoClassDefFoundError : org/apache/http/HttpEntity in Selenium for FirefoxDriver

转载 作者:行者123 更新时间:2023-12-04 06:26:10 24 4
gpt4 key购买 nike

我不想在这里做太多事情。

我只是想运行 Selenium 网站中给出的示例,只需打开 Google 页面并在编辑框中输入搜索字符串

但我收到以下错误:

*> 线程“main”中的异常

java.lang.NoClassDefFoundError: org/apache/http/client/ClientProtocolException at org.openqa.selenium.ie.InternetExplorerDriver.setup(InternetExplorerDriver.java:92) at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:56) at com.testscripts.Selenium2Example.main(Selenium2Example.java:16)*



我不知道这个 ClientProtocolException 是什么
类是和在哪里可以找到这个。

你们中的任何人都可以帮忙吗?

代码是
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openqa.selenium.ie.*;

public class Selenium2Example {
public static void main(String[] args) {
// Create a new instance of the Firefox driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
System.setProperty("webdriver.firefox.bin", "C:\\Documents and Settings\\Vikas Kashyap\\Local Settings\\Application Data\\Mozilla Firefox\\firefox");

WebDriver driver = new FirefoxDriver();

//WebDriver driver = new InternetExplorerDriver();

// And now use this to visit Google
driver.get("http://www.google.com");

// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));

// Enter something to search for
element.sendKeys("Cheese!");

// Now submit the form. WebDriver will find the form for us from the element
element.submit();

// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());


//Close the browser
driver.quit();

}
}

问候,
维卡斯

最佳答案

谢谢回复。

我发现了我所犯的错误。

我使用 Eclipse 作为我的 IDE。
在外部引用的 JAR 文件列表中,我包含了“selenium-java-2.0b3.jar”

实际上我必须包括“selenium-server-standalone-2.0b3.jar”

Selenium 网站并没有真正说明要为服务器下载哪个 jar 文件!这造成了所有的困惑。

使用正确的 jar 文件,不再有 "NoClassDefFoundError"。

问候
维卡斯

关于selenium - NoClassDefFoundError : org/apache/http/HttpEntity in Selenium for FirefoxDriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6018275/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com