I want to compile an example code which using google`s webdriver.
I saved webdriver into /home/iyo/webdriver. My code is:
package com.googlecode.webdriver.example; import com.googlecode.webdriver.By; import com.googlecode.webdriver.WebDriver; import com.googlecode.webdriver.WebElement; import com.googlecode.webdriver.htmlunit.HtmlUnitDriver; public class FirstTest { public static void main(String[] args) { WebDriver driver = new HtmlUnitDriver(); driver.get("http://www.google.com"); WebElement element = driver.findElement(By.xpath("//input[@name = 'q']")); element.sendKeys("Cheese!"); element.submit(); System.out.println("Page title is: " + driver.getTitle()); } }
But I with
javac -cp /home/iyo/webdriver FirstTest.javaI got errors like this:
FirstTest.java:5: cannot find symbolsymbol : class By
location: package com.googlecode.webdriver
import com.googlecode.webdriver.By;
^
FirstTest.java:7: cannot find symbol
symbol : class WebDriver
location: package com.googlecode.webdriver
import com.googlecode.webdriver.WebDriver;
^
FirstTest.java:9: cannot find symbol
symbol : class WebElement
location: package com.googlecode.webdriver
import com.googlecode.webdriver.WebElement;
^
FirstTest.java:11: package com.googlecode.webdriver.htmlunit does not exist
import com.googlecode.webdriver.htmlunit.HtmlUnitDriver;
^
FirstTest.java:19: cannot find symbol
symbol : class WebDriver
location: class com.googlecode.webdriver.example.FirstTest
WebDriver driver = new HtmlUnitDriver(); ^
FirstTest.java:19: cannot find symbol
symbol : class HtmlUnitDriver
location: class com.googlecode.webdriver.example.FirstTest
WebDriver driver = new HtmlUnitDriver(); ^
FirstTest.java:27: cannot find symbol
symbol : class WebElement
location: class com.googlecode.webdriver.example.FirstTest
WebElement element = ^
FirstTest.java:29: cannot find symbol
symbol : variable By
location: class com.googlecode.webdriver.example.FirstTest
driver.findElement(By.xpath("//input[@name = 'q']")); ^
8 errors
Its possible to use it whitouht Ant?(The code in NetBeans or Eclipse work well, but I don
t want to use them.) Only with javac?
Thanks.