enter image description here

enter image description here

enter image description here

please send me the full code I tried Some XPath and CSS:




div.col-md-1.checkbox.checkbox-primary > label*

but using above locators I'm not able to click on the checkbox.

Anyone could suggest me on this, What needs to done?

  • All you examples show looking for label. But label is not checkbox. You cannot click, or get status of a label. You need to first locate the correct element. @Zhivko.Kostadinov has the correct path in their answer. – MivaScott May 3 '18 at 18:25

Does it work?

   if ( !driver.findElement(By.id("selectCheckBox")).isSelected() )

p.s In case you wish to select (if it's not selected) or if it's selected, code remove the check box. BUT: The problem is you can't locate an element, or you can't write the code with Java?

  • Please mention proper description why should it work & how it resolve the problem. – Nitin Rastogi May 3 '18 at 9:21

Use this code.

String demo = "//input[@id='selectCheckBox']";

// to check the checkbox is already selected or not


driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElementByXpath(demo).click();   // Select the checkbox


Use explicit wait condition and preform click.

WebDriverWait wait = new WebDriverWait(driver, 10);   
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("selectCheckBox")));

The above Java code states that we are waiting for an element for the time frame of 20 seconds as defined in the "WebDriverWait" class on the webpage until the "ExpectedConditions" are met and the condition is "visibilityofElementLocated".


When you get a ElementNotVisibleException, there can be multiple reasons.

  1. In UI check the view port of the element. Make sure the element is not overridden by any other element.
  2. Check if the element is present in the current browsing context.
  3. If the application supports localization, different browsers render the content in different way. Try locating the element in the same browser in which you are running the automation.

Please check with the below xpath,


If not working, please paste the html portion in the question. Not as an image. So that the locators can be checked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.