我使用selenium 2 web驱动程序来测试使用AJAX的ui。
是否有一种方法使驱动程序等待一点,以便ajax请求将完成
基本上我有这个:
d.FindElement(By.XPath("//div[8]/div[3]/div/button")).Click(); // this^ click triggers an ajax request which will fill the below Id with content // so I need to make it wait for a bit Assert.IsNotEmpty(d.FindElement(By.Id("Hobbies")).Text);
var wait = new WebDriverWait(d,TimeSpan.FromSeconds(5)); var element = wait.Until(driver => driver.FindElement(By.Id("Hobbies")));