0

I start to test new project, and the developer send API services to me to test it because frontend(UI) implementation is not ready. I have to write Automation scripts for features after stabilizing them

  • 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.
  • Can you please explain to me difference between Automate through WEB UI vs through Automate API
Mzaghleh
  • 17
  • 2

1 Answers1

1

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.

Cody Reichert
  • 1,620
  • 15
  • 13
  • 1
    Thank you very much for this clear answer, Yes currently I am using postman to test API manually. and company want to automate the test, that's why I am looking to do it through API instead of UI, although all my automation experience is based on UI using selenium. So, now that leads me to ask one more question, Why QA automation engineer go to use UI testing and locate elements using ID/Xpath?, I mean why Automation API is not common as UI Automation? – Mzaghleh Jun 03 '17 at 23:29
  • That's a good question - I think a big reason is that separating the API from the UI is a relatively new thing. These days, it's best practice to write your API separately from the UI. Before that, UI and backend were tightly coupled, so Selenium tests covered a lot of ground. API test automation is becoming more popular now that APIs are used independently. (PS - If you have a Postman collection, Assertible can automate those requests. [See here](https://assertible.com/blog/new-feature-import-and-automate-api-tests-from-postman-collections)) – Cody Reichert Jun 03 '17 at 23:47