Coded UI Test - Logon on Azure Active Directory with MFA enabled RRS feed

  • Question

  • Hi,

    I'm having Visual Studio Enterprise 2019 and I want to try with Coded UI Test.
    I'm not sure how or if it's possible to have Coded UI Test on our Web Applications which some are still on WebForm and .NET MVC. However we are stuck at the first step, logon screen.
    Our applications are secured using Azure Active Directory and for all logon it requires the user to enter 2FA (be it Microsoft authenticator, Phone Call, or SMS). 

    Is there a way the Coded UI Test support this?
    Any suggestion on next step?
    If possible we don't want to disable MFA or create MFA exception on some accounts (like backdoor).


    :: Simple Is Everything, Nothing Is Complex ::

    Thursday, July 30, 2020 2:36 AM

All replies

  • Hi Freddy,

    You can try to add and use the method for example Playback.Wait(XXXX) to let Code UI Test(CUIT) wait for the verification to succeed and continue to test the next UI control.

    Actually, automating test 2FA isn’t recommended and it’s a challenge. There are some limitations and security issues, for example, one of the authentications needs to use a pop-up Windows Store Application, but the general CUIT project template is suitable for testing Web, Windows Presentation Foundation or other applications except Universal Windows Platform(UWP) application. To test(sign in) the web application, you need to first pass the authentication from this pop-up Windows Store Application. So you need the CUIT project template for UWP, but you can’t use one template to test(perform actions) both Web and UWP applications.

    Besides, please note, Coded UI Test for automated UI-driven functional testing is deprecated. Visual Studio 2019 is the late version where Code UI Test will be available. We recommend using Selenium for testing web apps.

    In addition, for Selenium, if you check this document: Two Factor Authentication, you can find these suggestions: Automating this seamlessly and consistently is a big challenge in Selenium. There are some ways to automate this process. But that will be another layer on top of our Selenium tests and not secured as well. So, you can avoid automating 2FA.

    Hope this helps a little and feel free to contact me.

    Kind Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 31, 2020 6:56 AM