Search code examples
javaseleniumxpathcheckboxhtmlunit

Selenium HtmlUnitDriver clicking on checkbox


I'm trying to get my checkbox clicked while running using selenium.

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: 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?


Solution

  • Okay. I've tried both the suggested answer but none works.

    So I decided to move on to PhantomJS and it works.

    PhantomJS

    Thanks everyone!