标签: pytest-selenium

如何通过命令行将 firefox/chrome 无头模式传递给 pytest

我需要以无头模式远程运行我的硒测试用例。

目前,我正在 py.test 命令下运行

py.test --driver remote --host selenium.host --port 4444 --capability browserName firefox --capability platform LINUX
Run Code Online (Sandbox Code Playgroud)

对于无头模式,我需要在conftest.py文件中处理它

但我需要在命令行中使用该选项,而不是在conftest.py文件中处理该选项

@pytest.fixture
def chrome_options(chrome_options):
    chrome_options.add_argument('--headless')
    return chrome_options


@pytest.fixture
def firefox_options(firefox_options):
    firefox_options.add_argument('-headless')
    return firefox_options
Run Code Online (Sandbox Code Playgroud)

python selenium pytest pytest-selenium

5
推荐指数
1
解决办法
4092
查看次数

标签 统计

pytest ×1

pytest-selenium ×1

python ×1

selenium ×1