我正在尝试点击一个复选框,这是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>
我正在尝试单击复选框,在jstree中使用带JAVA的selenium。
到目前为止,我尝试过的一些事情都没有成功。
解决方案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>这是在执行所有给定的解决方案之后发生的情况:
下拉框打开,但未被单击。
在前面单击复选框后
以下代码行被添加到HTML中:
<span class="selectedCount" data-count="4"> (4)</span>发布于 2016-06-01 20:37:34
我认为问题在于您正在尝试单击<i>,而实际上<a>是可点击的。试试这个:
driver.findElement(By.xpath(".//li[@id='733']/a")).click();https://stackoverflow.com/questions/37578036
复制相似问题