Forum Discussion

ilkoTest's avatar
ilkoTest
New Contributor
1 day ago

Running the Execution Plan enabled items via script within TestComplete

Hi,

I have a huge test project that contains hundreds of test items. Unfortunately, TestComplete does not provide a progress indicator for the test execution. The entire project runs for many hours, and it would be great to see how many test items were executed.

I am trying to write a JavaScript script that can execute the enabled test items in the Execution Plan one after another and show me the execution progress.

I am stuck at the point where I am trying to execute the following command block:

if (itemSelected.Enabled)
{
  Log.Message("The selected item is enabled");
  var progress = Math.round((i / count) * 100);
  Log.Message("The progress value is: " + progress);
  
  Indicator.PushText("Running: " + itemSelected.Name + " (" + progress + "% Complete)" + "out of " + count);
  
  try {
    itemSelected.Run();
  }
  catch(e){
    Log.Error("Error executing " + itemSelected.Name + ": " + e.message);

  }
  Indicator.PopText();
}
else
{
  Log.Message("The current item is disabled in the Execution Plan");
}

TestComplete throws the error saying that 

Error executing <itemSelectedName>: itemSelected.Run is not a function

If I remove the brackets after Run, TestComplete ignores this command and iterates to the next item.

 I was wondering if anybody has any idea how to overcome this and run the selected test items via script.

Thanks

4 Replies

  • eykxas's avatar
    eykxas
    Frequent Contributor

    Hi !

    How do you initialize "itemSelected" ? I think the problem is here. I'm pretty sure "ItemSelected" does not expose a Run() function.

    • ilkoTest's avatar
      ilkoTest
      New Contributor

      This is JavaScript code. The initialization is done by assigning a value to the itemSelected:

      for (var i = 0; i < count; i++)
        {
          var itemSelected = testItems.TestItem(i);

      And you're right; it does not expose the Run() function, which I am getting an error for. 

    • ilkoTest's avatar
      ilkoTest
      New Contributor

      Thank you for your reply. While the TestComplete Command Line seems a good solution for running the tests, I don't think it will support the progress indicator, which is my primary focus of why am I doing all of this