资源介绍
package selenium;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import static junit.framework.Assert.assertNotNull;
public class WebDriverTest {
private WebDriver page;
@Before
public void before() {
page = new HtmlUnitDriver();
}
@Test
public void testHasAnImageSearchPage() throws Exception {
page.get("http://www.google.cn");
WebElement searchBox = page.findElement(By.name("q"));
searchBox.sendKeys("JavaEye");
WebElement subBtn = page.findElement(By.name("btnG"));
subBtn.submit();
WebElement result = page.findElement(By.linkText("http://www.javaeye.com"));
assertNotNull(result);
}
}