Use PDIs? Take our 5-minute survey to help shape the PDI roadmap.

ATF Create a User Domain Empty and Impersonation Fails with Invalid sys_id

poojayp
Tera Contributor

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

  1. Create a Manager User

  2. Create an Employee User

  3. Insert Leave Balance record

  4. Open Service Portal

  5. Open Leave Catalog Item

  6. Set Leave Type = Bereavement Leave

  7. Submit the Leave Request

  8. Impersonate the Manager

  9. 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

  1. 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?

  2. Why does the Create a User step show Domain = (empty) even though the test is being run in the xyzdomain?

  3. Is the Impersonate step referencing a static/old sys_id instead of the user created by the previous Create a User step?

  4. What is the recommended way to impersonate the user dynamically created by an ATF Create a User step in a Domain Separated instance?

  5. 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 exist

Any guidance on how ATF handles Domain Separation + Create a User + Impersonate would be greatly appreciated.

0 REPLIES 0