none
Cannot run Coded UI tests as different user on Windows 8.1

    Question

  • We have a Coded UI test suite which depends on running our tests as different users.  We accomplish this by using the following ApplicationUnderTest.Launch overload:

    ApplicationUnderTest.Launch(browserLocation, null, url, username, GetSecurePassword(password), domain);

    We use Visual Studio 2013 premium (update 3) and had no problem when running on Windows 7 and Windows 2012 R2.  Now we have migrated to Windows 8.1 and we are no longer able to run as a different user.  We get the following infamous error:

    "The application cannot be started. This could be due to one of the following reasons:
    1) Another instance of the application is already running and only one instance can be running at a time.
    2) The application started another process and has now stopped. You may need to launch the process directly.
    3) You do not have sufficient privileges for this application." File: C:\Program Files\Internet Explorer\iexplore.exe."

    We are able to run Coded UI tests successfully when we run as the current user like so:

    ApplicationUnderTest.Launch(browserLocation, null, url);

    Unfortunately doing this does not allow us to exercise our tests.  We are running Visual Studio as Administrators and all the test users we run as are set up as Administrators themselves.  Do you have any idea of what the problem might be?

    This is the stack trace I experience:


       at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.ThrowIfProcessNotValid(Process process)
       at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.SetCurrentProcessPrivate(Process value)
       at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.<>c__DisplayClassb.<set_Process>b__a()
       at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
       at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.set_Process(Process value)
       at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.Start(ProcessStartInfo startInfo)
       at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.<>c__DisplayClass10.<.ctor>b__e()
       at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
       at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest..ctor(String fileName, String alternateFileName, String arguments, String userName, SecureString password, String domain)
       at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.<>c__DisplayClass4.<Launch>b__3()
       at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
       at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.Launch(String fileName, String alternateFileName, String arguments, String userName, SecureString password, String domain)
       at Pantheon.Web.AppsPortal.UITests.Utilities.TestBase.LaunchBrowserWindow(String browserLocation, String url, String username, String password, String domain) in c:\dev_jr\AppsPortal\Development\Pantheon.Web.AppsPortal.UITests\Utilities\TestBase.cs:line 122

    TestBase.cs:line 122 looks like this:   

    var app = ApplicationUnderTest.Launch(browserLocation, null, url, username, GetSecurePassword(password), domain);


    Wednesday, August 13, 2014 9:38 AM

Answers

