cancel
Showing results for 
Search instead for 
Did you mean: 

Capturing the Command Line of a Process running in the Task Manager

SOLVED
BenoitB
Community Hero

Re: Capturing the Command Line of a Process running in the Task Manager

Could you show me the code that call the ProcessFinder function ?

 

I suspect this is because you need to make a loop after the click on image and call ProcessFinder in the loop.

Un sourire et ça repart

nedbacan
Contributor

Re: Capturing the Command Line of a Process running in the Task Manager

@BenoitB ,  The test is done in Keyword but I converted it into a script so you can review it.   See below.

 

What the script is doing is finding a patientID and clicking on an image so it can open in the window display, when this is done the process is called.  

To test the function you send me, I perform the test manually to get the process to appear in the TaskManager, once the process appears I run the ProcessFinder() script to test it, but it returns "process not found" with the process still in TaskManager.  Using the manual test steps should work as well because the Process function is checking what is in the TaskManager.

 

//USEUNIT FindFolder
//USEUNIT ProcessFinder
function CheckPS()
{
var PatientID;
PatientID = "NoPatient";
//Clicks the 'linkMenupatient' link.
Aliases.browser.pageImagenet.linkMenupatient.Click();
//Waits until the browser loads the page and is ready to accept user input.
Aliases.browser.pageImagenet.Wait();
Project.Variables.TritonPatient1.Reset();
for(; !Project.Variables.TritonPatient1.IsEOF();)
{
//Clicks the 'textboxPatientid' object.
Aliases.browser.pageImagenet.textboxPatientid.Click(77, 5);
//Clicks the 'textboxPatientid' object.
Aliases.browser.pageImagenet.textboxPatientid.Click(56, 9);
Aliases.browser.pageImagenet.textboxPatientid.SetText(Project.Variables.TritonPatient1.Value("TritonPatient"));
Aliases.browser.pageImagenet.buttonAll.ClickButton();
Aliases.browser.pageImagenet.cell2.Click(66, 8);
//Clicks the 'panel' object.
Aliases.browser.pageImagenet.panel.Click(72, 75);
//Waits until the browser loads the page and is ready to accept user input.
Aliases.browser.pageImagenet.Wait();
if(Aliases.browser.pageExam.vgSvgslice0.Exists);
//Right Click BSCAN
Aliases.browser.pageImagenet.vgSvgslice0.ClickR(347, 138);
//Click PixelSmart option
Aliases.browser.pageImagenet.textnodeProcessingmovingaverage.Click(25, 13);
//Runs a script routine.
WaitForButton();

//Runs a script routine.

ProcessFinder();
//Checks whether the 'contentText' property of the NameMapping.Sys.browser.pageExam.panelResult.panel object equals 'PixelSmart
aqObject.CheckProperty(NameMapping.Sys.browser.pageExam.panelResult.panel, "contentText", cmpEqual, "PixelSmart\nClose\nON\n0");
//Runs a keyword test.
KeywordTests.FileProperty.Run();
//Delays the test execution for the specified time period.
Delay(2000);
//Runs a script routine.
FindFolder();
//Delays the test execution for the specified time period.
Delay(2000);
//Clicks the 'linkMenupatient' link.
Aliases.browser.pageImagenet.linkMenupatient.Click();
//Waits until the browser loads the page and is ready to accept user input.
Aliases.browser.pageImagenet.Wait();
Project.Variables.TritonPatient1.Next();
}
}

 

======================================

function ProcessFinder()
{
Sys.Process("octDataParser").Exists ?
Log.Message(Sys.Process("octDataParser").CommandLine) :
Log.Message("Process not found !");
}

AlexKaras
Community Hero

Re: Capturing the Command Line of a Process running in the Task Manager

Hi,

 

Just several generic notes:

 

it returns "process not found" with the process still in TaskManager.

Does TestComplete run using the same or higher privileges level when compared to those of octDataParser process?

For example, process can be invisible for TestComplete if it was started under your user's account while octDataParser process is spawned with privileges elevation.

