Quantcast
Channel: Silk Test Knowledge Base
Viewing all articles
Browse latest Browse all 105

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

$
0
0
Current Revision posted to Silk Test Knowledge Base by Vasilis Will on 9/9/2018 11:40:47 PM

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
}
Tags: result files, copy to local, remote agent, Screenshots

Viewing all articles
Browse latest Browse all 105

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>