This is my html source:

<div class="col s12">
    <input type="checkbox" class="filled-in"
           d="corresp-checkbox" data-class="jrnlCorrRef" data-note-
           class="jrnlCorrAff" data-selector=".//*[@class='jrnlCorrRef']
    [not(@data-track='del')]" data-type="checkBoxComponent" data-
           validate="requiredField" data-save-type="setCorrespondingAuthor"
           data-check-field="jrnlEmail" autocomplete="off" autocorrect="off"
           autocapitalize="off" spellcheck="false">
            for="correspcheckbox" style="margin-
    top:10px" contenteditable="false">Corresponding:
    <div class="input-field">
        <span class="text-line"
              type="text" contenteditable="true" data-selector="//*
    [@class='jrnlEmail']" data-class="jrnlEmail" data-
              data-email="true" data-parent="jrnlAuthorGroup"></span>
                for="email" contenteditable="false">Email

absolute xpath from copy xpath receives click:


My own relative xpath throws error element not visible:

  • Please add what your code and what the error is being thrown in a proper way. Simple copy pasting the HTML/DOM is not gonna be helpful to anyone tryna debug. – demouser123 Feb 9 '18 at 7:07
  • @demouser123 i have updated now – Harri Feb 9 '18 at 7:16
  • @Harri Can you try using //label[@for='correspcheckbox'] xpath and update me same – NarendraR Feb 9 '18 at 8:50
  • @NarendraR NoSuchElementError: no such element: Unable to locate element: {"method":"xpath","selector":"//label[@for='correspcheckbox']"} – Harri Feb 9 '18 at 9:11

As the code isn't clear high level solution would be insert an explicit wait before the operation. And try locating the element. If it is located proceed as usual. If you are unable to locate or somehow not successful try using JavascriptExecutor. Providing a sample below:

JavascriptExecutor jse = (JavascriptExecutor) driver;
WebElement element = driver.findElement(By.id("checkbox_accept-terms"));
jse.executeScript("arguments[0].click();", element);
| improve this answer | |

i can't see your code because you haven't included it with the question, however it looks like you are encountering a common issue with the selenium api where it is possible to discover an element but not be able to click it.

This can happen when a page is still loading or a syntax error in the page can cause it to load incorrectly. In this case it looks like some of the odd line wrapping within quoted data might cause parsing issues.

I would suggest loading the page in a browser and viewing the DOM to verify this content renders as you expect it to.

| improve this answer | |

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.