Forum Discussion

scsvel's avatar
scsvel
Frequent Contributor
14 years ago

TestComplete - Script Extension problem

Hi guys,



I am on the way of creating a TestComplete Script Extension file and am having problems. Here is the details i tried...

Test1.JS

1.  function TestClass1(){

2.  var a;

3.  var b;

4. function add(){

5. var c;

6. c = a + b;

7. }

8. function sub(){

9. var c;

10. c = a - b;

11. }



12. }

13. function Start(){

14. var ins = new TestClass1();

15. return ins;

16. }



Description.XML


<?xml version="1.0" encoding="UTF-8"?>

<ScriptExtensionGroup Name = "MyExts">

  <Category Name="Runtime Objects">

    <ScriptExtension Name = "TestClass1 Object" Author = "Shanmugavel" Version = "1.0 test" HomePage = "www.automatedqa.com">

      <Script Name = "Test1.js" InitRoutine = "Start">

            <RuntimeObject Name = "TestClass1">

<Method Name = "add" Routine = "add">Add method</Method>

<Method Name = "sub" Routine = "sub">Sub method.</Method>

              <Description>

                Provides access to the TestClass1 methods

              </Description>

          </RuntimeObject>

      </Script>

      <Description>

                Provides access to the TestClass1 methods

      </Description>

    </ScriptExtension>

  </Category>

</ScriptExtensionGroup>



I am having these above files in folder C:\MyExts\Ext1 and I added MyExts folder in Engines-->Script Extensions under Tools-->Options dialog. After I created a new unit and typed Test. So CodeCompletion feature lists my TestClass1 but after that no methods listed out under that TestClass1. It shows error in Test1.JS file in line 14 Column 1. 

Any ideas?
  • scsvel's avatar
    scsvel
    Frequent Contributor
    Also Project Properties --> Encoding set to ANSI and under File-->Install Script Extensions object listed out correctly.

    Also i tried after setting Also Project Properties --> Encoding to UTF-8. but no luck..

    Any other thing I have to do?

    What's the problem in my code? Still shows error in line 14 Column 1...
  • scsvel's avatar
    scsvel
    Frequent Contributor
    Hi Jared,

    Again I got into some problem. I have Description.XML which is given below and some methods(Error) listed out for that class(Logger) and some not(Warning).




    <?xml version="1.0" encoding="UTF-8"?>

    <ScriptExtensionGroup Name = "TC Script Extensions">

      <Category Name="Runtime Objects">

        <ScriptExtension Name = "Logger Object" Author = "QA" Version = "1.0 Beta" HomePage = "www.qa.com">

          <Script Name = "ResultLog.js" >

                <RuntimeObject Name = "Logger">

    <Method Name = "Error" Routine = "Error">Creates a Test Result log for Error Reporting.</Method>

    <Method Name = "Warning" Routine = "Warning">Creates a Test Result log for warning reporting.</Method>

                  <Description>

                    Provides access to the QA custom Result Logging features.

                  </Description>

              </RuntimeObject>

          </Script>

          <Description>

            Provides access to the QA custom Result Logging features.

          </Description>

        </ScriptExtension>

      </Category>

    </ScriptExtensionGroup>


    Can you clarify about this.. What I am missing? Anything wrong here?

    Thanks...
  • Hi,



    Are you able to call the method which is not listed in Code Completion? Does it help if you reload your extension (click Reload in the 'File | Install Script Extensions' dialog)?



    If this doesn't help, can you post here your script extension so we can check it on our side?
  • scsvel's avatar
    scsvel
    Frequent Contributor

    Hi ,

    I tried to reload option but no luck...

    Here is my XML and JS file...



      function LogError(Message, Comments)  { 

        var ImgErr  



        {


          ImgErr  
    = Sys.Desktop.Picture()


          Log.Error(Message, Comments, 300,
    "", ImgErr)


          ImgErr = null   


      }


      function LogWarning(Message, Comments)  { 


        var ImgWar


          ImgWar= Sys.Desktop.Picture()


          Log.Warning(Message, Comments, 300,
    "", ImgWar)


          ImgWar= null   


      }


      function LogException(Message,
    exceptionobj)  {


        Log.Error(Message, exceptionobj)


      }


      function RGB(r, g, b)  {  


       return r | (g << 8) | (b << 16);


      }


     


    Description.XML


     


    <?xml
    version="1.0" encoding="UTF-8"?>


    <ScriptExtensionGroup
    Name = "TC Script Extensions">


      <Category Name="Runtime
    Objects">


        <ScriptExtension Name = "Logger
    Object" Author = " QA" Version = "1.0 Beta" HomePage =
    "www.qa.com">


          <Script Name =
    "ResultLog.js" >


                <RuntimeObject Name =
    "TestResultLogger">


                                                    <Method
    Name = "LogError" Routine = "LogError">Creates a Test
    Result log for Error Reporting.</Method>


                                                    <Method
    Name = "LogWarning" Routine = "LogWarning">Creates a
    Test Result log for Error Reporting.</Method>


                                                    <Method
    Name = "LogException" Routine = "LogException">Creates a
    Test Result log for Error Reporting.</Method>


                  <Description>


                    Provides access to the QA custom
    Result Logging features.


                  </Description>


              </RuntimeObject>


          </Script>


          <Description>


            Provides access to the QA custom Result
    Logging features.


          </Description>


        </ScriptExtension>


      </Category>


    </ScriptExtensionGroup>



  • scsvel's avatar
    scsvel
    Frequent Contributor
    Sorry for wrong post.. I got mistakes in corrected in my script..

    Now its working well...Thanks for your support...