0

I am writing a test method to launch a window application.

Below is my code

 namespace UnitTestProject1
    {
        [TestClass]
        public class UnitTest1
        {
            [TestMethod]
            public void TestMethod1()
            {      
                ProcessStartInfo P = new ProcessStartInfo("C:\\Windows\\System32\\notepad.exe");
                Application app = Application.Launch(P);      
            }
        }
    }

After running this test a Notepad window opens up and then below exception is thrown

System.MissingMethodException: Method not found: 'System.Windows.Rect System.Windows.Automation.Provider.IRawElementProviderFragment.get_BoundingRectangle()

Satwik163
  • 1
  • 1

1 Answers1

0

I don't know what namespace Application belongs but it's probably the wrong one and you are aiming for the class Process. Below is the code you need to perform this task with the method .Run().

using System.Diagnostics;

namespace UnitTestProject1
        {
            [TestClass]
            public class UnitTest1
            {
                [TestMethod]
                public void TestMethod1()
                {      
                    ProcessStartInfo P = new ProcessStartInfo("C:\\Windows\\System32\\notepad.exe");
                    Process.Start(P);      
                }
            }
        }
ojonasplima
  • 411
  • 2
  • 12