Selenium HtmlUnitDriver单击复选框 [英] Selenium HtmlUnitDriver clicking on checkbox
问题描述
我正在尝试使用硒运行时单击我的复选框。
I'm trying to get my checkbox clicked while running using selenium.
使用chromedriver运行我的测试没有问题。
但是,当我切换到 HtmlUnitDriver
时,单击复选框操作会引发错误。引发的错误是
I have no issue running my test when using chromedriver.
But when I switch to HtmlUnitDriver
, it will throw error when it reaches the clicking of checkbox action. The error thrown is
org.openga.selenium.ElementNotVisibleException:您只能与可见元素进行交互
org.openga.selenium.ElementNotVisibleException: You may only interact with visible elements
我尝试了多种方法,例如:
I've tried multiple methods like:
driver.findElement(By.xpath("//*[@id=\"chkConfirm\"]")).sendKeys(Keys.SPACE);
driver.findElement(By.xpath("//*[@id=\"chkConfirm\"]")).click();
但它们都不起作用。有人可以帮我吗?
But none of it works. Can someone help me out?
推荐答案
好。我尝试了两个建议的答案,但没有一个。
Okay. I've tried both the suggested answer but none works.
所以我决定继续使用PhantomJS,它可以工作。
So I decided to move on to PhantomJS and it works.
感谢大家!
这篇关于Selenium HtmlUnitDriver单击复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!