RobVious
RobVious

Reputation: 12915

CodedUI tests failing due to missing assembly reference?

I have a coded UI test built with VS2010 for TFS2010 running on machine A. I have a test agent installed on machine A that the tests run on successfully. My testsettings file>Roles is set to RemoteExecution because these codedUI tests ALWAYS need to be run on machine A. The file always says "connected to the controller" that I specified.

I check the code into the build server (machine B), and it fails. With copy local set to false on the codedUI assemblies, the build fails with an error:

"Not runnable: Failed to initialize the unit test extension 'urn:CodedUITest': A unit test extension is not registered for the following attribute: Microsoft.VisualStudio.TestTools.UITesting.CodedUITestAttribute."

In the application logs on machine B, I get this:

(QTAgent32.exe, PID 5308, Thread 8) GetCollectorType: Failed to get type for Collector 'Microsoft.VisualStudio.TestTools.DataCollection.SystemInfo.SystemInfoDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.SystemInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a': System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.DataCollection.SystemInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.VisualStudio.TestTools.DataCollection.SystemInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) at System.Type.GetType(String typeName, Boolean throwOnError) at Microsoft.VisualStudio.TestTools.DataCollection.ExecutionPluginManager.GetCollectorType(String collectorTypeName, Exception& loadException)

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

And in the Administration console I get this:

Following error encountered while reading sqm registry entry: TF255003: The installation path cannot be found for the following feature: ApplicationTier. Either the feature is not installed, or you must use a different installation path.

With copy local set to true on the coded UI assemblies, I don't get any error in the Build Explorer in VS, but the build fails and says 0/0 tests run. In the application log on machine B, I get:

The description for Event ID 0 from source VSTTExecution cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:

(MSTest.exe, PID 5544, Thread 1) Exception thrown when enumerating assembly: Microsoft.VisualStudio.TestTools.Exceptions.EqtDataException: Unable to load the test container 'C:\Builds\1\Project\Binaries\Microsoft.VisualStudio.QualityTools.CodedUITestFramework.dll' or one of its dependencies. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.Vsip, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

at Microsoft.VisualStudio.TestTools.TestTypes.Unit.AssemblyEnumerator.EnumerateAssembly(IWarningHandler warningHandler, String location, ProjectData projectData, ObjectHandle assemblyResolverWrapper) at Microsoft.VisualStudio.TestTools.TestTypes.Unit.AssemblyEnumerator.EnumerateAssembly(IWarningHandler warningHandler, String location, ProjectData projectData, ObjectHandle assemblyResolverWrapper) at Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAttributeEnumerator.Read(ITestTypeExtensionClientSidesProvider provider, IWarningHandler warningHandler, String assemblyFileName, ProjectData projectData, TestRunConfiguration testRunConfiguration)

Machine B does have VS2010 express installed.

What else do I need to do to get this building on Machine B (build machine), but tests running on Machine A (with the test agent)? What else can I do to diagnose this?

UPDATE: I tried manually copying the qualitytools.vsip dll into the project and referencing it that way with copy local set to true, but now I'm back to getting

"Failed to initialize the unit test extension 'urn:CodedUITest': A unit test extension is not registered for the following attribute: Microsoft.VisualStudio.TestTools.UITesting.CodedUITestAttribute."

Upvotes: 1

Views: 6111

Answers (3)

anonymous
anonymous

Reputation: 1

    Solution 1:  Replace the name as that seen in pop UP. Might be this code can help clicking it

    WinWindow pop = new WinWindow(null);
                pop.SearchProperties.Add("Name", "Message from webpage", "ClassName", "#32770");

    ‘Windows Internet Explorer
                pop.TechnologyName = "MSAA";
                pop.DrawHighlight();

//------------
“Usinng MSTEST.exe to generate result”

C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE>MSTest /testcontainer:
D:\Practise\CodedUITestProject1\CodedUITestProject1\CodedUITestProject1\bin\Debu
g\CodedUITestProject1.dll /test:CodedUITestMethod1 /resultsfile:D:\SachintestRes
.trx


 public void CodedUITestMethod1()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            string testcase = " /testcontainer:" + "D:\\Practise\\CodedUITestProject1\\CodedUITestProject1\\CodedUITestProject1\\bin\\Debug\\CodedUITestProject1.dll /test:CodedUITestMethod1 /resultsfile:D:\\SachintestResAut.trx";

            string Path = @"C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\MSTest";

            Process myProcess = new Process();
            ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(Path, testcase);
            myProcessStartInfo.UseShellExecute = false;
            try
            {
                myProcess.StartInfo = myProcessStartInfo;
                myProcess.Start();
                myProcess.BeginOutputReadLine();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }

                WinText text = new WinText(pop);

                text.SearchProperties.Add("Name", "Some Name");
                String msg = text.GetProperty("DisplayText").ToString();

                if (msg.Contains("Data saved."))
                {
                    Console.WriteLine("System is displaying " + msg);
                }
                else
                {
                    Console.WriteLine("System is displaying " + msg);
                }

                WinButton ok = new WinButton(pop);
                ok.TechnologyName = "MSAA";
                ok.SearchProperties.Add("Name", "OK");
                Mouse.Click(ok);

    Solution 2: Try the Browser Dialog Actions like OK,Cancel,Close .May be it can be helpful. PFB snapshot below.

    try
                {
                    BrowserWindow browserWindow = new BrowserWindow();
                    browserWindow.PerformDialogAction(BrowserDialogAction.Ok);
                }
                catch (Exception)
                {
                    // If a popup does not exists and an error is thrown, continue...
                    Playback.PlaybackSettings.ContinueOnError = true;
                }

