以下代码测试网页的自动完成框:
public class Test {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver","chromedriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www..............com");
driver.switchTo().frame("mainFrame");
WebDriverWait waitst = new WebDriverWait(driver, 120);
waitst.until(ExpectedConditions.visibilityOfElementLocated(By.name("sourceTitle")));
WebElement sourceTitle = driver.findElement(By.name("sourceTitle"));
WebElement small = driver.findElement(By.cssSelector("li#nameExampleSection label + small"));
sourceTitle.sendKeys("Times");
Thread.sleep(5000);
Actions actions = new Actions(driver);
actions.click(small).perform();
}
}
为什么自动建议框不加载?重要提示:尝试手动输入“...........” ......自动完成框将完美加载!!!那么,为什么不起作用cssSelector
,为什么不加载自动完成框?
为什么自动输入不允许自动完成选项但手动输入呢???
PS:我也试过了fireEvent
,sendKeys
但没有任何效果。