Forum Discussion

sriguda's avatar
sriguda
Frequent Contributor
10 years ago

Getting Browser is already running error while initiating next script in the sequence.

Hi,

I have few scripts and trying to run them as project suite. All my scripts end with logging off application and closing browser. But looks like the browser session is still running in the back ground. So after running 1st script, getting error that browser is already running and cannot open another session so it stops running.

 

I have set auto timeout of 2 mins for run browser statement in the following scripts. That didn't work. Any other solution to this?

  • You may want to check at the end of the test if the browser process exists? If yes, then terminate.

     

    Check Sys.Process("BrowserProcessName").Exists and Sys.Process("BrowserProcessName").Terminate

    • sriguda's avatar
      sriguda
      Frequent Contributor

      Can I put this statement in Keyword test r it has to be in script routine.

      • Lage's avatar
        Lage
        Contributor

        You must put the statement that amarr1143l wrote before in a script. But you can call this script from a keywordTest using the Operation "Run Script Routine".

         

        Personally I like to have the current browser setted in a Project varible.

        • Project.Variables.Browser = "chrome"

         

        Also I have a variable to set if I want to close or not the browsear at the begining of each test:

        • Project.Variable.CloseBrowser = true

         

        (What I do is not exactly this way but similar). Just call a "Run Script Routine" at the begining of each KeywordTest to initialice the execution. That may close the browser or not depending on the stored CloseBrowser project variable.

         

        TestInitialize-CloseBrowser.png

         

        Sub CloseSpecifiedBrowser
          If Project.Variables.CloseBrowser Then 'this is a Boolean value
              'Close all open specified Browser Windows
              While Sys.WaitProcess(Project.Variables.Browser,2000).Exists
              Sys.Process(Project.Variables.Browser).Terminate
              WEND
          End If
        End Sub

        Hope it helps