ATF Create a User Domain Empty and Impersonation Fails with Invalid sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Here is a clear ServiceNow Community post you can use. I’ve included the exact ATF behavior, Domain Separation context, execution results, and the question you need answered.
Title: ATF Create a User shows Domain = empty during execution, but test is configured for xyz domain – Impersonate step fails with “User does not exist”
Hi Community,
I am facing an issue with an Automated Test Framework (ATF) test in a Domain Separated ServiceNow instance.
I am running the ATF test while my current domain is xyz.
The test is for a manager approval scenario for a Bereavement Leave request.
ATF test flow
Create a Manager User
Create an Employee User
Insert Leave Balance record
Open Service Portal
Open Leave Catalog Item
Set Leave Type = Bereavement Leave
Submit the Leave Request
Impersonate the Manager
Continue with manager approval
The first 7 steps are successful.
However, the Impersonate step fails.
Execution result
The Create a User step successfully creates the manager:
First name = Test Last name = Manager User ID = test.man Domain = (empty) Roles = [itil, snc_internal, approver_user]
The employee user is also created successfully, but its execution result also shows:
Domain = (empty)
The test is being executed in the xyz xdomain.
The failure occurs at the Impersonate step with:
User with sys_id '97d32e3760ba431041e37912d1dd574f' does not exist
My concern
During test creation, I selected/configured the user/domain for xyz, and I am also running the test while the current domain is xyz.
But during execution, the Create a User ATF step shows:
Domain = (empty)
And when the test reaches the Impersonate step, ATF tries to use a sys_id that does not exist.
Questions
Does running an ATF test while the current domain is xyz automatically create the test user with sys_user.domain = xyz , or does the domain need to be explicitly set?
Why does the Create a User step show Domain = (empty) even though the test is being run in the xyzdomain?
Is the Impersonate step referencing a static/old sys_id instead of the user created by the previous Create a User step?
What is the recommended way to impersonate the user dynamically created by an ATF Create a User step in a Domain Separated instance?
Is there any special configuration required for ATF user creation and impersonation when testing within a child domain such as xyz?
I have attached a screenshot showing the domain hierarchy and the ATF execution result.
The main issue is:
Current execution domain = xyz
↓
Create a User
↓
Domain = (empty)
↓
Impersonate
↓
User with sys_id '97d32...' does not existAny guidance on how ATF handles Domain Separation + Create a User + Impersonate would be greatly appreciated.