Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Config file support #69

Open
kumaraditya303 opened this issue Jul 24, 2021 · 2 comments
Open

[FEATURE] Config file support #69

kumaraditya303 opened this issue Jul 24, 2021 · 2 comments

Comments

@kumaraditya303
Copy link
Contributor

Same thing as in js/ts world playwright.config.ts equivalent for python playwright.conf.py which would automatically parameterize all the tests.

Includes #67

@michaelsatish
Copy link

@mxschmitt

How about using the pyproject.toml file for configuration.

[tool.playwright]
headed = true
@pytest.fixture(scope="session")
def playwright_config(request: pytest.FixtureRequest) -> Dict:
    rootpath = request.config.rootpath
    config_file_path = rootpath / "pyproject.toml"

    if not config_file_path.exists():
        return {}

    with config_file_path.open(mode="rb") as f:
        config = tomli.load(f)
        return config.get("tool", {}).get("playwright", {})

@pytest.fixture(scope="session")
def browser_type_launch_args(pytestconfig: Any, playwright_config: Dict) -> Dict:
    launch_options = {}
    headed_option = pytestconfig.getoption("--headed") or playwright_config.get("headed")

I am not a seasoned python developer. If this is an acceptable approach, I can open up a PR.

@mxschmitt
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants