Forum Discussion

ajaybabu's avatar
ajaybabu
Occasional Contributor
15 years ago

open and close browser

what is the testcomplete code to launch either firefox or IE browser through script


and also what is the script to close open browsers(may be IE or firefox)

7 Replies

  • Ravik's avatar
    Ravik
    Super Contributor




    Hi All,



    We can use below code/Script for launching the browser




    Sub
     Browser

    dim IE



    set IE= CreateObject("InternetExplorer.Application")



    IE.visible= True



    IE.Navigatewww.google.com



    Delay(15000)

     



    End Sub


  • function openBrowser() {



      var bi = Browsers.Item(btIExplorer);

      // Browsers.Item(btChrome);

      // Browsers.Item(btFireFox);

     

      bi.Run("yourURL");



    }







    function closeBrowser(){

      browserWindow = Sys.Browser().BrowserWindow(0);

      browserWindow.Close();

    }
  • Can I specify the URL I need to open in the testedApps Run command?

    like I need to open a web page if a value is set, url is obtained in between the script execution.
  • tim_espasandin's avatar
    tim_espasandin
    Occasional Contributor
    I'm having some trouble opening browsers today.  Here's a sample of the code that isn't working for me:



      Browsers.Item("iexplore").Run("https://www.google.com");



    This gives me an "Unspecified Error". Can anyone tell what's going wrong here?
  • tim_espasandin's avatar
    tim_espasandin
    Occasional Contributor
    Hmm... I've just rebooted my machine, and I can now open browsers with no trouble. Hopefully, this won't be a problem again.