Forum Discussion

jamesc12's avatar
jamesc12
Champion Level 0
3 months ago
Solved

Opening browser from BeforeFeature hook causes 'Unable to find the object Sys.Browser("*")' error

Hi all,

I have 2 feature files, with multiple scenarios inside them. I am opening the browser using the following function below:

function OpenBrowser() {
Log.AppendFolder("Open browser for the test.") ;
Browsers.Item(btChrome).RunOptions = "--no-first-run";
Browsers.Item(btChrome).Run();
Sys.Browser().BrowserWindow(0).Maximize();
}

I'm calling this function from a BeforeFeature hook, on a remote Windows machine. It seems to cause a 'Unable to find the object Sys.Browser("*")' error for each test. In the video recorded for each, it just seems Chrome doesn't open. However, if I call this function from a BeforeScenario hook, it runs fine.

The above problem doesn't seem to happen when I run the test on my local machine. Do you know why this is happening only on the remote machine? 

Thanks! 

  • Hi all,

    Just to follow up on this, I found out why this was a problem.

    In the Azure Devops Pipeline, the TestCompleteAdapter does NOT support BeforeFeature and AfterFeature hooks. Confirmed by Smartbear themselves. 

    Thanks again and hope this helps someone else that bumps into this issue.

15 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Does this work for you?

    BeforeFeature(function (feature){
      Browsers.Item(btChrome).Run();
      Sys.Browser().BrowserWindow(0).Maximize();
    })
    • jamesc12's avatar
      jamesc12
      Champion Level 0

      Thanks for the reply. Tried this, and I still get the exact same error for each test.

      • rraghvani's avatar
        rraghvani
        Champion Level 3

        I'm using TC v15.61 and this is what I get,

         

  • jamesc12's avatar
    jamesc12
    Champion Level 0

    Hi all,

    Just to follow up on this, I found out why this was a problem.

    In the Azure Devops Pipeline, the TestCompleteAdapter does NOT support BeforeFeature and AfterFeature hooks. Confirmed by Smartbear themselves. 

    Thanks again and hope this helps someone else that bumps into this issue.