Weird issue happening. I created a test and it passes when running via VS Code using the playwright plugin, but fails when I try to run it via the command line using npx playwright test. how can I check to make sure I am using the same test runner for both ways of execution? Or does anyone have any ideas?
This thread is trying to answer question "Why does a test pass when run via VS Code using the playwright plugin, but fail when run via the command line using npx playwright test, and how can the same test runner be ensured for both methods of execution?"
Error: page.waitForResponse: Page closed at ..\pages\blockEnergyPredictions.ts:58
56 | //});
57 |
58 | const response = await page.waitForResponse(response => { | ^ 59 | return ( 60 | response.url().startsWith('http://website.com/web/v1.0/agency_blocks/') && 61 | response.status() === 200
Retry #1 ─────────────────────────────────────────
Test timeout of 30000ms exceeded.
Error: locator.waitFor: Page closed
This is the code it was trying to execute: const response = await page.waitForResponse(response => { return ( response.url().startsWith('http://xxx.xx.xx.x/web/v1.0/agency_blocks/') && response.status() === 200 ); }, { timeout: 60000 });
Do you have multiple projects in your config? Which project(s) do you have selected in your vscode extension? Are you literally just running npx playwright test
or adding anything extra on that may be changing the test execution? Have you checked traces from the failed tests to identify anything more specific on what is going wrong?
Ya no replacing the need to debug and investigate your test, no substitute from rolling up you sleeves and figure out what is happening. not a surprise that running in VS Code you may effectively be adding time delays which the tests outside of VS Code won't benefit from, if you increase the default timeout value while running from npx? Until you can rule that out seems you have some debugging and investigating?
1 Playwright\tests\QA\Quote-LinQ\Broker_Admin\Log in\Log_in_Broker.spec.ts:3:5 › test (30.0s)
Test timeout of 30000ms exceeded.
Error: locator.pressSequentially: Test timeout of 30000ms exceeded.
Call log:
- waiting for getByPlaceholder('Username')
3 | test('test', async ({ page }) => {
4 | await page.goto('https://qa.quote-linq.com/auth/login');
5 | await page.getByPlaceholder('Username').pressSequentially('Broker_admin',{delay: 100}); | ^ 6 | await page.getByRole('button', { name: 'Login' }).click(); 7 | await page.getByPlaceholder('Password').pressSequentially('password123', {delay: 100}); 8 | await page.getByRole('button', { name: 'Login' }).click(); at C:\Users\Steve Bishop\Playwright\tests\QA\Quote-LinQ\Broker_Admin\Log in\Log_in_Broker.spec.ts:5:43
Slow test file: Playwright\tests\QA\Quote-LinQ\Broker_Admin\Log in\Log_in_Broker.spec.ts (30.0s) Consider splitting slow test files to speed up parallel execution 1 failed Playwright\tests\QA\Quote-LinQ\Broker_Admin\Log in\Log_in_Broker.spec.ts:3:5 › test ──────────
After running your test from the command line you would run: npx playwright show-report
which would open the playwright html report, and you can then view the trace for the test from there
Or you can drag the trace.zip file to https://trace.playwright.dev/
thank you for your input. I appreciate it. When I ran npx playwright (name of test) show-report I didn't have anything open up. This is what my config has in it reporter: [
['list'],
['html', { open: 'always' }]
],
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].