ExecuteScript() throws 'Accesss is deniend' exception

Class library usage, coding and language questions.
elena.ungureanu
Posts: 19
Joined: Mon Jan 05, 2015 5:46 pm

ExecuteScript() throws 'Accesss is deniend' exception

Post by elena.ungureanu » Tue Jan 06, 2015 1:45 pm

Hi,

I am using Ranorex V5.2.1 for our automated testing. I have some methods that are executing some javascript code using the Ranorex method ExecuteScript(). Everything works fine when I'm running the tests (including the execute javascript methods) on my local machine on IE, but I get 'UnauthorizedAccessException: Access is denied' error thrown for the execute javascript methods when tests are running in IE on a VM.

Here is the entire error message:
Ranorex.ActionFailedException: Action 'executescript' failed on element '{WebDocument:<webpage-title>}'. ---> System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at mshtml.IHTMLWindow2.execScript(String code, String language)
at Ranorex.Plugin.WebFlavor.ExecuteUserScript(String code, IHTMLDocument2 rootDoc)
at Ranorex.Plugin.WebDocumentFlavorElement.InvokeAction(Element element, String name, Object[] args)
at Ranorex.Core.Element.InvokeAction(String name, Object[] args)
--- End of inner exception stack trace ---
at Ranorex.Core.Element.InvokeAction(String name, Object[] args)
at Ranorex.WebDocument.ExecuteScript(String code)
VM details: Windows 7 SP1 64bits, IE11

Here is a code sample to see how ExecuteScript() method is being used

Code: Select all

String javascriptCode = "return jQuery(':animated').length";

String active = dom.ExecuteScript(javascriptCode);
int activeCount = int.Parse(active);

if (activeCount == 0)
{
//some message being saved
return;
}
Details about the machines were the ExecuteScript() method works without throwing exceptions: Windows 7 SP1 64bits, IE10 and IE11.

I hope you could give some information where the problem could be.

Thank you,
Elena

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: ExecuteScript() throws 'Accesss is deniend' exception

Post by Support Team » Thu Jan 08, 2015 1:55 pm

Hi Elena,

This seems to be related to permissions or security on your VM.
Could it be that the IE's protected mode is enabled on the VM? If so, please turn it off.
Have you also tried to run the Ranorex test exe as administrator?
Is a firewall or antivirus software installed on the machine?

Regards,
Markus
.
Image

elena.ungureanu
Posts: 19
Joined: Mon Jan 05, 2015 5:46 pm

Re: ExecuteScript() throws 'Accesss is deniend' exception

Post by elena.ungureanu » Tue Jan 13, 2015 9:47 pm

Hi Markus,

Thank you for your reply.

I've rechecked the IE settings and the 'Enable Enhanced Protected Mode' option is not ticked (Internet Options\Advanced tab\Security node).
The tests are running as an administrator and there is no antivirus or firewall installed.

Unfortunately I cannot reproduce it locally so I thought it might be worth asking thinking that maybe someone else had the same problem.

Regards,
Elena

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: ExecuteScript() throws 'Accesss is deniend' exception

Post by Support Team » Wed Jan 14, 2015 1:38 pm

Hi Elena,

What you can also try is to add the Url under test to the list of Trusted Sites (Tools --> Internet Options --> Security --> Trusted sites, click on "Sites" button and add Url) and to set the Security level for the trusted sites for test purposes to the lowest level.
Please let me know if this worked.

Regards,
Markus
.
Image

elena.ungureanu
Posts: 19
Joined: Mon Jan 05, 2015 5:46 pm

Re: ExecuteScript() throws 'Accesss is deniend' exception

Post by elena.ungureanu » Sat Jan 31, 2015 10:20 pm

Hi Markus,

I've registered the website Url under Trusted sites but I get the same 'Access denied' message. Also the security level is set to minimum.

For the moment Chrome is used to run the tests on the VM, but I really want to get to the bottom of the IE issue.

Kind regards,
Elena

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: ExecuteScript() throws 'Accesss is deniend' exception

Post by Support Team » Tue Feb 03, 2015 5:20 pm

Hi Elena,

Please contact [email protected] to discuss this issue in detail via email.
It may be necessary to schedule a remote session to be able to solve this issue on your machine.

Regards,
Markus
.
Image