Forum Discussion

jsc's avatar
jsc
Regular Contributor
13 years ago

TestExecute does not start browser

Hello all,



I implemented some script for web testing with TestComplete (9.1 today updated to 9.2). Everything is running fine on my pc.



If I run the same script with TestExecute the test stops with an error and the browser cannot be started.



Error: Exception

Additional Information: "An error occurred while executing the code snippet: Unable to evaluate the expression"



The simplified script is:



Log.Message("Browser0");

Browsers.item(btChrome).Run();

Log.Message("Browser1");

Browsers.item(btChrome).Navigate("www.smartbear.com");



The "Browsers.item(btChrome).Run();" throws the exception.



What do I have to change in TestExecute to make the code run?



Best regards

Joachim

  • jsc's avatar
    jsc
    Regular Contributor
    Update:



    I can run it in TestComplete in the scripts but i CANNOT run it in the keyword tests in TestComplete (calling the function via "run code snippet").



    Error: 'Browsers' is undefined (runtimeerror)





    The Keyword test is calling a function in the scriptextensions.

    This function installs some software, checks some process and services and then starts the browser (chrome) to do some initial checks.

    > the browser cannot be started.
  • Hi Joachim,



    Have you tried

    Browsers.Item("chrome").Run



     ... or try adding Chrome to your TestedApps. This helped me resolve a similar issue with starting a browser in TestComplete.



    Hope this helps!
  • jsc's avatar
    jsc
    Regular Contributor
    Hi,



    I tried all your suggestions.



    1)

    Browsers.Item("chrome").Run();

    - Result: Browsers is undefined



    2)

    Adding Chrome to Tested Apps (in the scriptextensions and the keyword tests)

    TestedApps.chrome.Run()

    - Result: Browsers is undefined



    I don't get it, I have no idea, what I could do to make the script run!





    The setup is like this:

    - keyword test calling a function in the scriptextensions

    - this functions starts chrome, does some checks and closes chrome again



    a) this function on his own (calling script routine) works perfectly fine

    b) calling this function from keyword tests does not open the browser and stops with an exception







    Joachim

  • jsc's avatar
    jsc
    Regular Contributor
    legacy web testing features are disabled in my project.

    The tests are created in TC9.x



    Should it be enabled?
  • jsc's avatar
    jsc
    Regular Contributor
    It's not working at all. My keyword tests execute a script (in the scriptextensions), that should open and close a browser without doing anything else. 

    - running the script itself in the extensions is working properly

    - calling it from keyword tests does not work at all



    it's actually a copy of a smartbear example.




    function checkChromeVersion()


    {


      var page, browser;


      // Run the web browser and obtain a web page


      Browsers.Item(btChrome).Run("http://google.de/");


      browser = Aliases.browser;


      // Close the web browser


      browser.BrowserWindow.Close(5000);


      // -- or


      //browser.Close(5000);


    }



    the result still is:

    - 'Browsers' is undefined

    - runtime error in Microsoft JScript

    - Line:  Browsers.Item(btChrome).Run("http://google.de/");



    Should this be reported as a bug?

    Or is it really not possible to start/close a browser through scriptextensions?

  • jorgesimoes1983's avatar
    jorgesimoes1983
    Regular Contributor
    We created a simple bat to kill the browser active processes and start again the browser.



    You can use something like that for any process.



    File.bat



    taskkill /f /im "iexplore.exe"

    start /MAX iexplore.exe