Java Selenium click checkbox



  • I can’t get selenium to click on this checkbox button no matter what I do.

    Error:

    no such element: Unable to locate element:

    I have used sleep thread timers and wait.until(ExpectedConditions.visibilityOfElementLocated()).

    Here is the HTML of the button:

    <input id="1_2_null" type="checkbox" name="1.0.50.gecb16" xgc="" rownumber="1">
    

    I have tried :

    driver.findElement(By.xpath("//*[@id=\'1_2_null\']")).click();
    driver.findElement(By.name("1.0.50.gecb16")).click();
    driver.findElement(By.id("1_2_null")).click();
    

    It's possibly inside this iframe:

    <iframe frameborder="no" width="100%" height="100%" src="" id="maincontent" name="maincontent"></iframe>
    


  • There could be two reasons for that

    1.) your element is not present on the same frame

    ii.) the id of the element is dynamic, you can use startswith, endswith or Contains methods of xpath.

    if you can share the Exception, I would be more specific on what might be causing that issue



Suggested Topics