This is my HTML page and I have some problem with my automation code and it is not able to locate the element and this is the XPath I used:


HTML Code:

<div class="col s4">

  <div data-radium="true">

    <div class="waves-effect waves-dark btn-large " data-radium="true" style="color: white; text-transform: capitalize; box-shadow: none; padding: 0px 2rem; border-radius: 5px; height: 50px; line-height: 50px; width: auto; cursor: pointer; background: rgb(0, 208, 156);">

      <div>I'm Done</div>
  • With the given HTML the locator should work. May be it appears after some actions - so you may need to access it after those actions. Commented Oct 1, 2018 at 7:32
  • 2
    Add exception you received after running your code.
    – Bharat Mane
    Commented Oct 1, 2018 at 7:38
  • 1
    Make sure your desired element is not located inside an IFRAME Commented Oct 1, 2018 at 19:35
  • Voting to close unclear what you are asking. No response to what was your exception, did you look for an iFrame. Commented May 2, 2019 at 8:32

2 Answers 2


Sometimes elements are not accessible directly. So, in test automation services we try including the parent div to locate that element. As per the given HTML, you can use below-mentioned locator that might help to resolve the issue.

XPath: @FindBy(xpath="//div[@class='waves-effect waves-dark btn-large']//div[contains(text(),'Done')]")

Further, please check whether the element is present inside an iFrame. If yes, please switch to the desired iframe first before using XPath

If you still face any issue provide more HTML so that we can assist you with a better solution.


Sometimes the text() function not work, So try using ( . ) instead of text()


And In case there are multiple elements founded surround your xpath by index


Not the answer you're looking for? Browse other questions tagged or ask your own question.