Here's an example of HTML code that I am working with:
<button id="toolbar-item-17-update-id" type="submit" name="action" value="update" class="button-action-update btn btn-secondary">
Edit
</button>
I am trying to locate this button using the XPath //button[contains(., 'Edit')]
. This method works when inspecting the element, but I encounter a DOMException error in JavaScript when trying to use the same syntax.
What is the correct syntax that I should use instead?
let btn = document.querySelector("[contains(., 'Edit')]");