I have a solution with some automation tests. Each test calls a Logon() method, which logs a test user in via azure AD, and then each test visits a different page and checks it works.
The Logon method does the following:
Go to the URL of the site
Microsoft login box appears
Enter username of the user, press enter
Enter the password of the user, press enter
Microsoft says do you want to set up 2fa (the test user is within the grace period, couldn't figure out how to get past 2fa otherwise)
Press the ask later button
Microsoft says do you want to stay logged in?
Click 'yes', click OK (doesn't matter afaik since every test is completely separate and there are no cookies etc)
Homepage of the site loads with the user logged in.
This works fine locally, and it works sometimes within azure. It runs as part of the PR, I create a PR, which triggers a build agent, which runs the tests.
Generally, 4 of the 6 tests will pass. Not always the same 4.
Getting information out is very hard, so I added some code to take a screenshot of the window and dump it encoded into the exception. When I decode it, this is what I see:
The problem is that sometimes the test passes, and sometimes it errors and produces this. I can't understand why the access would be intermittent. When this error occurs, it doesn't affect all the tests, as I say, just 1-2 of them seemingly at random and they all run together.
Any ideas that might point me in the right direction?