这是我的代码,它打开网页并将输入文本输入文本字段并尝试自动进一步浏览。第一个代码:element.sendKeys(Keys.ENTER); 正在工作,但紧随其后的下两行对我的程序没有影响。我被困在这里。请帮助我
public class GoogleSuggest {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
// And now use this to visit Google
driver.get("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
// Enter something to search for
element.sendKeys("vtu results");
element.sendKeys(Keys.ENTER);
element.sendKeys(Keys.TAB);
element.sendKeys(Keys.Enter);
System.out.println("Page title is: " + driver.getTitle());
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("v");
}
});
System.out.println("Page title is: " + driver.getTitle());
}
}