Creating ATF with Script

snoozer
Mega Guru

I am trying to create an ATF test with a script. I'm getting along pretty well until I have to create a step that references a previous step.

 

For example, this Record Update step. I want to be able to put a record that was previously created by the test into the Record field. I have looked at a step that already has that record to see how it's resolved, by doing a gs.info(gr.inputs.record_id). I get back this string: {{step['920e64422d35b99099c73d5676edf56a'].u_record}}

 

So in my script, I feed that string in:

gr.inputs.record_id = "{{step['920e64422d35b99099c73d5676edf56a'].u_record}}"

 

This does not work. When I look at the step that gets created, that record is not filled in. (All of the rest of the variables that I set are correct.) When I run the test, it says it can't find that record.

 

Can anyone help me figure this out? I've been trying to look into how exactly all of this works, but it is very difficult to follow by looking at tables in ServiceNow and there is not a lot of documentation.

 

Thanks.

3 REPLIES 3

Shaqeel
Mega Sage

Why are you doing the complex way.

I am sure there is a more simpler step can you follow.

Eg:

After record is open.

User Open existing record

Update the fields (Set field value)

Save/update.

 

 


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel

Because I am a complicated person!

 

The simplest answer is that I'm going to have to create around 300 steps for this test and I do not want to do it manually; writing a script is a much better way to do repetitive tasks like this. There are other factors as well, but that's the biggest.

 

I have actually had success with creating a single step manually and then having the script copy that step. The record I need gets copied over from that original step and then I can change the other things I need. But I am still curious about how it actually works!

You can try parameterized testing.


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel