Code Contest: Export/Importing Project Variables
Hello Community,
We are announcing the first Code Contest in our TestComplete Community. All of you can take part in the contest to check/improve your skills and win the main prize. I hope for fair play and serious competition :)
Contest Details
Create a script extension that will allow exporting/importing project variables.
To implement the task, you need to have basic coding skills, know how to use the TestComplete objects and be able to work with files from script.
You can use any script language to create a script extension. This is one of the advantages of using script extensions – they don’t depend on a particular script language used in a project.
Contest Duration
We will be waiting for your solutions till August 31. The winner will be announced shortly after that.
Contest Prize
The winner gets a $50 gift card.
Contest Storage
Once you create a ready script extension, post it as a reply to this thread. Others will be able to vote for your solution.
Contest Guideline
To help you create a script extension, I will specify some tips below. However, if you want to implement that task on your own – feel free to do so. You will need to post a working solution in the end.
Here are the steps of how this can be done:
- Code Creation:
You will need to declare at least two functions. You can do this in Code Editor and, then, move them to a script extension later.
* Export variables to an external storage (for example, to a file) – you will need to export their types and values via GetVariableType and VariableByName. Here is pseudo code written by cunderw:
function outputVars() { var count = Project.Variables.VariableCount; var name, type,value; for(var i = 0; i < count; i++){ name = Project.Variables.GetVariableName(i); value = Project.Variables.VariableByName(name); type = Project.Variables.GetVariableType(Project.Variables.VariableByName(name)) //code to write to file } }
* Import variables from the storage and add them to your project via AddVariable. Here is pseudo code written by cunderw:
-
function insertVars() { //code to open file for(lines in file) { if(!Project.Variables.VariableExists(varNameFromFile){ //add var and type } //set var value etc.. } }
2. Script Extension Creation:- Create a script extension and move the code there
- Create a GUI for your script extension by using TestComplete’s User Form
- Adding the script extension to TestComplete’s toolbar.
You can find the detailed description of the past two steps in the Creating Actions Tutorial article.
Good luck and may the odds be ever in your favor!
Hello Community,
At the beginning of my speech, I want to say big thanks to everyone who took part in our first Code Contest!
It was difficult for us to choose the winner as all of your works are great and worth using in TestComplete. To make the ultimate decision, we took into account these three criteria: functionality, extension’s GUI and usability.
Here are the extensions that made it to the final posted by:
And, the Oscar goes to… oops, sorry… and, the winner is StevenN!
Congrats, Steven!
I will contact you shortly to describe how you can get the main prize – a $50 gift card.
Please join me in saying thank you to all the participants and congratulating Steven.
And, be ready for the next contest…