What is the SwfConfig file?
The SwfConfig file, or .NET Add-in Extensibility configuration file as it is sometimes referred to by HP, is a XML formatted configuration file. This file is always located at the location:
{$HPTestingSoftwareInstallDirectory}\dat\SwfConfig.xml
This configuration file is read by HP’s UI testing software whenever you create a new or open a different existing test. This file is used to map the UI controls that you interact with for recording and replaying automated tests to a custom server proxy, such as what IG TestAutomation does for Infragistics Windows Forms UI controls.
What Information does the SwfConfig file Contain?
HP UI testing software loads this XML file into an internal table every time you either you create a new script or open an existing one. This timing should be noted, on one hand it offers the user the ability to change the SwfConfig file without closing the testing software, but on the other changes to the file do not take effect if you don’t change the active script. Also the configuration is not tied to a script, an existing script can be working fine, but changes to the SwfConfig file can break the script, even though the script itself wasn’t changed.
The above mentioned table maps the text Type name of a .NET UI Control that inherits from System.Windows.Forms.Control to the DLL’s and classes that are intended to control the record functionality, the replay functionality, and an interface that tells the testing software what methods are intended to be public. In addition Settings specific to the proxy can me stored as parameters, those about are exposed via the Settings Utility entry that correspond to the control as well as in a script.
How does the SwfConfig file work?
During Record
HP listens to low level windows messages to determine which control you are attempting to interact with. In the case of keyboard interaction, it bases off what Control has keyboard focus, in the case of Mouse interactions it bases it off of if you Clicked or moved inside the bounds of that control. When testing software identifies a control it first checks the Object Repository to see if it has already interacted with the control. It then looks up the Type name of the control in the SwfConfig based table. If the software finds the Type name in the table, and if the DLL referenced in the CustomRecord tag is not already loaded, the software will then attempt to load the DLL.
NOTE: While the UI Testing software can responds to mouse hovers, mouse moves and similar indirect actions. Those indirect action will not cause it to trigger an initial load of a custom server proxy, only a Click, gain focus, or keyboard input will trigger the initial load.
During Replay
Each line of script references one or more objects in the Object Repository. Internal to the Object Repository it stores the type name, and when you run the line of script, it will look up the type name in the SwfConfig based table. If the software finds the Type name in the table, and if the DLL referenced in the CustomReplay tag is not already loaded, the software will then attempt to load the DLL.
Troubleshooting
As the primary use of the SwfConfig file is to match the UI control under test with the custom proxy server DLL associated with it, and since that DLL contain all the record and replay functionality for that control, any issue with the SwfConfig will in turn break all of the custom record and replay functionality for that control.
The symptoms of issues with the SwfConfig.xml vary depending on the root cause, and the timing of when you are getting those symptoms either via record or replay. The resolutions will vary depending on the symptoms.
During Record
In many cases, you can identify an issue with the SwfConfig file, when recording against an Infragistics control, in the recorded script line the objects are proceeded with Swf, such as SwfObject or SwfTable, but the action recorded is Click #,# representing X and Y coordinates or Type “string value”.
It should be noted that it is possible that the HP UI testing software may record actions other than Click X, Y or Type “string” and still be a problem with the SwfConfig file. This is because they have implemented some functionality for Infragistics controls. The functionality that was implemented was done based on a limited subset of our controls at the time of their implementation. The controls and feature sets that have support are roughly based on the controls we had a the time of their implementation of the support, which is approximately the NetAdvantage 2005 volume 1 version of the controls.
When IG TestAutomation was first created its initial implementation was based on the support already provided, so the actions that might be recorded would be similar to actions recorded by TestAdvantage, but likely the actions recorded will be limited and not replay as intended as the NetAdvantage controls have changed over the years.
By the nature of how the HP UI testing software handles recording, you will very rarely get a discernable error, as they regularly swallow all errors.
During Replay
Typically the only way you will tell you have an issue from Replay is from a previously successfully recorded script. As an improperly configured SwfConfig file means you wouldn’t be able to record either, means you are likely testing an existing script, such as those that come with the samples.
Some of the most common issues that you will get during replay are via one of the following exceptions.
This happens when the version of TestAdvantage doesn’t match the version of NetAdvantage that you are using for the UI control in the application under test (AUT). The nature of the exception is TestAdvantage has references to NetAdvantage assemblies, but of a difference version than is included in the AUT. It attempts to find it, which in normal circumstances it would load it from the AUT, but as they are different it is unable to find the assembly it needs.
2. Throws a ‘Cannot cast exception’ exception, and the same named assembly but from two different versions.
Similarly this also happens when the version of TestAdvantage doesn’t match the version of NetAdvantage that you are using for the UI control in the application under test (AUT), the difference being it finds the DLL’s that it is looking for, likely in the Global Assembly Cache (GAC), but when it attempts to convert the UI Control from the AUT, to the UI Control it has a reference to, it throws the exception because they are different.
3. Throws an ‘Object doesn’t support this property or method’ or ‘Object doesn’t support this action’ exception. But the method or property exists in the intellisense for the object.
These exceptions are caused by not having any version of TestAdvantage defined in the SwfConfig. Typically caused by either an empty, SwfConfig and/or by setting the VersionUtility to disabled. But can also be caused by the DLL’s pointing to an invalid file location.