It's definitely possible to automate API service testing without a UI, and in many cases it's actually preferred.
Is it possible to automate API services functionalities, and how plz?
or I have to wait untill frontend is ready so I can locate elements and automate through UI.
You can test the API separately from the frontend UI. Remember, all the frontend UI does is make requests to the backend API. So instead of using the UI to make API requests, you can use a tool like Assertible, which allows you to send HTTP requests to the API and make assertions on the response.
When you're testing an API, you'll want to validate things like status code (eg, 200), and the response body to sure you get the expected response.
Basically:
1) Send API requests (eg, GET /users
)
2) Receive API response (eg, [{id: user1}, {id: user2}]
)
3) Assert the response status code equals 200
. Or, assert that 2
users are returned from the API.
Can you please explain to me difference between Automate through WEB UI vs through Automate API
The big difference is like i mentioned above: when you automate testing through the web UI, you are simply using the UI to make API requests. To test the API by itself, you just send requests directly to the backend.
There's many different tools and services you can use to accomplish this. If you want to use a hosted service that doesn't require much code, Assertible and Postman are both great. If you want to write code, you can use pretty much language/library that allows you to make HTTP requests. In JavaScript, for example, Chakram and Frisby.js are both popular choices.
Hope this helps!
As a side note - testing an API separately from the UI has a lot of advantages. Namely, keeping tests small and isolated so that tests aren't flaky and can easily be traced back to a root cause.