|
3#
楼主 |
发表于 2014-4-28 11:08:14
|
只看该作者
webdriver的代码:
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver", "D:\\Selenium\\IEDriverServer\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.com");
WebElement element =driver.findElement(By.name("q"));
element.sendKeys("Cheese!");
element.submit();
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
});
Assert.assertEquals(driver.findElement(By.xpath("//div[@class='kno-rdesc']")).getText().substring(0, 21), "奶酪,又名干酪、乳酪,译称芝士、起司、起士");
driver.quit();
} |
|