//C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE>MSTest /testcontainer: D:\Practise\CodedUITestProject1\CodedUITestProject1\CodedUITestProject1\bin\Debu g\CodedUITestProject1.dll /test:CodedUITestMethod1 /resultsfile:D:\SachintestRes .trx

 public void CodedUITestMethod1()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            string testcase = " /testcontainer:" + "D:\\Practise\\CodedUITestProject1\\CodedUITestProject1\\CodedUITestProject1\\bin\\Debug\\CodedUITestProject1.dll /test:CodedUITestMethod1 /resultsfile:D:\\SachintestResAut.trx";

            string Path = @"C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\MSTest";

            Process myProcess = new Process();
            ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(Path, testcase);
            myProcessStartInfo.UseShellExecute = false;
            try
            {
                myProcess.StartInfo = myProcessStartInfo;
                myProcess.Start();
                myProcess.BeginOutputReadLine();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }

Upvotes: 0

anonymous
anonymous

Reputation: 1

using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodedUITestProject1.Libraries
{
    class generic
    {
        public static BrowserWindow mParentWindow { get; set; }
        public static BrowserWindow ParentWindow
        {
            get
            {
                if(mParentWindow==null)
                { mParentWindow = TopParentWindow(); }
                return mParentWindow;
            }
        }

        public static BrowserWindow TopParentWindow()
        {
            BrowserWindow window = new BrowserWindow();
            window.SearchProperties[UITestControl.PropertyNames.ClassName]=BrowserWindow.CurrentBrowser.ToString();
            return window;
        }


        public enum PropertyType
        { Id,
          Name,
          ClassName,
          InnerText,
          TagInstance
        }

        public static void EnterText<T>(PropertyType type,string propvalue,string text) where T:HtmlControl
        {
            HtmlControl genericControl = (T)Activator.CreateInstance(typeof(T), new object[] { ParentWindow });
            if (type==PropertyType.Id)
            {
                genericControl.SearchProperties[HtmlControl.PropertyNames.Id] = propvalue;

            }

            else if (type == PropertyType.Id)
            {
                genericControl.SearchProperties[HtmlControl.PropertyNames.Id] = propvalue;

            }
            Keyboard.SendKeys(genericControl, text);
        }

        public static void ClickLink<T>(PropertyType type, string propvalue) where T : HtmlControl
        {
            HtmlControl genericControl = (T)Activator.CreateInstance(typeof(T), new object[] { ParentWindow });
            if (type == PropertyType.Id)
            {
                genericControl.SearchProperties[HtmlControl.PropertyNames.Id] = propvalue;

            }

            else if (type == PropertyType.Id)
            {
                genericControl.SearchProperties[HtmlControl.PropertyNames.Id] = propvalue;

            }
            //Assert.IsTrue(genericControl.WaitForControlExist(40000));
            Mouse.Click(genericControl);

        }

         public static Boolean ExistLink<T>(PropertyType type, string propvalue) where T : HtmlControl
        {
            HtmlControl genericControl = (T)Activator.CreateInstance(typeof(T), new object[] { ParentWindow });
            if (type == PropertyType.Id)
            {
                genericControl.SearchProperties[HtmlControl.PropertyNames.Id] = propvalue;

            }

            else if (type == PropertyType.Id)
            {
                genericControl.SearchProperties[HtmlControl.PropertyNames.Id] = propvalue;

            }
            try
            {
                Assert.IsTrue(genericControl.WaitForControlExist(4000));
                return true;

            }
            catch (Exception e)
            {
                return false;
            }
            //Mouse.Click(genericControl);

        }

    }
}

Upvotes: 0

Bose_geek
Bose_geek

Reputation: 498

Kindly make a check the project property that the target framework is not set to .NET framework 4 client profile. Instead set to .Net framework 4 (without client profile)

Upvotes: 2

Related Questions