Watin integration test failing with System.UnauthorizedAccessException when executing javascript - c#

Our team got into work in the morning and we found that all of our Watin (2.1.0) tests were failing on our integration server with the following exception. The tests also no longer work locally against (IE8 or IE9)
WatiN.Core.Exceptions.RunScriptException : RunScript failed
----> System.UnauthorizedAccessException : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Note, that this error message is occuring when a list box jquery change event is being fired:
self.$country.bind('change', function (e) {
var country = $('option:selected', this);
if(country.val() == "??")
{
self.$country.val('US');
}
We are at a complete loss as:
We have tried reverting all code changes prior to test failure and they errors do not appear to be related
These tests have been running successfully for several months
No windows updates have been applied to the server
Network permissions have not been changed
Any insight into this error or suggestions would be greatly appreciated.

For references, we fixed this issue by adding the test site to the IE's trusted sites list and it has resolved the error message. Similar issue is here for reference: stackoverflow.com/questions/3986477/…

I have also run into this problem a lot of times, but in my case it occurred only when the element that was being manipulated was disabled.
Are you facing this problem even when you are running the test in DEBUG mode or is it only when you are running it as part of the suite with a test runner.
You might want to run the test in Visual Studio with the debugger attached and check the properties of the element that is being manipulated in the Quick Watch window. The exact line where the exception is thrown will be available in the Stack Trace where you are getting this exception.
Regards,
Ashish Narmen

Related

ODP.Net new OracleConnection "Value cannot be null Parameter Name: path"

I have a project using ODP.Net version 12.2.1100. This project was working fine until opening today. The following line of code is causing the error:
using (var cn = new OracleConnection("User Name={userID}, etc, etc"))
The error being returned is:
Value cannot be null.
Parameter name: path
Inner exception
at System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(String[] str, Boolean onlyCheckExtras)
Things I have tried so far to resolve the issue:
Changed connection string from EZ Connect to full Oracle string
Uninstalled and resintalled Oracle.ManagedDataAccess.dll (through NuGet)
Ensured all config files were up to date
Created a new simple test console project (which connected fine)
I had the same issue. It occurred also with the Managed Data Provider and it happens with the first Oracle class that gets instantiated, e.g. OracleParameter. But it only happens in the debugger of a unit test or in other cases where Assembly.GetEntryAssembly() returns null.
The call stack of the error gave me a hint: It calls System.Web.HttpRuntime.AppDomainAppPath. This throws the exception. By looking at the Oracle code I found a try-catch around it that should catch the exception but for some reason that sometimes fails.
In another project I get the same exception but this time it gets caught before it hits my code. Strange.
The following work around works for me:
try
{
new OracleDependency();
}
catch
{
}
This triggers the static constructor of ConfigBaseClass and ignores the error. It is sufficient to call this once in your code, e.g. also in a static constructor. I used OracleDependency as it doesn't require a Dispose as most other Oracle classes.
So next on my list was checking in my project and asking a colleague to open it to determine if the problem travelled with the code. He was able to execute successfully. I deleted my working copy and pulled it down from TFS, everything started working again. I suspect that something was corrupt in the bin directory.
I got this error in my integration test project. After deleting the bin folder and rebuilding, the error disappeared.

Program fails to start; Event Viewer logs ConfigurationsErrorException

Issue: On my development machine, everything works fine. However, when I copy the executable to the server, my program doesn't start
What I've done so far: I checked the event viewer and the error stack looks like this:
Application: Project.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Configuration.ConfigurationErrorsException
Stack:
at System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(System.String)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String)
at System.Configuration.ConfigurationManager.GetSection(System.String)
at System.Configuration.ConfigurationManager.get_ConnectionStrings()
at Project.BaseService..ctor()
at Project.Service..ctor()
at Project.Program.Main()
I checked online and, most of the times, this error is generated by some misplacement of configSections on the .config files. To make sure this was not the case, I let both app.config and .exe.config files clean (only the section was there), but my program still didn't work.
Then, I generated a dump file from the failing process and here is where things get strange: the exception that is thrown when I'm calling ConfigurationManager.ConnectionStrings is "Configuration System failed to initialize", with a "The 'add' start tag on line 257 position 6 does not match the end tag of 'connectionManagement'. Line 258, position 3." inner exception. I double-checked my entire project and there is not a single reference to "connectionManagement" anywhere! I even tried to check AppDomain.CurrentDomain.SetupInformation.ConfigurationFile's value and it indicates the right config file.
By fixing this connectionManagement issue I'll probably be able to run my application, but do you guys have any idea about where this might be coming from?
Problem was on the machine.config file on the server. Changing it solved the problem!

"The handle is invalid" exception in Visual Studio 2015 test runner

I found that one of my tests that passes in VS2013 is failing in VS2015, the test calls a service that includes among other things a call to Console.Clear();
to find out whats going on I made a simple unit test
[TestMethod]
public void ExampleTest()
{
Console.Clear();
}
This test passes in visual studio 2013 but in 2015 I get the following error:
Test Name: ExampleTest
Test FullName: solution.Common.Test.CacheManagerTest.ExampleTest
Test Source: C:\solution.Common.Test\CacheManagerTest.cs : line 34
Test Outcome: Failed
Test Duration: 0:00:00.3015003
Result StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode,
String maybeFullPath) at System.Console.GetBufferInfo(Boolean
throwOnNoConsole, Boolean& succeeded) at System.Console.Clear()
at sol.Common.Test.CacheManagerTest.ExampleTest() in
C:\solution.Common.Test\CacheManagerTest.cs:line 35 Result Message:
Test method Alexandria.Common.Test.CacheManagerTest.ExampleTest threw
exception: System.IO.IOException: The handle is invalid.
I do understand that it is bad design for my service to fail if it is not called by a console. The reason I am asking this question is to understand why this is failing in the new version of Visual Studio. Is this the intended behavior? What changed?
I did not see anything obvious in the change log that would seem related to this.
Edit: I am calling the Console.clear from the following dll
Microsoft\Framework.NETFramework\v4.5.1\mscorlib.dll
Edit 2:
picture of testproject properties in both visual studios
The changes in VS2015 are pretty visible, use the Test > Debug > All Tests to get insight. You can see that it now has a new test host process, its name is TE.ProcessHost.Managed.exe, stored in the C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow directory.
Previous versions of VS used a different host, vstest.executionengine.exe. One notable change in the new test host is that it is no longer a console mode program. Something you can see by running Dumpbin.exe /headers on the exe.
Another way to see the underlying problem is with Task Manager. Note how running a test in an older VS version causes a conhost.exe process to get added. This is the process that owns the console window for a console mode app. A problem I've seen before is that this process tends to leak, not terminating when the test completes. Adding ever more conhost.exe instances, at one point researching this problem I had 12 of them running. Presumably the changes in VS2015 were meant to address that problem.
Technically you can configure the unit test with a .runsettings file and use the <ForcedLegacyMode> element to force the old test host process to be used. This however has no effect on the outcome of this test, looks like they addressed this in multiple ways.
That's a fair amount of guessing, I recommend you use connect.microsoft.com to file a feedback report. You can quote this Q+A for reference.
Meanwhile, you can consider a workaround. Do note that Console.Clear() is in general a trouble-maker, it will also fail in normal usage when the output of a console mode app is redirected. Very easy to do from a command line prompt with the > operator. Which is the ultimate reason it fails in a unit test. You'll want to make the code resilient so it can work properly both in production and in a unit test. Like this:
if (!Console.IsOutputRedirected) Console.Clear();
Which requires targeting .NET 4.5 or higher. You can use the code in this SO post if you need to target earlier versions.

