0

I have response:

<html>
  <body>{"name":"test","value":"new","_id":"578641fec44c56220b15e5f9"}:</body>
</html>

I want to assert "name" using RestAssured body() method

I came up with this: .body("html.body", containsString("\"name\":\"test\"")).

Is there a way to do it more elegant using body()?

3
  • Please don't tag your titles, and make them a clear, specific question. See How to Ask. Commented May 3, 2024 at 20:30
  • 1
    What isn't elegant about the code you came up with? How is the elegance of answers to be judged? Commented May 3, 2024 at 20:32
  • I think it’s not good practice to use json as string. I want to be able to get field from json and compare it against its value like in “equalTo()” method of hamcrest matchers Commented May 5, 2024 at 7:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.