我有一个动态加载的页面,其中包含一个按钮。我正在尝试使用C#绑定使用Selenium等待按钮可用以进行单击。我有以下代码:
WebDriverWait wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(30));
wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("addInspectionButton")));
var button = Driver.Instance.FindElement(By.Id("addInspectionButton"));
button.Click();
然而,这并不起作用。点击事件从未触发。Selenium脚本没有抛出异常警告“addInspectionButton”元素不存在。它只是无法单击它。如果在等待语句和获取按钮元素的行之间添加Thread.Sleep(3000),则可以正常工作。
我在这里是否没有正确使用ExpectedConditions.ElementToBeClickable?