How to access files on the system under test
TestResults.io executes the test cases on a remote system (System Under Test - SUT). This means that the test case code does not have access directly to the file system of the SUT. To be able to work with files on the SUT, such as uploading files in the tested application, TestResults.io supports working with remote directories that allow access to files required for the test execution. These remote directories are provided automatically when executing through the TestResults.io API or portal. Supporting Files that are provided for the test case in the portal are available in the path from
SystemHelpers.SupportingFilesDirectory, the software executable for a software version in
SystemHelpers.InstallerDirectoryand files generated during the test exeuction should be copied to
SystemHelpers.ArtifactsDirectoryso that they can be accessed from the test report in the portal.
In order to test and debug the interactions with these remote directories also when executing from the Designer, it is possible to configure a remote directory on the Test Environment in the Designer. The simplest way to set this up, is to configure a local shared folder on the system under test by following these steps:
- 1.Create a new folder "RemoteDirectory" (eg in C:\Temp)
- 2.From the contextmenu of the folder go to the "Properties"
- 3.In the Sharing tab, click Share and then in the Network access dialog again Share. This will create a shared folder that you can also access over the network.
- 5.Place the files you need during test execution in the subfolder "SupportingFiles" of the RemoteDirectory folder
Configure RemoteDirectory as a Shared Folder
The SetupRemoteDirectory is typically being executed by the installation test case, so you don't need to call it from a test case.
Code example to upload or open a file:
var dialog = new FileDialog(t, App.SystemHelpers);
// Replace MyScreen.UploadButton with the correpsonding button from your sw model:
dialog.SetFileName(App.SystemHelpers.SupportingFilesDirectory + "MyFile.txt");
And for downloading a file from a webapplication:
// Replace MyScreen.FileDownload with the correpsonding button from your sw model:
App.Browser.DownloadAndSaveFileAs(App.SystemHelpers.ArtifactsDirectory + "MyFile.txt");