我想编译一个使用 google 的 webdriver 的示例代码。
我将 webdriver 保存到 /home/iyo/webdriver。我的代码是:
包 com.googlecode.webdriver.example;
导入 com.googlecode.webdriver.By;
导入 com.googlecode.webdriver.WebDriver;
导入 com.googlecode.webdriver.WebElement;
导入 com.googlecode.webdriver.htmlunit.HtmlUnitDriver;
公共类 FirstTest {
公共静态无效主要(字符串[]参数){
WebDriver driver = new HtmlUnitDriver();
driver.get("http://www.google.com");
WebElement 元素 =
driver.findElement(By.xpath("//input[@name = 'q']"));
element.sendKeys("奶酪!");
元素.提交();
System.out.println("页面标题为:" + driver.getTitle());
}
}
但我与
javac -cp /home/iyo/webdriver FirstTest.java我收到这样的错误:
FirstTest.java:5:找不到符号符号:类
位置:包 com.googlecode.webdriver
导入 com.googlecode.webdriver.By;
^FirstTest.java:7:找不到符号
符号:类 WebDriver
位置:包 com.googlecode.webdriver
导入 com.googlecode.webdriver.WebDriver;
^FirstTest.java:9:找不到符号
符号:类 WebElement
位置:包 com.googlecode.webdriver
导入 com.googlecode.webdriver.WebElement;
^FirstTest.java:11:com.googlecode.webdriver.htmlunit 包不存在
导入 com.googlecode.webdriver.htmlunit.HtmlUnitDriver;
^FirstTest.java:19:找不到符号
符号:类 WebDriver
位置:com.googlecode.webdriver.example.FirstTest 类
WebDriver driver = new HtmlUnitDriver(); ^FirstTest.java:19:找不到符号
符号:类 HtmlUnitDriver
位置:com.googlecode.webdriver.example.FirstTest 类
WebDriver driver = new HtmlUnitDriver(); ^FirstTest.java:27:找不到符号
符号:类 WebElement
位置:com.googlecode.webdriver.example.FirstTest 类
WebElement element = ^FirstTest.java:29:找不到符号
符号:变量
位置:com.googlecode.webdriver.example.FirstTest 类
driver.findElement(By.xpath("//input[@name = 'q']")); ^8 个错误
它s possible to use it whitouht Ant?(The code in NetBeans or Eclipse work well, but I don不想使用它们。)仅使用 javac?
谢谢。