Forum Discussion

DarkShadows's avatar
DarkShadows
Contributor
8 years ago

How to make generic script

Hello Team,

i'm new in to use TestComplete tools, however while doing some experiment on this tool what i observe that how we can maintain the main scripts across entire platform. i'm QA and working on many different platforms likes Test ,Prepod and Prod environment and so using normal scripts recording action (as learner i have selected this option ) scripts has been recorded specific objects or elements correctly however the same scripts is failing if we run the same scripts on another environment. what  i observed that specific object or element been captured based on somewhat following login e.g. it based on browser.alias.{env url}.element parent class.main element location. so whenever you make any changes in the environment then in that case the locked obejct or element present in new environemnt however TestComplete failed to identify its mainly due to the change in the Web url . let me represent you following example hope this will help you to understand the exact issue i'm facing at presently.

 

Login button

OnTest Environment-

browser.alias.{www.testenvironment.com}.Loginpagepanel.Loginbtn

 

OnPrepod Environment-

browser.alias.{www.prepodenvironment.com}.Loginpagepanel.Loginbtn

 

please note**:

I'm adding objects by using on screen object operation method.

 

 

it will be really appreciated if somebody guide me what and how i can manage one scripts across different environment.

 

and can someone advise me is it feasible to use recording (extended) scripts or shall i go for directly Java-scripts .

 

Many Thanks

Amit Bhagwat

 

 

  • As with any automation tool that automates based upon UI, what you enter in during recording is what is stored in the script created.  This includes URL's stored in NameMapping files, etc.  The general process is then, after recording, going back and editing scripts and NameMapping objects to be more generalized.

     

    For example, in our AUT, we have multiple environments as well with the same basic pages on each environment.  On one environment, the URL is something like http://testenvironment1.mycompany.com/mainsegment/mainpage.html.  On another environment, the URL is http://testenvironment2.mycompany.com/mainsegment/mainpage.html.  If I do the recording in the first environment, the URL gets entered in NameMapping as indicated above.  If I want it to be able to run against any environment, what I do is edit my namemapping so the URL for the page is "*/mainsegment/mainpage.html".  This will make the mapping work for any environment so long as the path and page in the URL remains the same.  This is what I suggest you do after your recording.  

     

    As a rule of thumb, for sustainable, maintainable, and reusable test automation, ALWAYS edit your recording after you're done recording.  The recording should never be used as the actual test to be run but should only be used to get you started.  Your validations, verifications, etc., should be added after the fact and the test should have wildcards, parameters, etc., applied in order to do precisely what you are asking.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    As with any automation tool that automates based upon UI, what you enter in during recording is what is stored in the script created.  This includes URL's stored in NameMapping files, etc.  The general process is then, after recording, going back and editing scripts and NameMapping objects to be more generalized.

     

    For example, in our AUT, we have multiple environments as well with the same basic pages on each environment.  On one environment, the URL is something like http://testenvironment1.mycompany.com/mainsegment/mainpage.html.  On another environment, the URL is http://testenvironment2.mycompany.com/mainsegment/mainpage.html.  If I do the recording in the first environment, the URL gets entered in NameMapping as indicated above.  If I want it to be able to run against any environment, what I do is edit my namemapping so the URL for the page is "*/mainsegment/mainpage.html".  This will make the mapping work for any environment so long as the path and page in the URL remains the same.  This is what I suggest you do after your recording.  

     

    As a rule of thumb, for sustainable, maintainable, and reusable test automation, ALWAYS edit your recording after you're done recording.  The recording should never be used as the actual test to be run but should only be used to get you started.  Your validations, verifications, etc., should be added after the fact and the test should have wildcards, parameters, etc., applied in order to do precisely what you are asking.