cancel
Showing results for 
Search instead for 
Did you mean: 

[TechCorner Challenge #3] - Changing the options from outside of TestComplete

SOLVED
Highlighted
Community Manager

[TechCorner Challenge #3] - Changing the options from outside of TestComplete

Hi TestComplete Community! I bring you another task for our weekly scripting challenge🙂

Learn new things about working with the product, and get into the TechCorner Leaderboard!

 

Imagine that you need to change the TestComplete options on several machines - for example, set the JVM location. You don’t want to do it manually and decide to create a script and run it on each machine. How could this script look?
We suggest using JScript or VBScript, but you choose PowerShell, Python, etc.

 

Task: Create a script that changes TestComplete options from outside of TestComplete

DifficultyStar_Gold.pngStar_Gold.pngStar_gray.png

 

It is a bit more difficult than the tasks we posted here before, let's see how quickly you can solve his one!🙂

 

Upd: More hints!

 

Follow these steps to solve this:

 

1. You need to modify the XML file that contains the TestComplete settings - tcSettings.xml. The file is located in
%LOCALAPPDATA%/SmartBear/TestComplete/14.0. You can use the ExpandEnvironmentStrings method of the WScript.Shell object to obtain the %LOCALAPPDATA% environment variable value.

 

2. Open the XML file and locate the node that should contain the option value.
You can use the selectNodes or selectSingleNode methods of the DOMDocument object to get the needed node.

 

3. Set the needed value for the node attribute.

 

4. Save the XML file.


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Manager

Changing the options from outside of TestComplete

Task: Create a script that changes TestComplete options from outside of TestComplete

 

This is a solution created for [TechCorner Challenge #3]

 

Hi All,

I always try to find some time for coding. Recently, I've started learning VBA to create macros in Excel 😎 

 

So, here is a sample of how to read TestComplete settings from a setting file. However, I would like to mention that the structure of the setting file isn't documented and, thus, it can be changed from version to version. It's always better to use TestComplete/TestExecute UI to change settings.

 

Anyway, here is a VBScript code. Please feel free to post your comments.

 

 

 

Sub readTCsettings

  Dim Doc, localappdata, path, jvmSetting, newJvmPath
   
  'get a path to local settings
  localappdata = WshShell.ExpandEnvironmentStrings("%LOCALAPPDATA%")
  
  'get an object to work with XML
  Set Doc = Sys.OleObject("Msxml2.DOMDocument.6.0")
  
  'make sure that we can read a hidden file
  Call Doc.setProperty("ProhibitDTD", false)
  
  Doc.async = false
  path = localappdata + "\SmartBear\TestComplete\14.0\tcSettings.xml"
  
  'load the xml settings file
  Doc.load(path)
  
  'get the node with settings
  Set jvmSetting = Doc.selectNodes("//Node[@name='{2e030b0e-f461-47e8-980a-56851ef43cff}']/Node[@name='{291fd292-a44f-4b82-9232-e8899ca6c851}']/Prp[@name='value']")
  
  if jvmSetting.length = 0 Then
    Log.Message ("JVM setting wasn't found")
  
  Else
    'log the value of the setting
    Log.Message ("Current JVM settings: " & jvmSetting(0).getAttribute("value"))
  
  End If
  
End Sub

 

 

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

Tags (1)
12 REPLIES 12
Community Hero

Re: [TechCorner Challenge #3] - Changing the options from outside of TestComplete

question for clarification:

I think, IIRC, that some of these options are stored in the user profile.  Are you assuming that the user that is running the automation to change the options is the same user for whom the changes should be made?


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
Highlighted
Community Leader

Re: [TechCorner Challenge #3] - Changing the options from outside of TestComplete

Sorry but what is IIRC ?

Un sourire et ça repart

Highlighted
Community Hero

Re: [TechCorner Challenge #3] - Changing the options from outside of TestComplete

If I Remember Correctly. 🙂


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
Highlighted
Community Manager

Re: [TechCorner Challenge #3] - Changing the options from outside of TestComplete

@tristaanogre Yes, let's assume it is the same user.


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Community Manager

Re: [TechCorner Challenge #3] - Changing the options from outside of TestComplete

This is definitely a more difficult task, who will try to crack it?

 

@AlexKaras @Reshail @Wamboo 🙂


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Community Manager

Re: [TechCorner Challenge #3] - Changing the options from outside of TestComplete

💡 A hint - the XML-file with settings in %LOCALAPPDATA% needs to be changed!


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Community Leader

Re: [TechCorner Challenge #3] - Changing the options from outside of TestComplete

Yes, of course I will want to try 🙂 a very cool initiative with this task. I have a lot of work at the moment and if I will have a free moment I'll take up the challenge 🙂

Highlighted
Community Leader

Re: [TechCorner Challenge #3] - Changing the options from outside of TestComplete

Same situation as @Wamboo   ...  give us more time 😉

Un sourire et ça repart

Highlighted
Community Manager

Re: [TechCorner Challenge #3] - Changing the options from outside of TestComplete

@Wamboo @BenoitB Take as much time as you need🙂

 


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors