Getting remote files to the local machine in a remote agent scenario

Getting remote files to the local machine in a remote agent scenario

When you are running tests on a remote machine, the Open Agent writes result files and screenshots to the remote machine. However, this might not be what you want, for example if you want to locally process such result files.

Silk Test does not offer an out-of-the-box solution for writing the files to the local machine while testing on a remote machine. However, you could use the System Functions and PowerShell to do so.

The following code sample runs a browser test on a remote agent, takes a screenshot, uses the system functions and PowerShell to encode the screenshot to a Base64 String, and sends the String to the local machine. On the local machine, the example decodes the base64 String back into a PNG file and  stores the file at C:\temp\screenshot.png:

private Desktop desktop = new Desktop("<remote machine>:22901");

@Before
public void baseState() {
  // Go to web page 'demo.borland.com'
  BrowserBaseState baseState = new BrowserBaseState();
  baseState.execute(desktop);
}

@Test
public void test() throws Exception {
  desktop.<DomLink>find("demo_borland_com.BrowserWindow.Demo Application").click();

  desktop.captureBitmap("c:\\temp\\screenshot.png"); // On remote machine

  String base64 = desktop.getSystemFunctions().execute(
    "powershell \"$b = Get-Content -Encoding Byte -Path c:\\temp\\screenshot.png; [Convert]::ToBase64String($b);\"")
    .getOutput(); // On remote machine
  
  byte[] decoded = new BASE64Decoder().decodeBuffer(base64);
  Files.write(Paths.get("c:", "temp", "screenshot.png"), decoded, StandardOpenOption.CREATE); // On local machine
}

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2018-09-10 08:24
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.