等待一个ajax调用完成与Selenium 2网络驱动程序

前端之家收集整理的这篇文章主要介绍了等待一个ajax调用完成与Selenium 2网络驱动程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用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")));
原文链接:https://www.f2er.com/ajax/160714.html

猜你在找的Ajax相关文章