Forum Discussion

KJ's avatar
KJ
Occasional Contributor
4 years ago

.js file

Can I launch a .js file from within a Test Complete test?  If so, what are the best practices and common mistakes that occur when trying to do this?

Thank you.

 

  • In addition, if yu want to play a plain .js file to execute something, you can call ms script runner (cscript.exe or wscript.exe) by command line.

     

    Or you can register in TestedApps cscript.exe/wscript.exe and call it directly without the command line.

     

    The command line version allows you to eventually read the console output of your .js execution.

     

     

  • tphillips's avatar
    tphillips
    Frequent Contributor

    TestComplete supports test scripting, and it supports javascript as its test scripts.

    From a keyword test you can use the Run Script Routine operation to run a script function.

     

    What are you wanting to achieve in running this .js script?

  • ApplePen's avatar
    ApplePen
    Community Leader

    1.The js script that you mentioned is done by TestComplete? 

    2.Or you want to run the script out of TestComplete?

     

    If it is 1 , please do it as tphillips said.

    if it is 2, I haven't any experience. But as I know, you can run js code in TestComplete during testing web.

    Like 'pageObj.contentDocument.Script.eval("history.back()");'

    Please check the link Run JavaScript on Web Page  in detail.

  • BenoitB's avatar
    BenoitB
    Community Hero

    In addition, if yu want to play a plain .js file to execute something, you can call ms script runner (cscript.exe or wscript.exe) by command line.

     

    Or you can register in TestedApps cscript.exe/wscript.exe and call it directly without the command line.

     

    The command line version allows you to eventually read the console output of your .js execution.

     

     

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Thanks everyone for such great help!

      KJ Which advice did you end up using? Please mark the best reply as a Solution!

    • SangeetNenwani's avatar
      SangeetNenwani
      Contributor

      hello BenoitB ,
      I am working on a task, in which I have to open and search and verify data in .js file, 
      Is there given methods for it? I searched but i couldn't find, or do I have to deal it as a text file?