-1

I want check a checkbox in Selenium WebDriver with java , but It returns an exception ElementNotVisibleException.Element is currently not visible ...

The element is invisible but not hidden. I tried it with both firefox and PhantomJS but it doesn't work.

I found many suggestions here but it still not work

HTML code :

<span class="checkbox"> 
<input id="terms-checkbox" class="required" type="checkbox" name="terms_agreement">
</input> 
<label for="terms-checkbox"></label>
</span>
3
  • Add some more details: HTML, what have you tried, and so on. Refer to stackoverflow.com/questions/16651610/… Commented May 14, 2014 at 7:40
  • I tried to test a website with selenium in a maven project. So , the test works finely but not to check the chekbox , I can see the element in the browser with firefox or PhantomJS. but it can't check it and I got an excpetion . I think it's a visibilty issues but I don't know the solution Commented May 14, 2014 at 7:50
  • for (int second = 0;; second++) { if (second >= 60) fail("timeout"); try { if (isElementPresent(By.id("terms-checkbox"))) break; } catch (Exception e) {} Thread.sleep(1000); } driver.findElement(By.id("terms-checkbox")).click(); Commented May 14, 2014 at 7:56

1 Answer 1

0

As mentioned in question, the element is not hidden but could not find. So, it may be visible through label tag. You should try with the below code:

driver.findElement(By.xpath("//label[@for='terms-checkbox']")).click();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.