confest.py
에 pytest_addoption(parser)
을 추가하려고합니다. Here are the official Pytest docsPytest TypeError : __init __()에 '브라우저'라는 예상치 못한 키워드가 있습니다.
내가 테스트를 시작하려고하지만 내가 볼
TypeError: __init__() got an unexpected keyword argument 'browser'
Confest.py
import pytest
from fixture.application import Application
__author__ = 'Max'
fixture = None
@pytest.fixture
def app(request):
global fixture
browser = request.config.getoption("--browser")
if fixture is None:
fixture = Application(browser=browser)
else:
if not fixture.is_valid:
fixture = Application(browser=browser)
fixture.session.ensure_login(username="somename", password="somepassword")
return fixture
def pytest_addoption(parser):
# hooks for browsers
parser.addoption("--browser", action="store", default="chrome")
fixture/application.py
from selenium import webdriver
class Application:
def __init__(self,browser):
if browser == "chrome":
self.wd = webdriver.Chrome()
elif browser == "firefox":
self.wd = webdriver.Firefox()
else:
raise ValueError("Unrecognized browser %s" % browser)
들여 쓰기를 검토하십시오; 그것은 파이썬에서 중요합니다. – jonrsharpe