Milestone 5 of 9
API layer
Your framework talks to the DojoCover API directly: it signs in, reads and creates data, and checks status codes, response bodies and validation errors.
Why it matters
API tests are fast and stable, and an API layer is what makes hybrid tests possible. Interviewers for SDET roles expect both.
What to build
- An HTTP client wrapper. One class or module that knows the base URL (from your config), sends JSON, adds the
Authorization: Bearertoken, and turns responses into objects. Tests never build raw requests. - Models. Typed classes or records for a policy, a claim and an error, so tests compare fields rather than strings. Read the API reference for each shape.
- Sign in and reset. A
login(username, portal)method that returns the token, and a call toPOST /staff/resetas the admin before the suite, replacing the manual reset from milestone 4. - API tests. List policies with a filter, file a claim and read it back, and check the errors: a claim on an expired policy (
422withfields.policyId), a request without a token (401), and a customer trying to approve (403).
Rules
- The token is never written to a file or a log.
- Check the status code and the body: a 200 with the wrong data is still a failure.
- API tests don't open a browser.
Hints
Selenium
Selenium has no HTTP client, so add one: REST Assured or HttpClient (Java), requests (Python), HttpClient (C#), or fetch/axios (JavaScript). Keep it in its own package, beside the page objects.
Playwright
Playwright's request fixture (APIRequestContext) is an HTTP client: give it the base URL in config, and use request.post(`/api/cover/${env}/login`, { data }).
These are pointers, not solutions. TestDojo doesn't publish a finished framework: the point is that you build and understand your own.
Done when
Ticks are saved in this browser only, for your own tracking.
In an interview
Questions this milestone prepares you for, and what a good answer covers. Answer them in your own words, about your own framework.
- How do you test an API?
- Status codes, response bodies and schemas, error cases and authorisation, not just the happy path.
- How is your API layer structured?
- A client, models and endpoint methods, kept apart from the tests, with configuration and auth in one place.
- UI tests or API tests: which do you write more of?
- The test pyramid: most checks at the API level, a smaller set of UI journeys, and why.
Note the decision you made in this milestone and why. Those notes become your README in milestone 9.