Is it okay to use UI automation code in API automation tests?
Say that I am testing a GET api. The get api fetches data which is stored due to user actions on a web UI. The data cannot be setup by simply looking at the network inspector calls for these actions and then repeating the calls. Ideally, I'd like to use apis to setup the data, but that is not possible now. So, I was thinking of putting UI automation code in my api automation code just to setup the data. Is this acceptable ? If not, then why ?
I don't see any challenges other than html locators getting changed, which would be very rarely for this web app.
carriann last edited by
Creating test data via GUI will have the following impact:
- test execution time will grow,
- test will become 'flaky', results will not be trusted,
- test will be prone to
errorsdue to html changes,
- if you use CI you will become dependent on browser,
- or will have to write browser independent code,
I suggest creating the data straight in the database (if possible), if not you can separate the jobs, so if test data creation fails test are not executed (this might help a little with trust issues, but you will still encounter all other problems).