Rayrun
← Back to Discord Forum

Terminal commands for VSCode plugin before "Record at cursor" or "Record new"

When using the playwright plugin for VSCode, is there a way to run terminal commands before "Record at cursor" or "Record new" is activated? This is useful if you're using commands in other languages that require another virtual environment for example.

This thread is trying to answer question "Is there a way to run terminal commands before 'Record at cursor' or 'Record new' is activated in the playwright plugin for VSCode?"

1 reply

Answer

Sure, you can run terminal commands before using the "record at cursor" or "record new" feature in the Playwright plugin for VS Code. Here's how:

Open Terminal in VS Code

First, open the integrated terminal in VS Code. You can do this by going to View -> Terminal or by pressing Ctrl+` (backtick).

Run Terminal Commands

Now, you can run any terminal command you need. For instance, if you need to install dependencies or start a local server, you can use commands like npm install or npm start.

npm install
npm start

These commands will run in your project's directory.

Start Recording

After setting up your environment, you can start recording.

To "record at cursor", click the corresponding button in the Testing sidebar. This will generate actions in your existing test file at the current cursor position.

// Example of recording at cursor
import { test } from '@playwright/test';

test('my test', async ({ page }) => {
  await page.goto('https://ray.run/');
  // Your recorded actions go here
});

To "record new", click the respective button in the Testing sidebar. This will create a new test file and open a browser window for recording.

// Example of recording new
import { test } from '@playwright/test';

test('my new test', async ({ page }) => {
  await page.goto('https://ray.run/');
  // Your recorded actions go here
});

Running terminal commands before recording lets you customize your test environment and perform necessary setup tasks. This ensures your tests accurately reflect your application's desired behavior.

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].