【问题标题】:unable to click the kendo dropdown in selenium webdriver无法单击 selenium webdriver 中的剑道下拉菜单
【发布时间】:2020-04-20 08:20:46
【问题描述】:

这是我的硒代码:

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>

【问题讨论】:

    标签: javascript html selenium


    【解决方案1】:

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

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

    【讨论】:

    • 它没有显示上述错误,但位没有点击
    • @MurugesanK 你能给我链接吗?
    猜你喜欢
    • 2012-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多