Forum Discussion

Brentp's avatar
Brentp
Occasional Contributor
10 years ago

Using VB Script within JScript project

I'm new to TC, so my apologies in advance if there is an obvious answer to this that I'm missing. 

 

I have an existing VB Script that I wish to call from within my JScript project.  When using Add...Existing Item the project looks for a .sj file rather than a .sbv file.  If I override this and add the .sbv file anyway, I'm not able to access the script it in the fashion that I would for an imported .sj script (USEUNIT) because the project is looking for a JScript file.   

 

I've tried creating a new project for just the VB Script within the same Suite, but I encounter the same problem referencing it because of the scripting language mismatch.  

 

I could re-write the VB Script if there are no other solutions, but the script is rather extensive and I'm hoping to save myself the time of re-writing.  I'm hoping that someone has a suggestion on how I can approach this.  

 

 

 

  • Hi,

     

    All code in script units within the project must be on the same language.

    Different projects within test suite may use different languages, but the rule that the same language must be used for script units (whether local or shared) within test project still apply.

    The only possible workaround for this is to move your code into Script Extension (see help for more details), but this is not always convenient and may not be always possible because not all runtime test objects accessible from the script are accessible from the script extension (again, see the help for more details).

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    All code in script units within the project must be on the same language.

    Different projects within test suite may use different languages, but the rule that the same language must be used for script units (whether local or shared) within test project still apply.

    The only possible workaround for this is to move your code into Script Extension (see help for more details), but this is not always convenient and may not be always possible because not all runtime test objects accessible from the script are accessible from the script extension (again, see the help for more details).

    • Brentp's avatar
      Brentp
      Occasional Contributor

      Thanks Alex.  I was starting to suspect that re-writing the script is the only solution since an extension will not work for what I need to do.  Appreciate your assistance. 

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        And no chance to stay with VBScript to avoid code porting?

        Just in case you are doubting: language of the tested application and language used for the test automation are independent from each other. So the fact that web pages use JScript will in no way affect your tests written using VBScript. And you still be able to call JScript functions from your web pages using your VBScript code (see help for more details on this).

        Yes, VBScript is not the best choice for some situations (for example, for testing Web Services), but for web pages it is quite acceptable, so the question is what is more reasonable to port - VBScript code or your current project code.