Unexpected error launching Internet Explorer. IELaunchURL() returned 800700C1

Every time I launch Selenium WebDriver on one of my test servers, I'm receiving the following error from the SDK:
System.InvalidOperationException: System.InvalidOperationException:
Unexpected error launching Internet Explorer. IELaunchURL() returned
800700C1 for URL 'http://localhost:5555/' (NoSuchDriver).
The rest of my test servers are not having any trouble. Also, I verified that all of the internet zones were set to protected.
Delete the "C:\Program" file from your system
Answer from https://code.google.com/p/selenium/issues/detail?id=6181
It seems a bit odd, but when I checked, there was a 0 byte "Program" file in the root of the C drive. I deleted the file and the issue went away.

Running Coded UI tests with Resharper/NUnit will not locate Silverlight components

I'm using Visual Studio 2010 Premium Edition. I've recorded tests with Coded UI, on a Silverlight application within a browser.
When I run the tests using test runner they pass.
When I run them using NUnit, they open the browser and navigate on an HTML site properly, but once the test reaches the Silverlight application it fails to locate the elements.
Does anyone have any ideas?
This is the error message:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException : The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'Silverlight'
ControlType: 'MainPageView'
----> System.Runtime.InteropServices.COMException : Error HRESULT E_FAIL has been returned from a call to a COM component.
See the Answer on this post
http://social.msdn.microsoft.com/Forums/en-US/vsautotest/thread/ef77627b-6802-44e3-928e-434f1901e152

Categories

Resources