Code Contest: Export/Importing Project Variables
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
Tanya Yatskovskaya
SmartBear Community and Education Manager
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What a great contest! It’s so awesome to see all your extensions here.
However, the time is up. I’m closing this contest. Now, we will need to analyze all your works and choose the winner.
Thanks everybody for your contribution!
Stay tuned. We will announce the winner very soon 🙂
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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…
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Congrats, Steven! I was in your fan club 🙂
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
🙂 thanks everyone!
That was fun and I actually learned something new. Looking forward to the next contest!
@baxatob Haha I've always wanted a fan.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Guys,
I am getting error - The module's major version 0 does not match the product's major version 11.
I am using TestComplete 11.32, shall we expect version compatible plug-in(s) of it. which will be support TestComplete version 10.x, 11.x or higher version.
it's really good feature. and congrats StevenN once again. 🙂
Thanks
Ravik
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm getting an error too. I'm guessing this won't work for us in jscript if we are running vbscript.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Marsha_r,
One of the main purposes of script extensions is the possibility to work in all projects - they aren't related to the script language you use in your project.
The error says that TestComplete cannot find a file by the specified path. Please double-check the path to your file where you keep variables.
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you mean the project path?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think the issue is related to the path to the XML file. Right now, you write data to C:\Temp\fileName.xml.
2 options are possible here (from my understanding):
1- TestComplete doesn't have the permission to write data to C:\\
2- the Temp folder doesn't exist
Tanya Yatskovskaya
SmartBear Community and Education Manager
