簡體   English   中英

無法單擊 selenium webdriver 中的劍道下拉菜單

[英]unable to click the kendo dropdown in selenium webdriver

這是我的硒代碼:

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM