Having problems restarting Edge process after killing the process

Ask general questions here.
User avatar
Aracknid
Posts: 371
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Having problems restarting Edge process after killing the process

Post by Aracknid » Tue Mar 17, 2020 2:40 pm

Hi,

I was wondering if anyone has run into this or something similar. Using Ranorex 9.3 on Windows 10.

As part of my process of running an automated script, I first check if there are any browsers running, and if so I kill their processes. For the new Edge, I look for 'msedge', and if found kill it.

The first time I run a script, on a system that has been rebooted, my script runs fine, likely because there are no 'msedge' processes running yet. The general process is as follows:

(Note: scripts are created in visual studio, using the Ranorex API, but this really has nothing to do with Ranorex as this code is all straight forward vb.NET)

1) Pre-cleanup: Look for and kill any process that is of 'msedge'

2) Start the process 'msedge' using the code System.Diagnostics.Process.Start("msedge", "about:blank")

3) Do the steps of the automated script

4) The script passes and the Edge browser is gracefully closed by signing out, or the script fails and the browser remains open

5) Post-cleanup: Look for and kill any process that is of 'msedge' (regardless of pass or fail in step 4). Note even if it gracefully closes the browser, there are still many msedge processes running in the task manager, so all these are killed.

The second time I run my script and get to my second step, OR if I manually try to start the process by double-clicking the icon, it will not start.

I don't have this problem with any other browser (Chrome, FireFox or IE) using the same code.

Any suggestions? Is there any other process running that I should also kill? I notice that when Edge starts, it starts many msedge processes, and all these are killed by my scripts. Any Edge settings?

Thanks for any help,

Aracknid

User avatar
Aracknid
Posts: 371
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Having problems restarting Edge process after killing the process

Post by Aracknid » Tue Mar 17, 2020 3:38 pm

Sorry, 2 clarifications...

1) I'm of course talking about the new Edge browser, powered by Chromium. Not the old original Edge browser.

2) It looks like I can in fact start it by double-clicking the icon on the desktop. Just cannot start it by using the code Process.Start.

Aracknid.

User avatar
Vega
Certified Professional
Certified Professional
Posts: 222
Joined: Mon Jul 11, 2016 2:15 pm

Re: Having problems restarting Edge process after killing the process

Post by Vega » Wed Mar 18, 2020 12:36 am

Hi,

Just wondering if you notice any difference if you use Ranorex API to open the browser

Code: Select all

Host.Current.OpenBrowser("http://www.ranorex.com", "Edge", "", false, false, false, false, false, true);
hope this helps

User avatar
Aracknid
Posts: 371
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Having problems restarting Edge process after killing the process

Post by Aracknid » Wed Mar 18, 2020 5:49 pm

Yes, your suggestion to use the Ranorex OpenBrowser does in fact work (as far as I can tell from the few tests I've done). So for now I'll use this, as I need to test this new browser. Thanks for this suggestion.

Still though, I wonder why the way I'm doing it doesn't work for new Edge...?

Aracknid

User avatar
Vega
Certified Professional
Certified Professional
Posts: 222
Joined: Mon Jul 11, 2016 2:15 pm

Re: Having problems restarting Edge process after killing the process

Post by Vega » Wed Mar 18, 2020 9:44 pm

Not sure since I stick to Ranorex API for launching browsers because there are many useful flags on the Ranorex openbrowser call, but I did find this post from stack overflow regarding the .NET process.start method:

https://stackoverflow.com/questions/396 ... p-winforms

Code: Select all

The ":" at the end is inportant, otherwise won't work

To open in blank:

System.Diagnostics.Process.Start("microsoft-edge:");
or specifying an address:

System.Diagnostics.Process.Start("microsoft-edge:http://www.google.com");
hope this helps

User avatar
Aracknid
Posts: 371
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Having problems restarting Edge process after killing the process

Post by Aracknid » Wed Mar 18, 2020 10:11 pm

Actually, that info is for the old Edge browser. But thanks anyway.