【发布时间】:2016-06-01 20:18:44
【问题描述】:
我正在尝试单击作为 jstree 一部分的复选框,到目前为止我尝试过的每件事都没有成功。请协助。 目标是勾选 id 为 733 的复选框
这是 HTML 代码:
<div id="jstree-1" class="jstree jstree-2 jstree-default jstree-default-responsive jstree-checkbox-no-clicked" role="tree" aria-activedescendant="8528">
<ul class="jstree-container-ul jstree-no-dots jstree-no-icons">
<li id="733" class="jstree-node jstree-open jstree-last" role="treeitem" aria-selected="false" aria-expanded="true">
<i class="jstree-icon jstree-ocl"/>
<a class="jstree-anchor" href="#">
<i class="jstree-icon jstree-checkbox"/>
<i class="jstree-icon jstree-themeicon false jstree-themeicon-custom"/>
Accepts Cash
</a>
<ul class="jstree-children" role="group" style="">
</li>
</ul>
我正在尝试单击复选框,该复选框使用带有 JAVA 的 selenium webdriver 出现在 jstree 中。
这是我迄今为止尝试过但没有成功的事情。
解决方案 1:
driver.findElement(By.xpath(".//li[@id = '733']/a/i[@class = 'jstree-icon jstree-checkbox']")).click();
解决方案 2:
driver.findElement(By.id("733")).sendKeys(Keys.SPACE);
解决方案 3:
WebElement element = driver.findElement(By.xpath(".//*[@id='733']/a/i[1]"));
Actions actions = new Actions(driver);
actions.moveToElement(element).click().perform();
解决方案 4:
driver.findElement(By.xpath(".//*[@id='733']/a/i[1]")).click();
所有命令后跟下面一行
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
我不断收到以下错误代码:
unknown error: Element is not clickable at point (695, 507). Other element would receive the click: <a class="jstree-anchor" href="#">...</a>
这是执行所有给定解决方案后发生的情况:
Dropdown box opens up but is not getting clicked
After checkbox is clicked in frontend
以下代码行添加到 HTML:
<span class="selectedCount" data-count="4"> (4)</span>
【问题讨论】:
标签: javascript java node.js selenium-webdriver jstree