Connecting to a pid rather than to a process
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Connecting to a pid rather than to a process
Previously I was using TC 12 and C#
Connect.Sys["Process"]("java", 900000);
rootNode = driver.WaitProcess("java");
to connect to my Java process I start up. But lately there have been multiple instances of Java. For instance when this tries to run on the Jenkins machine, there is a Jenkins java process.
I am using C# so I was able to get the PID of the Java Process (integer) to which I would like to connect.
But I am not sure how to do this. I tried
Connect.Sys["Pid"](javapid, 90000);
where javapid is the pid, but it gave me an unknown name error. So does anyone have any suggestions?
And please don't tell me to use TestLeft.
(
driver.waitProcess(processName) just does a
return Connect.Sys["WaitProcess"](processName, timeout);
)
Thanks
Solved! Go to Solution.
- Labels:
-
Keyword Tests
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure to understand the need but perhaps this do your job ?
function GetMyPID(ProcessName, ProcessId) { var p = Sys.FindChild("ProcessName", ProcessName); var result = -1; while (p.Exists) { if (p.Id == ProcessId) { result = p.Id; break; }
p = Sys.FindChild("ProcessName", ProcessName); } return result; }
Un sourire et ça repart
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@BenoitB Suggestion will work with one change. Replace "FindChild" with "FindAllChildren". FindChild will return only one process... and only the "top" one in the list. So, use "FindAllChildren" and loop through the array of found processes until the process object found has the same PID as the one you're looking for, then break.
See documentation on FindAllChildren
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
True, but i can affirm it will work as i've written, use it since a loong time.. (To terminate processs still executing with a certain PID).
Lot of the underneath Window API manage themself the picking of next sibling when they are called in loop.
Un sourire et ça repart
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Man, it's been like half a year since I asked 😉 I figured out some other way but now I do not remember.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@bistritapcv
Perhaps, once you find the solution, you could post it and mark it solved? That would avoid "resurrection" of dead topics like this. 🙂
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks everyone for participation
Since this got ressurected I'll go ahead and mark BenoitB's answer as a solution for future reference.
Sonya Mihaljova
Community and Education Specialist
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like that may do it
