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

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

Related

How to effectively run .net core unit test with selenium, from published web app

I have a .NET Core v2.2 application. I am trying to start Selenium UI tests, built on top of unit testing project (tried using NUnit, xUnit).
The tests can be started locally from VS(using TestExplorer), or from started locally .NET Core 2.2 app.
The goal is to be able to start test, once the app is deployed in IIS, using button in a view.
I've tried both starting the test using reflection, and instantiating the class, or starting it as process (by running nunit3-console.exe, dotnet test or vstest.console.exe) in command line.
When using
dotnet test {PathToTestDll} --filter "Name ~{testName}" --logger trx --results-directory {resultDir}
command, I can start the test from cmd, but when trying to open the published site, I get error for missing dll
Could not load file or assembly 'Microsoft.VisualStudio.Coverage.CoreLib.Net, Version=16.9.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.), which is part of VS Enterprise, I am currently using VS Professional 2019 Version 16.9.1.
If I try and use
nunit3-console.exe --test={testFullyQualifiedName} {PathToTestDll}
I get another error for missing nunit.framework package:
NUnit.Engine.NUnitEngineException : An exception occurred in the driver while loading tests.
System.IO.FileNotFoundException : Could not load file or assembly 'nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' or one of its dependencies. The system cannot find the file specified.
--NUnitEngineException
An exception occurred in the driver while loading tests.) regardless if I execute it in the dir, where the nunit.framework file is located (C:\Users{user}.nuget\packages\nunit{version}), or the published project's dir (somewhere in C:\inetpub\wwwroot{projectName}).
Now when using reflection, after the app is published, the test fail, with the same error (javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite. (Session info: chrome=88.0.4324.190)), which is a Selenium error, for using not unique way to locate element, if I am not mistaken. For each test. I've checked them and can assure you, it is not the case.
By this time, I have accepted that I am doing something, or everything wrong, but cannot pin-point what.
I have to say, that I currently use NUnit3, chromedriver v88.0.4324.96, Selenium.WebDriver 3.141.0

Visual Studio 2019 crash doing literally anything conntected to Windows Forms Designer Package (?)

I wanted to get VS Community 2019 after using 2017 for some time because i still had it.
Uninstalled VS2017 and installed VS2019
Now, i have done this today and tried reinstalling 2 times now.
My issue is: When i open VS2019 everything is normal. It is showing me all the options you have in the splashscreen, i can click on "Continue without code" without a problem. But if i try to open a .sln file, the Import Export Settings, create a new Project or open options the program crashes without a message, sometimes i get one. It is telling me:
The "Windows forms designer package" packe did not load correctly... (pointing me to an xml for logs)
I open the Activity Monitor Log and at place 643, ERROR:
CreateInstance failed for package [Windows Forms Designer
Package]Source: 'mscorlib' Description: Exception has been thrown by
the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.TypeLoadException: Could
not load type 'System.Drawing.Design.ToolboxService' from assembly
'System.Drawing.Design, Version=4.0.0.0, Culture=neutral
And so on..
GUID: {7494682B-37A0-11D2-A273-00C04F8EF4FF}
HR: 80004005 - E_FAIL
Source: VisualStudio
I can't really figure out how to fix this, any tips or ideas are appreciated.
Thank you in advance, even if it doesn'T work. Trying is everything!
I updated windows until there were no more updates and rebooted my pc a couple of times, now it works.

System.Diagnostics.Process.Start causes error "No application is associated with the specified file for this operation" when deployed

I am new to c# and have created a web form using ASP.NET 4.7.2 and Visual Studio 2019. One of my buttons links to a url using:
System.Diagnostics.Process.Start("www.google.com", "_blank");
However, when I debug my app locally, it works fine. Once I deploy the app and click on the same button, this error shows up:
Exception Details: System.ComponentModel.Win32Exception: No application is associated with the specified file for this operation
This points directly at the line where I make the call to System.Diagnostics.Process.Start.
What am I doing wrong?

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

Watin integration test failing with System.UnauthorizedAccessException when executing javascript

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

Categories

Resources