Ranorex.Host.Local.OpenBrowser throws Win32Exception

Bug reports.
chris125
Posts: 1
Joined: Thu Oct 05, 2017 1:33 pm

Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by chris125 » Thu Oct 05, 2017 1:46 pm

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?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by odklizec » Mon Oct 09, 2017 8:30 am

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by odklizec » Mon Oct 09, 2017 2:18 pm

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by krstcs » Mon Oct 09, 2017 4:27 pm

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.
Shortcuts usually aren't...

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by odklizec » Mon Oct 09, 2017 4:41 pm

I'm using 7.2, but I saw this "Access is denied" error even in 6.x.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by Support Team » Tue Oct 10, 2017 12:48 pm

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ž

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by odklizec » Tue Oct 10, 2017 2:04 pm

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.
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

scrushmaster
Posts: 13
Joined: Thu Dec 08, 2016 1:46 am

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by scrushmaster » Tue Oct 10, 2017 8:31 pm

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-".

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by krstcs » Tue Oct 10, 2017 8:49 pm

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.
Shortcuts usually aren't...

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by odklizec » Wed Oct 11, 2017 7:31 am

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by Support Team » Fri Oct 13, 2017 1:03 pm

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ž
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by odklizec » Fri Oct 13, 2017 1:11 pm

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex.Host.Local.OpenBrowser throws Win32Exception

Post by odklizec » Mon Oct 23, 2017 9:08 am

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).
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration