Forum Discussion

nastester's avatar
nastester
Regular Contributor
15 days ago
Solved

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. 

6 Replies

  • nastester's avatar
    nastester
    Regular Contributor

    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. 

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    See Login Object, and take note of "TestComplete may not be able to access the Login dialog displayed in Internet Explorer when you attempt to access protected resources that belong to a domain other than the domain to which the web page, which is currently open in the browser, belongs. To work around this problem, navigate to a web page (which does not require user authentication) belonging to an appropriate domain before accessing protected resources."

    • nastester's avatar
      nastester
      Regular Contributor

      I'm not using IE but this seems to be for "when the user attempts to access a web application that uses Basic authentication".   I don't like the Azure login flow is considered basic auth

      • rraghvani's avatar
        rraghvani
        Champion Level 3

        I can't find the actual topic on the documentation, and I was hoping that the link that I had provided would give a hint! However, anything other than basic authentication will not work. TC is not able to identify any objects on a secured page.

         

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    What screens are you seeing with the headless version? Show us screenshots please.