这是我的硒代码:

WebDriverWait fee = new WebDriverWait(driver, 10);
fee.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='select']")));
fee.until(ExpectedConditions.elementToBeClickable(By.xpath("//span[text()='select']"))).click();


这是我的HTML代码:

<span title="" class="k-widget k-dropdown k-header" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="ddlSaleItem_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-activedescendant="e30bc773-2592-40f2-aa5f-38850a538cd6"
  style="width: 115%;">
  <span unselectable="on" class="k-dropdown-wrap k-state-default">
  <span unselectable="on" class="k-input"></span>
<span unselectable="on" class="k-select">
  <span unselectable="on" class="k-icon k-i-arrow-s">select</span></span>
</span>
<div id="ddlSaleItem" data-id="" style="width: 115%; display: none;" data-role="dropdownlist"></div>
</span>


我收到这种错误消息:

Exception in thread "main" org.openqa.selenium.ElementClickInterceptedException:
element click intercepted: Element <span un...able="on" class="k-icon k-i-arrow-s">
select</span> is not clickable at point (402, 143). Other element would receive the
click: <div class="k-overlay" style="display: block; z-index: 10002; opacity: 0.5;
transition: all 350ms ease-out 0s;"></div>

最佳答案

您可以使用JavaScriptExecutor click方法单击元素。
您可以像这样使用它:

WebElement element = driver.findElement(By.xpath("//span[text()='select']"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);

10-08 07:57