How can I find a java WebDriver checkbox item?

0

I need to find and select a checkbox.

<p class="checkbox">
  <div class="checker" id="uniform-cgv">
    <span class="checked">
      <input name="cgv" id="cgv" value="1" type="checkbox">
    </span>
  </div>
  <label for="cgv"></label>
  <a href="http://ejemplo.phpo  
  id_cms=3&amp;controller=cms&amp;content_only=1" class="iframe" rel="nofollow">
  (Read the Terms of Service)</a>
</p>
    
asked by Ariannis 08.04.2017 в 20:31
source

1 answer

0

What you ask, you can do it using the findElement method of the webdriver.

The findElement can be used for several things, from performing actions on a button or a form to obtaining the part of html contained in the tag.

Perform operations on the checkbox, it should be something similar to:

    WebElement checkboxField = driver.findElement(By.id("uniform-cgv"));
    checkboxField .click();

If this does not work, the documentation also allows searching by other attributes besides the ID.

Here you will find all the documentation: link

    
answered by 14.04.2017 в 16:55