Page 1 of 1

Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Thu Oct 05, 2017 1:46 pm
by chris125
Using Ranorex 7.1 on Windows 7 and 10:
Calling Ranorex.Host.Local.OpenBrowser with the browsername being 'ie' and killExisting set to true, it sometimes throws a Win32Exception (as an inner exception of RanorexException) with the exception message 'Access is denied'. This seems to be purely sporadic and not specific to a certain test. The issue seems to be with the Browser killing because when splitting the method into Host.Local.KillBrowser and Host.Local.OpenBrowser, the KillBrowser method throws the Win32Exception directly
Any ideas?

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Mon Oct 09, 2017 8:30 am
by odklizec
Hi,

I'm experiencing a very similar problem with "Access is Denied" but in my case, it happens only with Chrome. I haven't thought that killExisting could be the source of issue! I will disable it in our tests and give it a shot.

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Mon Oct 09, 2017 2:18 pm
by odklizec
I can confirm that the KillExisting parameter is indeed a cause of "Access is Denied" error occasionally thrown by OpenBrowser action. In our case, it's almost exclusively reproducible with Chrome browser. Error is no longer reproducible after disabling this parameter.

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Mon Oct 09, 2017 4:27 pm
by krstcs
Which version of Ranorex are you guys using? Please be more specific than "7.1" as there are 3 versions of 7.1 (.0, .1, & .2).

When listing the Ranorex version, please give the FULL version number.

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Mon Oct 09, 2017 4:41 pm
by odklizec
I'm using 7.2, but I saw this "Access is denied" error even in 6.x.

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Tue Oct 10, 2017 12:48 pm
by Support Team
Hello everyone,

I am aware of a similar issue in Chrome.
Can you let me know what your exact error message is? We have seen the following message in the past:

Code: Select all

Host.Local.OpenBrowser("https://www.google.com/","chrome","",True,True,True,False,True) //Clear Cache = True;
Error message: "Failed to open URL 'https://www.google.com/' with browser chrome. Access to the path 'data_0' is denied."
To the customer that has reported this issue before we have suggested creating a new Chrome profile because this has resolved the issue when we have replicated it. Unfortunately, we have not heard back from that customer.

Can let me know if the issue is indeed the same and if it can be resolved by creating a new Chrome profile?

Sincerely,
Tomaž

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Tue Oct 10, 2017 2:04 pm
by odklizec
In my case, the error message looks like this:
Failed to open URL 'http://10.22.10.61' with browser Chrome.
Access is denied
AccessIsDenied.png
I will try to create a new chrome profile and let you know if it helped or not.

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Tue Oct 10, 2017 8:31 pm
by scrushmaster
I used to get this alot for a variety of reasons (mainly chrome staying open, bugging out staying open, etc...).

The way I solve it is:
1. Before openbrowser(), close all dom object that are chrome, i run a loop to ensure they are closed sometimes they don't close the first try. Something like this in a try catch:
DomObject = repo.DomToClose.BasePath.ToString();
IList<Ranorex.WebDocument> MyWebDocuments = DomObject.Find<Ranorex.WebDocument>(repo.DomToClose.BasePath.ToString());

foreach (Ranorex.WebDocument BrowserWindowsToClose in MyWebDocuments)
{
BrowserWindowsToClose.Close();
}
2. Make sure you always open chrome with the following argument "--disable-web-security --user-data-".

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Tue Oct 10, 2017 8:49 pm
by krstcs
I'll add my 2 cents...

I almost always run web tests in Incognito mode. This means that nothing is saved from the session to the user profile. I also set the Ranorex browser plugin to be allowed in Incognito, or it wouldn't work... :D

I haven't seen the issues that you guys are talking about.

My guess would be that Ranorex is doing something that is causing the browser to mess up the profile...

Edit to add: Ranorex 7.1.2, but I didn't see it in 7.0.X or 6.X either, for what it's worth.

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Wed Oct 11, 2017 7:31 am
by odklizec
OK, I've tried the "new profile" trick but this did not help. Some of our night tests again failed with "Access is denied" error. Once the KillExisting is disabled, the same tests passes OK.

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Fri Oct 13, 2017 1:03 pm
by Support Team
Hello everyone,

I have invested some time into this issue.
I can confirm that the error appears only when there is no delay between closing the browser at the end of your test case and reopening it again with the KillExisting attribute set to true.

For me the issue only happens when I am looping tests in Chrome.
By adding a delay of 5 seconds at the end of your test case (before the OpenBrowser is called again) the issue should be resolved. Could you try that?

Furthermore, I have tried to set the KillExisiting attribute to false and instead using the method System.Diagnostics.Process.Kill in the following way:
public void Recording1_Open_Browser()
		{
			Report.Log(ReportLevel.Info, "Website", "Opening web site 'http://www.ranorex.com' with browser 'Chrome' in normal mode.");
			
			Process [] chromeInstances = Process.GetProcessesByName("chrome");
			foreach(Process p in chromeInstances)
				try
			{
				p.Kill();
			}
			catch (Exception e)
			{
				Report.Error(e.Message);
			}
					
			
			Host.Current.OpenBrowser("http://www.ranorex.com", "Chrome", "", false, false, false, false, false);
		}
The exception "Access denied" is now raised by the Kill method. The report looks like this:
Report.png
Therefore, this seems to be a timing issue. The process that you are trying to kill is already gone before it can be killed.

Please try to implement the delay in your solutions and let me know if it helps. If you are running the tests on a VM, then maybe a higher delay could be needed, try 10 seconds.
I hope this helps.

Sincerely,
Tomaž

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Fri Oct 13, 2017 1:11 pm
by odklizec
Hi Tomaz,

Thanks for the feedback. Your finding is consistent with my experience, where one test runs OK and the next one fails with "Access is denied" exception. We are going to add the delay and re-enable KillExisting in our tests. I should have some result for at Monday. Thanks.

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Posted: Mon Oct 23, 2017 9:08 am
by odklizec
Hi guys,

I forgot to update this post. Adding 5s delay definitely helps with "Access is denied" problem in Chrome (while using kill existing option).