我正在尝试设置Firefox的Webdriver。 “Webdriver”和“Firefox”下划线为红色。我点击'import firefox driver'和'import webdriver',但错误仍然存在..
我做了什么: - 我试图再次添加Jars。 - 我下载了Gecko驱动程序。 - 我点击导入webdriver并导入firefox驱动程序。
但根本不起作用。我真的不知道该怎么做。
package testbrowser;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Methods
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
System.setProperty("webdriver.firefox", "C:\\geckodriver-v0.19.1-win64\\geckodriver.exe");
WebDriver driver = new FirefoxDriver(); driver.get("google.com/");
}
}
答案 0 :(得分:1)
当您在import语句中看到错误时,这意味着Eclipse无法在类路径中找到相应的库(也称为JAR文件)。从seleniumhq.org下载selenium独立服务器并将其放在类路径上。提示:右键单击您的项目 - >构建路径。
如果您还没有这样做,我强烈建议您在进入Selenium WebDriver之前花一些时间浏览Java的基础知识并熟悉Eclipse IDE。