Forum Discussion

pwang's avatar
pwang
Occasional Contributor
3 years ago

Dynamically add TestedApps in Script Extensions

Hi,

I create a Script Extensions and introduced themethod which i could add TestedApps Dynamically.

I could run successfully in debug mode but failed in Script Extensions.

I am not sure if we could add TestedApps in Script Extensions dynamically  ,Did  I miss something here?

 

Code like this:

function AddCharApplication(){

var AppPath = "a.exe"
var index = "";
TestedApps.Clear();

if ( aqFile.Exists( AppPath ) ) {
var index = TestedApps.Find( AppPath );
if ( -1 == index )
index = TestedApps.Add( AppPath );
} else {
Runner.Stop( false );
Log.Error( "" );
}
var apprun = TestedApps.Items( index ).Run();
}

 

Error Message:

Thanks,Peng

  • pwang's avatar
    pwang
    3 years ago

    Yes, I think i have to create a new project to dealt with this on the recommendation of you.

    Thank you very much!.

     

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Yes you can. I had written this, on another post today:

     

    If you find yourself starting to implement the same functions, then it's probably best to create a separate project which has all your functions, which can then be called from other projects

     

    For example,

    See Import Functions Dialog, and require("Unit1"); uses round brackets, not square!

    • pwang's avatar
      pwang
      Occasional Contributor

      Yes, I think i have to create a new project to dealt with this on the recommendation of you.

      Thank you very much!.

       

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Just to clarify, your script extension, is it relating to Script Extensions Dialog ?

     

    TestedApps is inbuilt into TC. It seems like your Script Extension can not use the inbuilt functions of TC. The coding you have written, does it really need to be an Extension?

    • pwang's avatar
      pwang
      Occasional Contributor

      I have multiple projects need to run in sequence, and also need to start different clinet testapp for different project.

      My first thought I wanna add the TestedApps in the script extension. then some project could start some testapp from script extension when it is executed.

       

      if this could be implemented, i think i may not need to add the Testapp for some projects, and those project could be call the common method directly from script extension.

       

      It seems that I'll have to go the other way.

       

      Thanks rraghvani for your quick reply!!🙂

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Script Extensions are used to create TestComplete plugins using TestComplete SDK.

     

    From what I understand, you want to launch different applications, such as a.exe, b.exe, c.exe etc? You can define these in TestedApps, and launch them in your projects.

     

     

    • pwang's avatar
      pwang
      Occasional Contributor

      Hi rraghvani,Do you know if there is any way to call the method in script in cross project in one TestSuite.

       

      TestSuite

       

      -Project A
      --scipt
      ------- Function A(){}

      -Project B
      --scipt
      ------- Function B(){}

      -Project C
      --scipt
      ------- Call Function A() in Project C ??