Authenticate with API request or reuse existing authentication state in TestComplete
Hello,
I am looking for a way in TestComplete to authenticate with API request or reuse authenticated state. I want to test authentication (login) only once and avoid going through login page in all other tests. This could speed up test execution significantly (currently authentication step takes 4-6 sec).
I know that TestCompete allows sending HTTP requests Sending and Receiving HTTP Requests From Script Tests | TestComplete Documentation (smartbear.com).However, I am not sure how to implement this with API login, store and reuse authenticated browser state.
I was not able to find related solutions in the docs and community answers.
I know that this approach is recommended when using other tools like Playwright and Cypress . I would appreciate it if you could guide me on what would be the best way to implement reusing authenticated session in multiple tests.
Some context. I do not have much experience with test automation, but I know that our app uses Bearer token and cookie with token sent in headers when user is authenticated. We use Auth0 for authentication and I was able to implement login test in Postman using Auth0 API and user credentials. We have multiple user roles, so, ideally, we would like to store authentication session separately for each user role. We have a subset of tests that can run at the same time with the same account, without affecting each other. Currently most of our tests implemented as keyword tests but we use some scripts too. We plan to run our tests in multiple environments (QA, UAT, production).
Example test (currently):
1. (2s) Launch browser
2. (3s) Open login (UI form)
3. (2s) Submit login form
4. (2s) Open Dashboard page
5. (0.5s) Verify dashboard page opened (text is displaying and menu is visible).
6. (2s) Logout
TOTAL time: 11.5s.
Example test (desired):
1.(0.1s) Login with API or load authentication state from previous test.
2. (2s) Launch browser
3. (0.1s) Apply authentication state in browser
4. (2s) Open Dashboard page
5. (0.5s) Verify dashboard page opened (text is displaying and menu is visible).
6. (2s) Logout.
TOTAL time: 6.7s.
Thank you,
Maksim