Forum Discussion

francisd84's avatar
francisd84
Contributor
7 years ago

Task.State always returns 1 (idle) event if task is running.

Hi there,

 

I'm experiencing an undesired behavior when I try to get the realtime state of a task running from a Job in NetworkSuite.

 

My network suite has 1 job with 7 tasks running simultaneously through TestExecute.

 

In 1 task, I ask at each 5 minutes the state of 3 tasks using CodeSnippet in a Keyword Test: NetworkSuite.Jobs.ItemByName("JobName").Tasks.ItemByName("TaskName").State

 

Each time I call this code, I got "1" as response (which means Idle) even if all tasks are in running state.

 

Not sure if I'm doing the right thing to get the Task status or if it is an issue.

 

Thanks a lot for your help!

6 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    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.

    • francisd84's avatar
      francisd84
      Contributor

      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

       

       

      • francisd84's avatar
        francisd84
        Contributor

        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.