我想单击位于菜单栏中的元素并单击它,但我收到错误
OpenQA.Selenium.ElementNotVisibleException: element not visible
HTML:
<div id="et_top_search">
<span id="et_search_icon"/>
</div>
C#代码:
_driver.FindElementByXPath(".//span[@id='et_search_icon']").Click();
答案 0 :(得分:0)
您必须诱导 WebDriverWait 才能点击该元素,如下所示:
wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(30));
wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(".//span[@id='et_search_icon']"))).Click();