Update: I noted that octDataParser_core process is started under System account as per screnshot of your Task Manager. Do you have the Show System Processes button enabled in Object Browser in TestComplete?

 

Sys.Process("octDataParser").Exists ?

This line of code assumes that octDataParser process already exists or appears within the Project | Playback > Runtime > Auto-wait Timeout time period.

Otherwise there will be 'process not found' error in test log.

One must use one of the WaitXXX() methods (WaitProcess() in your case) if it is not guaranteed that sought for object exists at the moment of code execution.

 

P.S. You wrote that octDataParser process exists for several seconds only... This makes me think that this part of your test can be fragile and not stable if, for example, octDataParser process completes within 1-2 seconds on a fast powerful box. Do you really need to grab command line for the spawned octDataParser process? Maybe you can use, say, some log generated by octDatParser, or wait for some time for some result of its work? (Say, processed data file.) Such modified approach will definitely make your test more stable.

 

P.P.S. Personally I would not use Task Manager but WMI if I need to search for the process and its properties. But only if functionality provided by TestComplete appears to be not enough.

E.g.:

https://www.computerperformance.co.uk/vbscript/wmi-process/

https://www.google.com/search?q=wmi+vbscript+get+process+command+line

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
tphillips
Community Leader

Re: Capturing the Command Line of a Process running in the Task Manager

Just for reference, you can use the "Insert/Edit code sample" button to insert code snippets, it makes it a lot easier to read blocks of code

tphillips_0-1611693979617.png

 


--------------------
QA Systems Architect
BenoitB
Community Hero

Re: Capturing the Command Line of a Process running in the Task Manager

As for me i've presupposed you have a standard Auto timeout of 5 or 10s.

But it's true that you must check your value.

And about rights and settings, it's a good point to check.

 

For info, the task explorer use was only to be sure of using the good process name, the finder doesn't need it.

 

I would try the following code (not tested):

 

 

WaitForButton();
let p = Sys.FindChildEx("Name", "octDataParser", 5, true, 15000);
p.Exists ? Log.Message("Process found, command line is : " + p.CommandLine) : Log.Error("Process not found");

 

 

And about putting it in a function i would write this :

 

 

function CommandLineProcessFinder(ProcessName = "", Depth = 5, TimeOut = 15000) {
  if (ProcessName == "") {
    Log.Error("Mandatory parameter 'ProcessName' is missing");
    return false;
  }
  let p = Sys.FindChildEx("Name", ProcessName, Depth, true, TimeOut);
  if (p.Exists) {
    Log.Message("Process '" + ProcessName + "' found, command line is : '" + p.CommandLine + "'");
    return true;
  }
  else {
    Log.Error("'" + ProcessName + "' not found");
    return false;
  }
}

 

Un sourire et ça repart

AlexKaras
Community Hero

Re: Capturing the Command Line of a Process running in the Task Manager

> WaitForButton();

And one more suspect...

What does this function do? Isn't it too late to look for the octDataParser process when the function returns?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
nedbacan
Contributor

Re: Capturing the Command Line of a Process running in the Task Manager

Does TestComplete run using the same or higher privileges level when compared to those of octDataParser process? I would not know how to answer this but as you mentioned octDataParser is running under System while TC is with user.

 

Do you have the Show System Processes button enabled in Object Browser in TestComplete?  Yes, the octDataParser process is not listed.

 

Sys.Process("octDataParser").Exists ?  I used Sys.Find("octDataParser", n); and Sys.Process("octDataParser"); and no luck.

 

Do you really need to grab the command line for the spawned octDataParser process?  A requirement indicates when this process is run there will be certain command lines for certain images opened to give you a quick idea, I thought catching the process from TaskManager will be a quicker way to get the answer, but seems not for what I want to do. 

 

Currently working on getting a log file created for this process so that TestComplete can read the log and report it in the test log.

 

Thank you all for your support. 

 

New Here?
Join us and watch the welcome video:
Top Kudoed Authors