run pytest with seleniumbase failed: "argparse.ArgumentError: argument --variables: conflicting option string: --variables"

23 views Asked by At

when running a test case, it gives this error whereas if I only use Selenium it works properly and test case gets executed

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

There are 1 answers

1
Michael Mintz On

The conflicting option string, --variables, means that you have at least two different pytest plugins installed that are initializing the --variables option. pytest options can only be initialized once. This means you have to uninstall one of plugins.

By calling pytest -h, you can see which plugins the --variables option is being initialized from.

You also avoid this issue by installing dependencies into separate Python virtual environments. In your case, the pytest plugins that initialize --variables (one is SeleniumBase) should be separated.

Virtual Environment tutorial: https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment