I have a few text fields which when I login as a specific user (rights of a read only) , all the text fields are not allowed to be edited. I am trying to automate this page in Cypress.

I tried using :

cy.get(element).should("have.text", readonly,readonly).

Both failed.

Please let me know if anyone has any other options.

  • What's the actual DOM you're trying to test? Are the inputs disabled? Do they have the attribute readonly set (is that what you're trying to test with "have.text")? Something else (e.g. code behind just ignores whatever the user tries to type in)?
    – jonrsharpe
    Jul 15 at 7:42
  • The DOM is an input field (a text box) . They dont have an attribute "readonly" . Currently there is no value in the text boxes, Jul 15 at 8:20
  • Can you paste the relevant DOM? Disabling can be implemented in many ways - your code should be align with the specific way. Jul 15 at 9:36
  • Here is one example of it. there are 15 text fields . all of them are non editable. Jul 16 at 12:27
  • 1
    Past the ACTUAL dom from view page source so we can see the input field, any label field and any other wrappers immediately around them. We can guess endlessly about what it might be but you can tell us (and then we can help you) by showing us the HTML code. Jul 16 at 23:52

1 Answer 1


Please close the thread. i got the answer , i asked the developer to add an extra attribute. Thank you very much.

  • Please don't add "thank you" as an answer. Instead, accept the answer that you found most helpful. - From Review 19 hours ago
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review 15 hours ago
  • Please edit your answer to explain what the extra attribute you asked the developers to add was, and how this solved your problem. You will be able to accept your answer as correct. By explaining your solution in more detail, you will help others who encounter the same issue.
    – Kate Paulk
    12 hours ago

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.