How do I turn a UI test into API tests?
In SmartestQA a web test case with a Network step in List mode records the calls the browser makes during a pipeline run. In Maintenance, on the Network Calls tab, Make API test turns the calls you pick into API Request steps in a new test case, with the login token extracted and secrets replaced by variables.
In short
On this page you can
- Capture the API calls behind a web UI flow during a normal run.
- Turn the captured calls into API Request steps in a new test case.
- Keep the login: the token is extracted and sent by the later requests.
- Replace the host with a
{{baseUrl}}variable for every environment. - Generate a JMeter test from the new API test case.
How to use it
- Add a Network step in List mode at the end of the web test case.
- Run the test case in a pipeline.
- Open Maintenance, tab Network Calls, and click Make API test.
- Pick the requests, set the two options and click Create with n steps.
- Define the listed variables, add assertions and run the new test case.
The short answer#
You do not rebuild the requests by hand. A Network step in List mode writes the calls of the browser session, with their requests and responses, to the report. After the test case has run in a pipeline, Maintenance lists it on the Network Calls tab. Click Make API test, pick the requests, and SmartestQA creates a new test case in the same folder with one API Request step per request, in capture order.
Network steps exist only in WEB projects, so this path starts from a web test.
The problem this solves#
Many teams have UI tests for their main flows and few or no API tests. To add them, someone has to find out which calls a screen makes. Often that means opening the browser’s developer tools, clicking through the flow and copying the calls one by one into a client or a script.
That takes patience, and it has traps. The copied calls carry a token that soon expires, and sometimes a password. The login has to be rebuilt so later calls get a fresh token. When the flow changes, the copying starts again. So the API tests are often put off, although the UI test already makes every call that is needed.
An example#
This is an illustration, not a customer story. A team tests an HR portal and has a web test case named “Submit leave request” that logs in, fills the form and checks the confirmation.
- A tester opens the test case in Automate, clicks Network, picks List and Set it up myself, leaves the URL empty and adds the step at the end. It shows the chip Net List.
- The test case runs in the nightly pipeline, as it did before.
- The next morning the tester opens Maintenance and the Network Calls tab. Under Pending there is one row for the test case, and the tester clicks Make API test.
- The dialog Network → API steps opens on the filter API calls. The request marked Login and the portal’s own calls are pre-selected, and the counter says “6 requests selected”. The tester turns on Replace the host with a {{baseUrl}} variable (update it in one place per environment).
- The name is pre-filled as “Submit leave request - API”. A click on Create with 6 steps answers “Submit leave request - API created (6 API steps)”. The new test case opens in Automate and the row moves to Converted.
- The tester defines the listed variables, among them
baseUrland the password that was masked, adds an Assertion on the status of each response and runs the test case.
The team now has an API test for the flow without having copied a single call.
Copied by hand, with your own scripts, and with SmartestQA#
| Question | Calls copied by hand from the browser | Your own API test scripts | SmartestQA |
|---|---|---|---|
| How do you find the calls a screen makes? | Click through the flow with the developer tools open | Read the API documentation or ask the developers | A Network step in List mode writes them to the report during a pipeline run |
| Who builds the requests? | A person, one by one | Someone who writes code | Make API test creates one API Request step per selected request, in capture order |
| What happens to the login? | The copied token works until it expires | You write the login call and pass the token on | The token of the login request is stored in {{authToken}} and later requests send it |
| What happens to passwords and tokens? | They are in the copied call unless you remove them | In configuration you manage | The report masks them as ***; the conversion turns them into variables that you fill in |
| What is left for you to do? | Everything after the copy, including the checks | Everything | Define the listed variables, add custom headers your API needs, and add assertions: an API step passes for every HTTP status |
| Where does it work? | Any application you can open in a browser | Any API | WEB projects only, for test cases that have run in a pipeline or scheduled run |
Steps#
Add a Network step in List mode
Open the web test case in Automate and click Network on the step toolbar. In the dialog Add Network step pick List and Set it up myself. The URL is optional (“Leave empty to list every call.”). Fill Test Step Name and click Add. Put the step at the end of the flow: by default List uses the Scope “Whole session”. See List.
The step appears with the chip Net List.
Run the test case in a pipeline
The Network Calls tab lists a test case only after it has run in a pipeline or scheduled run. New runs update the row; they do not add rows.
Open Network Calls
Open Maintenance and the Network Calls tab. It opens on Pending, with one row per test case: “s Network steps · c calls”, the date of the latest run and the number of runs. Click Make API test. From a report, Convert to API steps brings you to the same dialog.
Pick the requests
The dialog Network → API steps opens on the filter API calls. Tick or untick rows, or use Select All for the visible filter. The counter says “n requests selected”. Keep the request marked Login selected whenever later calls need a token.
Choose the two options
Add Bearer {{authToken}} to requests after login is on by default: requests after the login request send its token. Replace the host with a {{baseUrl}} variable (update it in one place per environment) is off by default; turn it on when the same API runs on several environments.
Read the warnings, name and create
The dialog lists what you must fill in afterwards, for example “You need to define values for these variables: …”. New test case name is pre-filled as “<test case> - API”. Click Create with n steps.
“<name> created (n API steps)”. The new test case opens in Automate, and the row moves to Converted.
Finish the API test case
Define the listed variables, add any custom headers your API needs, add assertions on the responses, and run it. An API step passes for every HTTP status, so the assertions are what make the test fail. See Check the status code.
What the conversion does with the capture#
| In the capture | In the new API test case |
|---|---|
| Each selected request | One API Request step, in capture order, named by method and path, for example POST /api/orders. Query parameters are kept. |
| The login request (its response contains a session token) | A JSON extractor stores the token in {{authToken}}, and a refresh token in {{refreshToken}}. |
| A masked Authorization header | Bearer {{authToken}} |
| A masked header or body field, such as a password | A {{name}} variable; you fill in the value. |
| Browser headers: Host, Cookie, User-Agent, Referer, Origin, caching and similar | Not copied |
| A body that is truncated in the report | Marked “truncated”: “The body is truncated in the report. Complete it after saving.” |
| The new test case | Created in the folder of the source test case, with its environment, and the description “Generated from the Network capture of the "<name>" run.” |
Which requests are pre-selected#
| Request | Pre-selected |
|---|---|
| Your app’s own API calls that did not fail, each method and path once | Yes |
| The login request, marked Login | Yes, unless it goes to a third-party site |
| The same method and path again, marked “duplicate” | No, only the first |
| Requests to other sites, analytics and tracking services | No |
| Static files: scripts, styles, images, fonts | No |
| WebSocket and event streams | No |
| OPTIONS and HEAD requests | No |
The filters Pages, Static, Third party, Other and All appear when there are such requests, so you can still tick them. See Make an API test, step by step.
What you get#
- An API test from a run you already have. One API Request step per selected request, in the order the browser made the calls.
- A working login. The token of the login request is stored in
{{authToken}}and the later requests send it. - No secrets copied. The report masks Authorization, Cookie, Set-Cookie and X-API-Key headers and body fields such as password, token, secret or otp as
***; the conversion turns them into variables. - One switch per environment. With the
{{baseUrl}}option the host is a variable; setbaseUrlas a suite parameter. - A clear status. The test case stays under Converted with a link to the API test case, even after later runs.
- A path to load tests. A JMeter test can be generated from the new test case in Automate.
Questions and answers#
Which test cases can I convert to API tests?Customers
Test cases that have a Network step and have run in a pipeline or scheduled run. SmartestQA lists them in Maintenance on the Network Calls tab, one row per test case; the latest run of each Network step is used and all Network steps of the test case are combined in one list. See What the tab lists.
Why is my test case not on the Network Calls tab?Customers
The tab lists a test case only when it has a Network step and has run in a pipeline or scheduled run. It opens on Pending; a test case that was already converted is under Converted. See My test case is not listed.
Does this work for mobile or desktop tests?Customers
No. Network steps exist only in WEB projects and are not offered in mobile and desktop projects. In those projects you can still add API steps from the API Requests library. See Network step limits.
Which Network step mode should I use for the capture?Customers
List, for the whole session. Check and Get value capture a single request. List hides static files such as CSS, scripts and images and reports API calls, page loads and errors. See The three modes.
Does the capture see every call with Selenium and with Playwright?Customers
Playwright sees all calls. Selenium sees fetch and XHR calls, and the first page load only in Chrome and Edge; iframes, service workers, sendBeacon, form posts and static files are not seen. See Limits.
What happens to passwords and tokens in the captured calls?Customers
They are not copied. The report shows them as ***, and the conversion adds them as variables: a masked Authorization header becomes Bearer {{authToken}}, a masked header or body field becomes a {{name}} variable that you fill in. See What gets created.
What does “Requests use {{authToken}}, but no selected request produces a token.” mean?Customers
The requests you picked send a token, but the login request is not among them. Select the request marked Login whenever later calls need a token. Each warning of the dialog is explained in Troubleshooting.
Can the API test run on DEV, TEST and PRP?Customers
Yes. Turn on Replace the host with a {{baseUrl}} variable (update it in one place per environment) in the dialog and define baseUrl, for example as a suite parameter in the pipeline. See “{{baseUrl}} must be defined at run time”.
My API needs a tenant or language header. Is it copied?Customers
No. A List capture has no request headers, so add such a header to the API steps after the conversion. See The request.
Can I convert the same test case again?Customers
The test case stays under Converted, even after later runs. If you delete the API test case that was created, the row returns to Pending and you can convert it again. See After the conversion.
Can I load test the calls I captured?Customers
Yes, in two steps: make the API test in Maintenance, then generate a JMeter test from that test case in Automate. See Generate with AI from API steps.
Read more#
- Network Calls: the tab, the dialog and what gets created.
- Network step: Check, Get value and List, with all settings.
- API Request step: the request, JSON paths and status checks.
- The API library: build API tests from Postman, Swagger / OpenAPI or curl instead.
- Maintenance FAQ: more questions and the limits.
- How do I test a REST API without writing code?: API steps and assertions from the start.
- How do I get a load test from my functional tests?: the next step after the conversion.
Didn’t find your answer?Write to support with your project name and what you see on screen.
info@smartestqa.ai