Forum Discussion

RichBopp's avatar
RichBopp
Contributor
4 years ago
Solved

Keyword Project - Convert from Python to JavaScript

Short Question - How do you convert a Keyword Project recorded using Python as the underlying language to JavaScript?

 

Long Background - When we were originally creating Projects years ago - we experimented with using different underlying languages for our Keyword Projects.  Quickly we decided to go with JavaScript as our standard as it appeared to be the most universal.  Since what we were reading at the time stated that the underlying language should have no impact on actual function - we didn't bother redoing anything we had in Python. 

 

Now we are running into issues which require some scripting (i.e. - Capture an Order number from a screen, then plug that number into another function).  We don't want to have to find solutions for both languages.  As JavaScript is our standard, we want to convert our Python Projects. 

 

Anyone know how? 

  • Hi Rich,

     

    Are we out of luck?

    Unfortunately, yes, you are.

    However, I believe that unless you were using something that is very specific to Python, the conversion should not be that difficult.

    Personally I convert from time to time my code that I created in VBScript, DelphiScript and JScript and the process is quite straightforward. (Tip: my preference is to use the means provided by TestComplete instead of native functionality provided by the given scripting language whenever possible. (E.g. functions to work with date, time, strings, etc.) This significantly simplifies future conversion.)

    Another option that you may consider is to create Script Extension and move common generic code to there. Script Extensions are not ideal but can be used from projects that are based on different scripting languages.

     

4 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Pure keyword tests are language-agnostic. But embedded code snippets must be converted manually.

     

    • RichBopp's avatar
      RichBopp
      Contributor

      Hi Alex,

       

      Thank you for responding.  Much appreciated.

       

      Not quite the answer I was hoping for though.   We're looking to only need to maintain a code snippet library for a single language - JavaScript.  Hence our desire to convert Projects recorded using Python to JavaScript.  

       

      We were really hoping for something along the lines of:

       

      1 - Select 'Tools/Options'
      2 - Select General/Projects'
      3 - Select Default Language= JavaScript
      4 - Select the Python Project you wish to convert.
      5 - Clone the Project.
      6 - Verify the Project is cloned as JavaScript by clicking on the Project's Advanced/Script/Unit1 - Look at footer display.
      7 - Run the new JavaScript Project to verify that it functions correctly. Make corrections as needed.

       

      So - Are we out of luck?  No such option?  Rerecord is all we can do?

       

      I would appreciate your insights,

       

      Rich

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi Rich,

         

        Are we out of luck?

        Unfortunately, yes, you are.

        However, I believe that unless you were using something that is very specific to Python, the conversion should not be that difficult.

        Personally I convert from time to time my code that I created in VBScript, DelphiScript and JScript and the process is quite straightforward. (Tip: my preference is to use the means provided by TestComplete instead of native functionality provided by the given scripting language whenever possible. (E.g. functions to work with date, time, strings, etc.) This significantly simplifies future conversion.)

        Another option that you may consider is to create Script Extension and move common generic code to there. Script Extensions are not ideal but can be used from projects that are based on different scripting languages.