运行pytest与seleniumbase失败:“argparse.ArgumentError: argument --variables: conflicting option string: --variables”
在运行测试用例时,出现了这个错误,而如果我只使用Selenium的话,它就能正常工作,测试用例也能顺利执行。
from selenium import webdriver
from seleniumbase import BaseCase
class OpenWebPageTest(BaseCase):
def test_open_webpage(self):
# Using Selenium WebDriver to open the webpage
driver = webdriver.Chrome()
driver.get('https://test01.rubiscape.io/#/auth/login-user')
self.assert_true("Example Domain" in driver.title)
# Using SeleniumBase to capture a screenshot
self.check_window(name="Initial_Window")
if __name__ == "__main__":
OpenWebPageTest().test_open_webpage()
1 个回答
0
出现了冲突的选项字符串 --variables
,这意味着你安装了至少两个不同的 pytest
插件,它们都在初始化这个 --variables
选项。pytest
的选项只能被初始化一次,所以你需要卸载其中一个插件。
你可以通过输入 pytest -h
来查看 --variables
选项是从哪些插件初始化的。
为了避免这个问题,你可以把依赖项安装到不同的 Python 虚拟环境中。在你的情况下,初始化 --variables
的 pytest
插件(其中一个是 SeleniumBase)应该分开安装。