Forum Discussion
Just as a test, try the code using one specific job name and task name, so you don't have the ItemByName in there. See if that gives you the state that you are expecting. Then we can make sure that the State is coming back correctly.
No changes
That's what I tried to test the behavior (All using Keyword Tests):
1) Network suite-> 1 Job -> 2 Tasks
2) Task 1 Log the state of Task 2 in a loop of 5000ms from TestExecute
3) Task 2 turn in a loop using Label->Go To Label with a delay of 3000ms from TestExecute
4) Execute the job
Not sure about how to handle specific job and task in
To log the Task 2 state, I tried 4 different approaches:
-Using 1 liner code snippet [NetworkSuite.Jobs.ItemByName("Name").Tasks.ItemByName("Name").State] -> Returns 1 for each state.
-Using an Object Variable to store all tasks of Job using index instead of name [NetworkSuite.Jobs(0).Tasks]
Then asking for state of task item 1 [KeywordTest.testname.Variables.Var1.Item(1).State] -> Returns 1 for each state
-Using an Object Variable to store the specific task using index [NetworkSuite.Jobs(0).Tasks(1)]
Then asking for state [KeywordTest.testname.Variables.Var1.State] -> Returns 0 for each state
FYI, I'm using TC 12.20.935.7
- francisd848 years agoContributor
I also test the Task and Tasks objects by using Name property; it returns the good Task name, so I'm assuming that the object variable was good.
- Marsha_R8 years ago
Champion Level 3
I wouldn't assume that the object variable is good. Sometimes what goes in a variable is not the same type that comes out. That is why I suggested taking out all the references and just ask for the state of a specific task by specific name.
You want to eliminate anything that could be interpreted and just get the state. That will tell you if TestComplete is reading it correctly or not. Then you can backtrack and figure out if the variable is wrong or the object name is wrong or something else. Start with the smallest part first.
- francisd848 years agoContributor
I understand. But I don't figure out how to do that small part. As I see, I cannot just call "[taskname].State". If I do so, that returns an exception.
How can I directly ask the state of a task using something else than "NetworkSuite.Jobs......"?