Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting firefox-profile in conftest #95

Closed
fspinillo opened this issue Feb 7, 2017 · 2 comments
Closed

Setting firefox-profile in conftest #95

fspinillo opened this issue Feb 7, 2017 · 2 comments

Comments

@fspinillo
Copy link

fspinillo commented Feb 7, 2017

I'm currently setting the profile via command line with --firefox-profile=PATH, but am wondering if it is possible to do so with a fixture. I was looking through the codebase and saw --firefox-path is set via firefox-profile in pytest_selenium.py. I also saw this ticket relating to defining preferences #86

So I set up my fixture like so, but it seems to not use the correct profile

@pytest.fixture
def firefox_profile(firefox_profile):
    firefox_profile = '[PATH]'
    return firefox_profile

Edit: So it turns out the set up I have in conftest works fine, the issue is being caused by an additional pytest_addoption I'm passing through.

@davehunt
Copy link
Contributor

davehunt commented Feb 7, 2017

These fixtures are not currently documented, which I should fix. It's actually a better way to specify a profile than using the command line. The important thing to note is that firefox_profile in this case is a FirefoxProfile object, and if you don't need to modify that, then you don't need to include it in the method signature of your fixture. Here are a few ideas to try, and if you're interested in helping to improve the docs, that would be awesome:

@pytest.fixture
def firefox_profile():
    return '[PATH]'

This should work, because if the profile is a string, then a new FirefoxProfile object should be created from it. Alternatively, you could try:

from selenium.webdriver import FirefoxProfile

@pytest.fixture
def firefox_profile():
    return FirefoxProfile('[PATH]')

@fspinillo
Copy link
Author

Thanks @davehunt those work as well. The issue I'm running into has to do with my own pytest_addoption I'm calling for handling production vs branch urls. I noticed pytest-selenium has a plugin for just this feature so I'm working on converting over to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants