Unable to locate element Selenium Java



  • My xpath:

    @FindBy(xpath = ".//div[@class=\"recaptcha-checkbox-checkmark\"]")
    private WebElement captchaCheckBox;
    

    Method:

    public void clickCaptchaCheckbox() {
        captchaCheckBox.click();
    }
    

    Exception:

    org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":".//div[@class="recaptcha-checkbox-checkmark"]"}
      (Session info: chrome=73.0.3683.103)
      (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 0 milliseconds
    For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
    Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'}
    

    Why element is not visible and I can't click on it?

    enter image description here



  • Copy Paste has added escape chars (\").

    Change it to:

    @FindBy(xpath = ".//div[@class='recaptcha-checkbox-checkmark']");
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2