admin管理员组

文章数量:1291030

I'm trying to learn Playwright, so I was checking Playwright Inspector concept and written below piece of code. In Pycharm terminal I run the below i.e. set PWDEBUG=1 and use pytest

PWDEBUG=1 pytest -s test_saucedemo.py

I get error message

PWDEBUG=1 : The term 'PWDEBUG=1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the 
name, or if a path was included, verify that the path is correct and try again.

Note: Path of the file is proper because when I run as pytest -s test_saucedemo.py test is passed.

import pytest
from playwright.sync_api import Page,expect

def test_page_title(page:Page):
    page.goto(".html")  #pytest --base-url 
    expect(page).to_have_title("Swag Labs")
    page.get_by_placeholder("Username").fill("standard_user")
    page.get_by_placeholder("Password").fill("secret_sauce")


    page.locator("input.btn_action").click()

I'm trying to learn Playwright, so I was checking Playwright Inspector concept and written below piece of code. In Pycharm terminal I run the below i.e. set PWDEBUG=1 and use pytest

PWDEBUG=1 pytest -s test_saucedemo.py

I get error message

PWDEBUG=1 : The term 'PWDEBUG=1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the 
name, or if a path was included, verify that the path is correct and try again.

Note: Path of the file is proper because when I run as pytest -s test_saucedemo.py test is passed.

import pytest
from playwright.sync_api import Page,expect

def test_page_title(page:Page):
    page.goto("https://www.saucedemo/v1/index.html")  #pytest --base-url https://www.saucedemo
    expect(page).to_have_title("Swag Labs")
    page.get_by_placeholder("Username").fill("standard_user")
    page.get_by_placeholder("Password").fill("secret_sauce")


    page.locator("input.btn_action").click()
Share Improve this question edited Feb 14 at 6:10 ggorlen 57.3k8 gold badges110 silver badges154 bronze badges asked Feb 13 at 16:39 user166013user166013 1,5035 gold badges22 silver badges38 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The command you are executing to start your tests is using POSIX shell syntax for setting the environment variable PWDEBUG, but you seem to be executing it in a PowerShell.

The PowerShell syntax is a bit different. Try executing the following command instead:

$Env:PWDEBUG = 1; pytest -s test_saucedemo.py

See the question PowerShell: Setting an environment variable for a single command only.

本文标签: pythonUnable to run Playwright test scripts in debug ModeStack Overflow