Forum Discussion

nattanmaia's avatar
nattanmaia
New Contributor
3 days ago

Issues Encountered with Headless Browser

Issues with Headless Browser

We are in the process of converting some existing tests to run headlessly.  I have gone through Creating and Running Web Tests in Headless Web Browsers With TestComplete.  The browser

 

We are in the process of converting some existing tests to run headlessly.  I have gone through Creating and Running Web Tests in Headless Web Browsers With TestComplete and currently am using Edge (Microsoft Edge Version 142.0.3595.94 (Official build) (64-bit)) and TestComplete (Version: 15.79.5.7 x64) 

 

Our website launches multiple windows, currently when running in non-headless mode the tests are able to get close the windows that are not needed, but when headless mode runs, it keeps the windows causing confusion between the multiple windows.

 

if (headless == "true") {

var children = browser.FindAllChildren("ObjectType", "BrowserWindow", 10);

for (var i = 0; i < children.length; i++) {

var win = children[i];

win.Activate();

      browser.Wait(4000);

      if(NameMapping.Sys.browser.UCLSearchPage.textboxCaseApp.Exists){

        Log.Message("Found Case App text field in MIUCL page");

      } else {

        Log.Message("Unable to find Case App text field on MIUCL page");

      }

var title = win.WndCaption;

if (title.indexOf("UCL") !== -1) {

Log.Message("Window contains: " + title);

win.Close();

//break;

This is one of my methods for looking at the windows and is not working in headless browsers.  Sometimes it will go through and run and complete some of the functions but most of the time I receive an error that an object is not available.  Can anyone provide some insight?

 

Also, I have noticed that the checkpoints seem to be failing and returns an error:

The property checkpoint failed, because contentText does not contain the substring (case-sensitive) "Register Program - Program Details". See Details for additional information. 12:05:07              Normal                                          31.78

 

 

@skoski191

5 Replies

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    Your coding is correct,

    function BrowserTest()
    {
        var browser = Sys.Browser("chrome").FindAllChildren("ObjectType", "BrowserWindow", 1);
            
        for (var i = 0; i < browser.length; i++) {
            browser[i].Activate();
            
            /* This could be an issue*/
            if (NameMapping.Sys.browser.UCLSearchPage.textboxCaseApp.Exists) {
                Log.Message("Found Case App text field in MIUCL page");
            } else {
                Log.Message("Unable to find Case App text field on MIUCL page");
            }
        
            if (browser[i].WndCaption.indexOf("W3Schools") !== -1) {
                Log.Message("Closing Browser Window " + browser[i].WndCaption);
                browser[i].Close();
            }
        }
    }

    However, the main issue could be relating to the Name Mapping that you are using in the middle of the code. You are referencing browser.UCLSearchPage.textboxCaseApp, but what properties have you defined for the parent browser?