---
title: "Exec Output Test Example"
sidebarTitle: "Exec Output"
description: "Example test demonstrating how to capture and use output from PowerShell exec commands."
icon: "terminal"
mode: "wide"
---

## Demo Test Run

Watch this test execute in a real sandbox environment:

{/* exec-output.test.mjs output */}
<iframe 
  src="https://api-test.testdriver.ai/api/v1/testdriver/testcase/69c5d02ee8a04db4b705cbeb/replay" 
  width="100%" 
  height="390" 
  style={{ border: "1px solid #333", borderRadius: "8px" }}
  allow="fullscreen"
/>

## Source Code

```javascript title="exec-output.test.mjs" {22-27}
/**
 * TestDriver SDK - Exec Output Test (Vitest)
 * Converted from: testdriver/acceptance/exec-output.yaml
 */

import { describe, expect, it } from "vitest";
import { TestDriver } from "testdriverai/vitest/hooks";

describe.skip("Exec Output Test", () => {
  it(
    "should set date using PowerShell and navigate to calendar",
    async (context) => {
      const testdriver = TestDriver(context, { ip: context.ip || process.env.TD_IP, headless: true });
      await testdriver.provision.chrome({ url: 'http://testdriver-sandbox.vercel.app/login' });

      //
      // Generate date in query string format
      const queryString = await testdriver.exec(
        "pwsh",
        `
$date = (Get-Date).AddMonths(1)
Write-Output $date.ToString("yyyy-MM-dd")
    `,
        10000,
      );

      // Assert that the date is valid
      const dateValidResult = await testdriver.assert(
        `${queryString} is a valid date`,
      );
      expect(dateValidResult).toBeTruthy();

      // Generate date in display format
      const expectedDate = await testdriver.exec(
        "pwsh",
        `
$date = (Get-Date).AddMonths(1)
Write-Output $date.ToString("ddd MMM d yyyy")
    `,
        10000,
      );

      // Navigate to calendar with date parameter
      await testdriver.focusApplication("Google Chrome");
      await testdriver.pressKeys(["ctrl", "l"]);
      await testdriver.type(
        `https://teamup.com/ks48cf2135e7e080bc?view=d&date=${queryString}`,
      );
      await testdriver.pressKeys(["enter"]);

      // Assert that the expected date shows
      await testdriver.focusApplication("Google Chrome");
      const result = await testdriver.assert(
        `the text ${expectedDate} is visible on screen`,
      );
      expect(result).toBeTruthy();
    },
  );
});
```
