0

I'm writing some code but I cant find the locator of checkbox please anyone help me to find locator! I've posted an image and sample code I've written below.

Img

WebElement target = driver.findElement(By.id("term_and_conditions"));
target.click();
Ganesh
  • 1
  • 2

1 Answers1

0

To click the check box you can use either of the following Locator Strategies:

  • cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("label[for='term_and_conditions']"))).click();
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//label[@for='term_and_conditions']"))).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352