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

--firefox-preferences option is not working properly #86

Closed
okulynyak opened this issue Oct 13, 2016 · 4 comments
Closed

--firefox-preferences option is not working properly #86

okulynyak opened this issue Oct 13, 2016 · 4 comments

Comments

@okulynyak
Copy link

When trying to use --firefox-preference from command line or from pytest.ini like this:
"C:\automated_test_scripts\tests>pytest -v -s --firefox-preference="browser.helperApps.neverAsk.openFile"="application/excel" test_login.py"
i got error:
usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument --firefox-preference: expected 2 argument(s).
I tried different combination and all the time i got the same error.
I using a synthax in command line from >pytest -h

@davehunt
Copy link
Contributor

Can you try --firefox-preference "browser.helperApps.neverAsk.openFile" "application/excel" (use spaces instead of =) and let me know if this works? I think this might be a bug in pytest.

@okulynyak
Copy link
Author

okulynyak commented Oct 14, 2016

Hi.
First of all want to Thank you for your time.
I tried to use "space" instead "=", and it works.
Finally i added line "addopts = --driver=Firefox --firefox-preference "plugin.state.java" "2" --firefox-preference "offline-apps.quota.warn" "5120000" --firefox-preference "dom.max_script_run_time" "90" --firefox-preference "pdfjs.disabled" "true" --firefox-preference "app.update.auto" "false" --firefox-preference "app.update.enabled" "false" --firefox-preference "browser.helperApps.neverAsk.saveToDisk" "text/csv,application/vnd.ms-excel,application/pdf" --firefox-preference "browser.helperApps.neverAsk.openFile" "application/jsp,application/jnlp,magnus-internal/jsp,application/x-java-jnlp-file" --firefox-preference "browser.download.panel.shown" "false" --firefox-preference "browser.download.folderList" "2" --firefox-preference "browser.download.manager.showWhenStarting" "false" --firefox-preference "plugin.disable_full_page_plugin_for_types" "application/pdf,application/vnd.adobe.xfdf,application/vnd.fdf,application/vnd.adobe.xdp+xml,application/pdf,application/jsp,magnus-internal/jsp" --instafail --reruns=0" to pytest.ini and it works fine.
I checked.
Thanks a lot.
One more, this would be fixed in future?

@davehunt
Copy link
Contributor

Wow, that's a lot of options to add! You can also override the firefox_profile fixture in a conftest.py file to add these preferences. It would look something like:

import pytest
@pytest.fixture
def firefox_profile(firefox_profile):
    firefox_profile.set_preference('plugin.state.java', '2')
    firefox_profile.set_preference('offline-apps.quota.warn', '5120000')
    ...
return firefox_profile

Note that soon you will be able to set preferences via capabilities. At that point I'm likely to deprecate the firefox_profile and --firefox-preference features in favour of using capabilities. This would be a major release though, and will ultimately allow you to do something like:

import pytest
@pytest.fixture
def capabilities(capabilities):
    capabilities['moz:firefoxOptions'] = {
        'prefs': {
            'plugin.state.java': '2'.
            'offline-apps.quota.warn': '5120000'}}
return capabilities

For your original issue, this is likely a bug in pytest, so please raise a new issue here: https://github.com/pytest-dev/pytest

@okulynyak
Copy link
Author

Thanks a lot. it works! i wil report a bug to pytest.

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