pytest-dev / pytest-selenium

Plugin for running Selenium with pytest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pytest ignores driver selection

martinschorb opened this issue · comments

Dear all,
executing a test with

pytest -k test_function --driver Firefox --driver-path /path/to/geckodriver

fails with:

...
File "xxx/python3.9/site-packages/selenium/webdriver/common/service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home

Opening a Firefox webdriver in a Python CLI from the same env works fine.

What could be the reason for it to request Chrome?
Thanks for your help!

What versions of pytest-selenium and pytest are you using? What OS?

Does it work without -k?

Have you tried both relative and absolute path to the driver?

Also, according to your example, you're specifying the path to "geckodriver" and not "chromedriver".

Dear @BeyondEvil ,

  • without -k it passes all tests that do not require a web driver but fails with the same error for the rest.

  • it also fails when providing the relative path to the driver

Also, according to your example, you're specifying the path to "geckodriver" and not "chromedriver".

That's exactly what I am struggling with. I like it to use Firefox but it insists on looking for Chrome.
Isn't --driver Firefox --driver-path /path/to/geckodriver enough to make it use Firefox?

OK, I found out that --webdriver is the appropriate parameter to be used. This is because I am not using pytest-selenium independently but through dash-testing.

Sorry for the confusion. I wasn't aware that it introduces different parameters.