I am trying to run some script in headed mode from command line but its always running in headless mode. The thing is when I am directly running the class from the pycharm IDE, its successfully running in headed mode but unable to do the same when running from command line using any of the following settings.
I have my pytest.ini file like below
[pytest]
addopts = --html=report/report.html --self-contained-html --reruns 0 --reruns-delay 0 -v --browser chromium --headed --slowmo 2000
I have the conftest file as below
def pytest_addoption(parser):
parser.addoption("--headed", action="store_true", default=True, help="Run browser in headed mode")
@pytest.fixture(scope="session")
def playwright():
with sync_playwright() as playwright_instance:
yield playwright_instance
@pytest.fixture(scope="session")
def browser(playwright):
browser = playwright.firefox.launch(headless=False) # Set headless=True for headless mode
yield browser
browser.close()
@pytest.fixture(scope="function")
def browser_context(browser):
context = browser.new_context()
yield context
context.close()
@pytest.fixture(scope="function")
def set_up_tear_down(browser_context):
page = browser_context.new_page()
page.set_viewport_size({"width": 1536, "height": 800})
page.goto("https://www.saucedemo.com/")
yield page
page.close()
Command:
py -m pytest -v -s test_place_order.py --headed
Is there any hidden configurations which I need to modify to achieve running the tests in headed mode using command line?