我有一个动态加载的页面并包含一个按钮。我正在尝试等待使用 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();
Run Code Online (Sandbox Code Playgroud)
虽然这不起作用。click 事件永远不会被触发。selenium 脚本不会抛出异常,提醒 ID 为“addInspectionButton”的元素不存在。它只是无法点击它。如果我在等待语句和我获得按钮元素句柄的行之间添加一个 Thread.Sleep(3000) ,它会起作用。
我在这里没有正确使用 ExpectedConditions.ElementToBeClickable 吗?