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
Hi @StevenN! Thanks for the updates! Looking forward to trying the next version.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you find a solution for this, Marsha?
I'm seeing this error, too.
@Marsha_R wrote:@joseph_michaudI changed my variable to have + instead of & and now it will export and can be viewed without errors.
Next I created a new variable and exported it and then deleted it from my list to see if I could import it back. When I try that, i get this error:
Any suggestions?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@StevenN @TanyaYatskovska @joseph_michaud Did we ever get an updated version with the fixes mentioned above? I would love to be able to use this.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
+1
I too am also getting the same error
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The beautiful thing about Script Extensions is that you can simply open the TCX package by changing the extension to .zip. Open it up, find the code, and check the code line.
I'm GUESSING that the problem is related to something on the lines of Sys.OleObject('MSXML2.DOMDocument') where it has .4.0 added on the end. Just change it to MSXML2.DOMDocument and see if that fixes it.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry been missing from here for a while. I no longer have the original project (never bothered adding it to source control) but I found the updated version that I meant to upload. It has the fix for escaping the XML characters and it removed the MSXML version requirement, so should hopefully (maybe) work!
If not, then I only have access to the extension so will be limited in what can be changed.
When I try to attach the extension I get the following error:
"The attachment's importexportmanager.tcx content type (application/octet-stream) does not match its file extension and has been removed."
I'll need to upload it as a zip, so to run please first rename if from .zip to .tcx.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How are you attempting to attach the file? Remember this is a script extension.
This link may help: https://support.smartbear.com/testcomplete/docs/working-with/extending/script/installing-and-uninsta....
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know it's a script extension, I wrote it
I'm getting that error here, on the forum, when trying to upload the script as an attachment, seems it doesn't like .tcx files so that's why I uploaded it as a .zip.
