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

robot tests & firefox profiles #1786

Open
return42 opened this issue Dec 23, 2019 · 2 comments
Open

robot tests & firefox profiles #1786

return42 opened this issue Dec 23, 2019 · 2 comments
Labels
doc

Comments

@return42
Copy link
Collaborator

@return42 return42 commented Dec 23, 2019

My default (initial) firefox profile does not match the profile expected from the robot tests. Its a bit unusual, so lets start with the error message I got from the test:

$ LANG=C ./manage.sh robot_tests
[!] Running robot tests
...
Error occured: Traceback (most recent call last):
...
  File "~/searx/tests/robot/__init__.py", line 17, in test_404
    assert browser.is_text_present('Page not found')
...
selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None
Message: Dismissed user prompt dialog: Wenn Sie Ihre bevorzugte Sprache in Englisch ändern..

Here we have (system wide) a branded FFox profile (maintained by the admin). It consists of:

If I run the browser session interactive

>>> from splinter import Browser
>>> b = Browser('firefox')

I see the (german) dialog pops up, asking me if I prefer EN language for privacy reason: Wenn Sie Ihre bevorzugte Sprache in Englisch ändern..

This message appears every time a FFox Instance is started initial (without a profile). This is also, what happens when running the robot tests.

To continue work and running test, for the first I removed the /etc/firefox/syspref.js which is a good interim solution. On the long term, we should prefer a solution (test setup) which does not depend on a local (branded) profile.

I researched a bit and fond this:

ATM i am a bit baffled, I even do not know if I on the wrong track .. any ideas?

Thanks for any suggestion.

@dalf

This comment has been minimized.

Copy link
Collaborator

@dalf dalf commented Dec 23, 2019

Looking at:
https://github.com/cobrateam/splinter/blob/master/splinter/browser.py#L71

Browser function is basically:

def Browser(driver_name="firefox", retry_count=3, *args, **kwargs):
    return get_driver(FirefoxWebDriver, *args, **kwargs)

I don't if it can help : https://github.com/dalf/searx-stats2/blob/1ba4191b6815325b7268dfeffe11990632fc9162/searxstats/fetcher/external_ressources.py#L32

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

    ...
    firefox_profile = webdriver.FirefoxProfile()
    firefox_profile.set_preference('browser.preferences.instantApply', True)
    ...
    firefox_profile.update_preferences()
    options = Options()
    options.add_argument('--headless')

    driver = webdriver.Firefox(options=options,
                               firefox_profile=firefox_profile,
                               service_log_path=get_geckodriver_file_name())

Not sure if it is possible to ignore the .js file, but at least to replace the important values.

@return42

This comment has been minimized.

Copy link
Collaborator Author

@return42 return42 commented Dec 23, 2019

@dalf thanks for your suggestions ..

I digged a bit deeper, from what I can say now:

  1. robot test needs firefox installed on the system // BTW we should add some hints about test environment to the docs

Is there a way to install local firefox binary which is used only by the test environment and does not depend on the firefox from the package manager?

  1. firefox from (debian, ubuntu ..) package managers are always start using system profiles (/etc/firefox & /usr/lib/firefox-addons/)

Is there a (simple) way to fake /etc/firefox & /usr/lib/firefox-addons/ (e.g. chroot) or do some mozilla variables (MOZ_XYZ_ENVIRON) exit for these paths?

@return42 return42 added the doc label Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.