Looping IE Browser and Close and delete cookies

Hi All,

Can any one please help/advise/guide me on below process to automate

1. Extract all Window Title Name into collection for all open IE Browsers
2. Look for specific Title Name if that found then click on sign out / logout if that element is available on screen or else close the IE
3. Like wise loop through all open IE Browsers and check if its Last open browser then clear the cookies and close the IE Browser
4. End
 
and when we open browser right that time sometime will get restore session button down right side. this also how we can restore IE browser session using blue prism
 

VJR

Well-Known Member
1. Extract all Window Title Name into collection for all open IE Browsers
2. Look for specific Title Name if that found then click on sign out / logout if that element is available on screen or else close the IE
Hi naveedraza,

At first I recommend to go through the entire instructions and decide upon if you would like to go with this approach.
i. Make a duplicate copy of the 'Read Memory Stats' of Utility - Environment VBO.
Name it something like 'Get Stats with Window title'

Object Diagram:
View attachment 1533970596141.png

ii. Two new lines of code are added as shown below where you see the comment as 'THIS LINE


Code:
GC.Collect()
Process_Statistics = New DataTable
process_statistics.Columns.Add("Process Name", GetType(String))
process_statistics.Columns.Add("PID", GetType(Decimal))
process_statistics.Columns.Add("Working Set", GetType(Decimal))
process_statistics.Columns.Add("Virtual Memory", GetType(Decimal))
process_statistics.Columns.Add("Window Title", GetType(String)) 'THIS LINE

For Each R As DataRow in Processes.Rows
    dim ProcName As String = CStr(R("Process Name"))
    Dim PID As Integer = CInt(R("PID"))
    For Each P As Process in Process.GetProcesses()
        If P.ProcessName = ProcName OrElse P.ID = PID Then
            Process_Statistics.Rows.Add(New Object() {P.ProcessName, P.ID, P.WorkingSet64, P.VirtualMemorySize64, P.MainWindowTitle}) 'Window title parameter in THIS LINE
        End If
    Next
Next

iii. Add a new Field for the Window Title in the Output Collection.

View attachment 1533970548779.png

You can remove the other parameters (eg; PID, Working Set, Virtual Memory) if you would like from the above output collection and also remove its related line of code from the above Code stage.

iv. In the Input collection, pass the required process name from the Process to the Object eg; iexplore in this case.

View attachment 1533970748044.png

v. I have 2 IE windows open on my machine viz; google.com and yahoo.com
On running this new object it shows the output as below.

View attachment 1533971784286.png

An "issue" here is even though there are 2 IE windows open, there is only 1 instance of iexplore.exe opened in the Task Manager and that is why only 1 Window Title (Yahoo) is pulled in the above output collection.
This is a known thing for processes that have multiple child processes running under the same instance. I believe this happens with Winword.exe too. Meaning - no matter how may IE windows you open it will show up only under 1 iexplore.exe process and hence returns only 1 window title.

You can even run a dos command as below...
tasklist /fi "IMAGENAME eq iexplore.exe" /v >c:\titles.txt

...and find the same output in the c:\titles.txt file.
Notice the PIDs and the window titles are same as the above output collection

View attachment 1533971709537.png

The iexplore.exe *32 is maintained by the browser for a different reason and you can ignore them.

View attachment 1533970978286.png


vi. But the good news is this Process Statistics output collection keeps on showing each window title at a time.
For eg; I have now closed the Yahoo IE window and have run the process/object again.
This time it removed Yahoo and shows the other open window title ie; Google
View attachment 1533972128476.png

Now all IE windows are closed and no iexplore processes are present in the output collection.
View attachment 1533972181014.png

The point here is since you are going to work on 1 IE window at a time, you can access each window title from this collection -> Attach to this window -> look for the Log out element -> if not found close the window -> rerun this new object -> get the next window title from the collection -> continue the same as above

...and stop this when there are no more iexplore entries in the collection.
If a logout element is found then click on it to logout and you can then kill all iexplore processes using the Kill Process action since I believe you do not want to do anything with the IE window once the logout is done.

Looking for the Log out element:
Go to the page which has the Log out element. It could be a button or a hyperlink. Spy and Create an element in the Application Modeller for the Log out.
After attaching to a window use the dynamic wait stage's Check Exists action to check whether the element exists on that page or not. Your webpage is already loaded so you can give a short wait time and if it timesout then it means the element is not found and take the next step accordingly.
Alternatively as soon as you attach a window you can directly click on the button. If the click throws an error similar to "no matching element found for the supplied query terms" then it means the element is not found on that page.


Once you are done with all of this then go for clearing the cache which I will suggest you with some options at a later stage when the above works fine.
 
Top