cancel
Showing results for 
Search instead for 
Did you mean: 

Brrowser mode connecting to wrong chrome window

johwes
Level 4
Hi,

In the process I am currently working on I open one web based application from another web based application, ending up with two separate chrome windows. In the second application I am able to spy using UIA mode, but when trying to use browser mode it only connects to the first application. I attach to the second application using the window title, I have also tried detaching from the first application before attaching to the second, but the result is still the same.  
Win32, UIA and Region mode all connect to the correct application/window, but browser mode only connects to the wrong window. Any ideas?

Blue Prism version 6.10.1.

Regards,

------------------------------
Johanna Westlund
RPA developer
SpareBank 1 Østfold Akershus
/Norway
------------------------------
11 REPLIES 11

VedSengupta
Level 6
Hello Johanna,
One way to work around this is create a separate object to interact with different windows.
You can treat the two windows as two objects and attach separately ( Taking into consideration some unique identifier is already present. For Ex : window title)

------------------------------
------------------------------
Best Regards,
Ved Sengupta
RPA Developer
Deloitte India (Offices of the US)
Bangalore | INDIA
*If you find this post helpful mark it as best answer*
------------------------------
------------------------------
------------------------------ Best Regards, Ved Sengupta RPA Developer Deloitte India (Offices of the US) Bangalore | INDIA *If you find this post helpful mark it as best answer* ------------------------------

Hello Ved,
I already have two different objects since it's two different applications (even though they both run in chrome and I open one from the other). Both have different window titles. I have also tried with child index 0 and 1. I have tried to detach from the first before attaching to the second as well but browser mode still connects to the first. Very annoying :(.

------------------------------
Johanna Westlund
RPA developer
SpareBank 1 Østfold Akershus
/Norway
------------------------------

I think I have found the cause of the problem, both windows have the same PID:

26122.png
Is there any way to use the handle to attach? I can't find that option in the navigate stage for attach....

------------------------------
Johanna Westlund
RPA developer
SpareBank 1 Østfold Akershus
/Norway
------------------------------

Hi Johanna,

I was reading your post and just about to suggest that you attach using the PID. What you show there in your collection screenshot doesn't seem possible. Is that a collection you're creating, or are you using the "Read Memory Stats" canned action to retrieve the data?  Process ID is a unique Windows/Linux identifier - I don't think you can have 2 different running processes with the same PID.

All that said,  I've had similar issues in the past and my "always worked so far" fix has been this:
Within my object, create a page called Attach via PID
Create the following stages-
Read attached
If attached, wait/check for an element that should be in the window you need. If not attached, skip next line and go right to Call Read Memory Stats action
If found, you're done. if not found, detach
Call Read Memory Stats in the Environment Utility for the Chrome process
Check that there is more than one row in the resulting collection - the last row will always be PID 0, idle process and not applicable.
Loop through the resulting collection, attaching using the PID and Process Name as my inputs
After attaching, check for an element that should be in the window you need. If found, you're done. If not found, detach and then go back through the loop.
If you encounter PID = 0, skip it because your resulting wait stage will bomb.
If you get to the end of the loop, either your window isn't there or your wait stage needs to be reconfigured

I hope this makes sense. I'd upload an image or xml of my object page but that functionality is blocked by my institution so I can't upload to the portal.

Something else I've noticed while developing in Chrome.  If the only way I can spy an element is using UIA, chances are I'm attached to the wrong instance of Chrome and as soon as I run the process through control room the whole thing will fail.  It's good to do during setup so I can properly add my check/wait stages in my Attach via PID page, but then I have to go back and re-spy in browser mode.  I should also note that I've tried surface automation (region mode) and it, too, will fail if you're attached to the wrong PID.  I think you experienced that, too, and described it above.

I hope this helps. If anything is unclear, please respond and I'll do my best to explain better.

Good luck!


------------------------------
Diane Sanzone
------------------------------

Hi Diane,

In the most recent version of Blue Prisms "Utility General" version you get an action called "Get Windows" which provides the output I posted above. 

26125.png
Very useful action, but very annoying that I get the same PID for both windows...! I guess your "always worked so far" fix will not work in this case with two identical PID's?


------------------------------
Johanna Westlund
RPA developer
SpareBank 1 Østfold Akershus
/Norway
------------------------------

Yikes. I'm quite confused because you shouldn't have two processes with the same PID. What happens when you check task manager directly?  If you manually kill the process that is the PID retrieved with that call, do both windows close, or only one?  Also, is the Environment Utility no longer available in the newest version?  I wonder if the other action would produce different results?

------------------------------
Diane Sanzone
------------------------------

It keeps getting better... Task manager shows a number of chrome processes (extensions and what not), but only one with the PID retrieved by "Get Windows", 9108 :

26130.png

26131.png
Ending the task with PID 9108 closes both chrome windows. 

I am trying to get PIDs with Read Memory Stats but keep getting this error even though the collection with process names has a column called Process and so does the collection for the results. 

26132.png
Ideas?



------------------------------
Johanna Westlund
RPA developer
SpareBank 1 Østfold Akershus
/Norway
------------------------------

YES! I had very similar issues the first time I tried to use this action because the documentation is unclear.  You need to pre-define your collections like this:
One collection called Process Names with fields Process Name and PID. Initial value for process name = chrome, initial value for PID is blank
second collection called Process Statistics with fields Process Name, PID, Working Set, and Virtual Memory. no rows/initial values for this collection.
Your Process Names collection is the input to the Get Memory Stats action, your Process Statistics collection is the output.

See if that helps.

Also, bummer about closing the PID and both windows. That boggles my mind.

------------------------------
Diane Sanzone
------------------------------

I found the problem, I had named my field "Process name" instead of "Process Name". Trust BP to be a stickler for details :-P. 

So I ran both Get Windows and Get Memory Stats and this is the result:

26141.png
As you can see Get Memory Stats finds the same PIDs as in task manager
26142.png
This is very mind boggling indeed.

------------------------------
Johanna Westlund
RPA developer
SpareBank 1 Østfold Akershus
/Norway
------------------------------