我试图在我的confest.py
中添加pytest_addoption(parser)
。Here are the official Pytest docs
但如果我试着开始测试我明白了
TypeError: __init__() got an unexpected keyword argument 'browser'
Confest.py
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)
解决方案
您应该使用
Application(browser)
(在忏悔.py). 在另一个类似的问题:__init__() got an unexpected keyword argument 'user'
解释
当您生成
Application(browser=browser)
时,您正试图使用keyword parameters。在带关键字参数的示例
相关问题 更多 >
编程相关推荐