Best way to handle Azure login using TestComplete
Our new web app has Azure login. I was able to create fake test logins(email and password) and they do work.
I was also able to create a login script which is working when running non-headless:
function Login() {
Browsers.Item(Project.Variables.browser).Navigate(Project.Variables.releasebuild);
let browser = Aliases.browser;
let emailForm = browser.pageSignInToYourAccount.formF1;
let selectAccount = emailForm.imageImages;
let passwordForm = browser.pageFsUpsComAdfsLsClientRequestI.formLoginform;
Delay(2000);
selectAccount.Click();
emailForm.emailinputEmployeeNumberUpsCom.SetText(Project.Variables.User1);
emailForm.submitbuttonNext.Click();
//Bypass additional screen if present
bypassAccountTypeSelection();
passwordForm.passwordboxPasswordinput.SetText(Project.Variables.User1PW);
passwordForm.textnodeSubmitbutton.Click();
//Refresh page
Delay(1000);
refreshPage();
}
This seems like a somewhat fragile implementation though. The bypassAccountTypeSelection() function is needed because sometimes there is an additional screen that requires a click.
The main issue is running headless does not work at all. In looking at the logs, I am seeing screens that I do not see when logging in manually or running non-headless.
I feel there must be a better way to handle logging in to a web app that has Azure auth. I don't think disabling it is a viable option unfortunately. Previous web apps I have worked with have had a much simpler login flow and there was no issue headless or non-headless. This is my first time working with Azure login stuff.
I was able to get this to work headless.
Basically, my initial script was created with an Edge profile (me) so the login form I got when running manually/non-headless was different when the browser is launched headless.
I signed out of my profile, captured the right objects, updated my script and was able to run the login script headless.