We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More
This site is now read-only. You can still browse and search as usual. Learn More
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 https://support.smartbear.com/testcomplete/docs/reference/options/engines/java-bridge.html. 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
Difficulty:
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 https://www.vbsedit.com/html/c1c1f29c-2a30-46a1-bae7-c17f8af55a19.aspof the WScript.Shell object to obtain the %LOCALAPPDATA% environment variable value.
2. https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms762722(v=vs.85) and locate the node that should contain the option value.
You can use the https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms754523(v=vs.85) or https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms757846(v=vs.85)methods of the DOMDocument object to get the needed node.
3. https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms754616(v=vs.85) for the node attribute.
4. https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms753769(v=vs.85).
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
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
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?
tristaanogre Yes, let's assume it is the same user.
Sorry but what is IIRC ?
If I Remember Correctly. ๐