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,
Tianyu
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.