All replies

  • Hi,

    Please log on this Windows 8.1 machine with a different user and then launch iexplore.exe from C:\Program Files\Internet Explorer to check whether you can launch IE successfully. If you can’t, then you can’t do it in Coded UI test.

    If you can, please provide us detailed parameters in ApplicationUnderTest.Launch method such as browserLocation and GetSecurePassword(password). It would be better if you can provide us detailed code about GetSecurePassword method or a sample test project so that we can repro your issue completely on our side.

    If you have another Windows 8.1 machine, you can run your test project there to check whether the same issue will occur.

    In addition, which version of IE did you work with?

    Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 14, 2014 8:15 AM
    Moderator
  • Hi,

    I tested I could run as a different user by running this at the command line:

    runas /user:pantheon\TestUser1 "C:\Program Files\Internet Explorer\iexplore.exe"

    This worked just fine and fired up IE as TestUser1. (I assume that this covers the same ground as logging in as TestUser1 and firing up IE - let me know if that is not the case.)

    I've built a new Windows 8.1 machine over the last day and can confirm that the exact same error is occurring on the new machine.

    ApplicationUnderTest.Launch looks like this:

    ApplicationUnderTest.Launch(browserLocation, null, url, username, GetSecurePassword(password), domain);

    browserLocation: C:\Program Files\Internet Explorer\iexplore.exe
    url: http://localhost:53033/ (This is the location of the root of our application - I can confirm that the app is running and accessible when attempting to run Coded UI tests)
    username: TestUser1
    domain: Pantheon

    The password is created using this method which just encrypts a string and returns the secure equivalent:

            private static SecureString GetSecurePassword(string password)        {            var securePassword = new SecureString();            var plainPassword = password.ToCharArray();            foreach (var c in plainPassword)            {                securePassword.AppendChar(c);            }            return securePassword;        }

    These Coded UI tests are working successfully on my colleagues machine running Windows 7 and IE 9.  I am running on Windows 8.1 using IE 11 (64 bit)

    Friday, August 15, 2014 10:34 AM
  • One extra thing I've tried is starting up another instance of IE as the test user like this:

    runas /user:pantheon\TestUser1 "C:\Program Files\Internet Explorer\iexplore.exe"

    and leaving that instance of IE running whilst a run a Coded UI test that wants to run as TestUser1.  In these circumstances Coded UI can successfully launch as follows:

               

    ApplicationUnderTest.Launch(browserLocation, null, url, username, GetSecurePassword(password), domain);

    However, on the next line it chokes:

    varbrowser = BrowserWindow.Locate("Portfolio Monitoring - Welcome to Portfolio Monitoring System");

    The error / stack trace looks like this in these circumstances:

    Test Name: UI_AboutPageView
    Test FullName: Pantheon.Web.AppsPortal.UITests.TestCases._001_Home.About.AboutPage.UI_AboutPageView
    Test Source: c:\Source\AppsPortal\Development\Pantheon.Web.AppsPortal.UITests\TestCases\_001_Home\About\AboutPage.cs : line 42
    Test Outcome: Failed
    Test Duration: 0:00:20.8710233

    Result Message: 
    Test method Pantheon.Web.AppsPortal.UITests.TestCases._001_Home.About.AboutPage.UI_AboutPageView threw exception:
    Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException: You do not have sufficient privileges to access the information about this control or the control is part of the recorder process. Additional Details:
    TechnologyName:  'MSAA'
    Name:  'Portfolio Monitoring - Welcome to Portfolio Monitoring System - Internet Explorer'
    ClassName:  'IEFrame'
    ControlType:  'Window'
     ---> Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException: You do not have sufficient privileges to access the information about this control or the control is part of the recorder process.
    TestCleanup method Pantheon.Web.AppsPortal.UITests.TestCases._001_Home.About.AboutPage.TestCleanup threw exception. System.Security.SecurityException: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  To create the source, you need permission to read all event logs to make sure that the new source name is unique.  Inaccessible logs: Security..
    Result StackTrace: 
    at Microsoft.VisualStudio.TestTools.UITest.Framework.UITestService.ThrowIfHigherPrivilegeProcess(IntPtr handle)
       at Microsoft.VisualStudio.TestTools.UITest.Framework.UITestService.GetElementFromWindowHandle(IntPtr handle)
       at Microsoft.VisualStudio.TestTools.UITesting.IEBrowserService.UpdateWebBrowserReference()
       at Microsoft.VisualStudio.TestTools.UITesting.IEBrowserService.<>c__DisplayClass5.<Locate>b__4()
       at Microsoft.VisualStudio.TestTools.UITesting.ALUtility.PerformRetryOperation(RetryOperation operation, Int32 timeout)
       at Microsoft.VisualStudio.TestTools.UITesting.IEBrowserService.Locate(IntPtr handle)
       at Microsoft.VisualStudio.TestTools.UITesting.IEBrowserFactory.Locate(IntPtr handle)
       at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindow..ctor(UITestControl control)
       at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindowPropertyProvider.GetPropertyValue(UITestControl uiTestControl, String propertyName)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestPropertyProvider.GetPropertyValueWrapper(UITestControl uiControl, String propertyName)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyValuePrivate(String propertyName)
     --- End of inner exception stack trace ---
        at Microsoft.VisualStudio.TestTools.UITesting.Playback.AddUITestControlDescriptionToException(Exception exception, IPlaybackContext context)
       at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, IPlaybackContext context)
       at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, String actionName, UITestControl uiControl)
       at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, String actionName, Object parameterValue, UITestControl uiControl)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyValuePrivate(String propertyName)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyPrivate(String propertyName)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyOfType[T](String propertyName)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.get_WindowHandle()
       at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetElement(Boolean useCache, ISearchArgument searchArg)
       at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.Search(ISearchArgument searchArg)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindInternal()
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.<Find>b__37()
       at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.Find()
       at Microsoft.VisualStudio.TestTools.UITesting.IEBrowserService.Locate(PropertyExpressionCollection searchProperties, PropertyExpressionCollection filterProperties, Boolean findAll)
       at Microsoft.VisualStudio.TestTools.UITesting.IEBrowserFactory.Locate(PropertyExpressionCollection searchProperties, PropertyExpressionCollection filterProperties)
       at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.SearchTopLevelWindow(ISearchArgument topLevelSearchArg, String topLevelElementQueryId)
       at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetTitleUpdatedTopLevelWindow(ISearchArgument topLevelSearchArg, String queryId, IList`1 windowTitles)
       at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetTopLevelElement(Boolean useCache, Boolean useCacheOnly, ISearchArgument searchArg, IList`1 windowTitles, Int32& timeLeft)
       at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetElement(Boolean useCache, ISearchArgument searchArg)
       at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.Search(ISearchArgument searchArg)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindInternal()
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.<Find>b__37()
       at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.Find()
       at Microsoft.VisualStudio.TestTools.UITesting.ApplicationUnderTest.Find()
       at Microsoft.VisualStudio.TestTools.UITesting.BrowserWindow.Locate(String title)
       at Pantheon.Web.AppsPortal.UITests.Utilities.TestBase.LaunchBrowserWindow(String browserLocation, String url, String username, String password, String domain) in c:\Source\AppsPortal\Development\Pantheon.Web.AppsPortal.UITests\Utilities\TestBase.cs:line 124
       at Pantheon.Web.AppsPortal.UITests.Utilities.CDVInputterBase.get_UserOneBrowser() in c:\Source\AppsPortal\Development\Pantheon.Web.AppsPortal.UITests\Utilities\CDVInputterBase.cs:line 14
       at Pantheon.Web.AppsPortal.UITests.TestCases._001_Home.About.AboutPage.BrowseToAboutPage() in c:\Source\AppsPortal\Development\Pantheon.Web.AppsPortal.UITests\TestCases\_001_Home\About\AboutPage.cs:line 32
       at Pantheon.Web.AppsPortal.UITests.TestCases._001_Home.About.AboutPage.Setup() in c:\Source\AppsPortal\Development\Pantheon.Web.AppsPortal.UITests\TestCases\_001_Home\About\AboutPage.cs:line 27
       at Pantheon.Web.AppsPortal.UITests.TestCases._001_Home.About.AboutPage.UI_AboutPageView() in c:\Source\AppsPortal\Development\Pantheon.Web.AppsPortal.UITests\TestCases\_001_Home\About\AboutPage.cs:line 43

    TestCleanup Stack Trace
        at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate)
       at System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate)
       at System.Diagnostics.EventLogInternal.VerifyAndCreateSource(String sourceName, String currentMachineName)
       at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
       at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
       at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type)
       at Pantheon.Web.AppsPortal.UITests.Utilities.TestBase.TestCleanup() in c:\Source\AppsPortal\Development\Pantheon.Web.AppsPortal.UITests\Utilities\TestBase.cs:line 64

    Friday, August 15, 2014 10:38 AM
  • Hi Johnny,

    Thank you for your information.

    I found your scenario below can work fine on Windows 8.1 machine with VS2013 Update 2 and IE 11, but it will fail with the error message in your original post after I upgrade VS2013 to VS2013 Update 3 on Windows 8.1 machine.

    ApplicationUnderTest.Launch("C:\\Program Files\\Internet Explorer\\iexplore.exe", null, "http://www.bing.com", "another username instead of my own user", GetSecurePassword("the password"), "the domain");

    I suggest you to use VS2013 Update 2 instead of VS2013 Update 3 in order to continue testing your application, and then submit this feedback to Microsoft Connect feedback portal: http://connect.microsoft.com/VisualStudio/feedback/CreateFeedback.aspx, Microsoft product team will evaluate them seriously.

    After you submit the feedback, you can post the link here which will be beneficial for other members with the similar issue.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, August 18, 2014 6:35 AM
    Moderator
  • Hi,

    Unfortunately Visual Studio 2013 Update 2 (Premium version) appears to have been removed from MSDN and so I cannot test Coded UI with Update 2.  Do you know where I could find a copy?

    By the way, it's not the first time that a Visual Studio update has broken Coded UI (this happened last year with Visual Studio 2012 Update 2 or 3 I think). Bit frustrating!

    Best,

    John

    Monday, August 18, 2014 8:22 AM
  • Since I'm unable to test Update 2 I've just logged the issue here:

    https://connect.microsoft.com/VisualStudio/feedbackdetail/view/949049/coded-ui-cannot-run-as-a-different-user-with-visual-studio-2013-update-3

    Thanks for your help Crystal - I hope a patch will soon be shipped to resolve this.

    Monday, August 18, 2014 8:33 AM
  • Hi John,

    I also don’t find an official download link for VS2013 Update 2, in order to resolve this issue I also submitted this feedback to Microsoft product team(before it, I did not notice your reply:)):

    https://connect.microsoft.com/VisualStudio/feedbackdetail/view/949052/vs2013-update-3-coded-ui-test-cant-launch-ie-under-a-different-user-on-windows-8-1-machine-with-ie11

    You can vote it and add your comments in that connect.

    Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, August 18, 2014 8:39 AM
    Moderator
  • Hi John,

    And since we got that this issue is about Visual Studio Updates product and it was reported to Microsoft product team, then it is in their support range, Microsoft engineer will provide support for you better. I will close this thread through marking your reply as a temporary ‘answer’ on the forum side, which will be beneficial for other members when they use forums. Meanwhile I will continue to follow the Microsoft Connect. Once an answer is provided, I will help to post in this thread.

    Thank you very much for your understanding.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, August 19, 2014 1:42 AM
    Moderator