1

I am running local Selenium Behave tests on Firefox for a Django / Python project. My Firefox browser is set to English and I visit my local website via the browser manually everything is in English. However, when I run the Behave tests with Selenium, the browser is in German, as well as the standard language selected on my website. When I use the fix in this thread it changes the browser language to English but not the default language of the website. This would be the code of the before_all script:

from selenium.webdriver import Firefox, FirefoxOptions
from selenium.webdriver.support.ui import WebDriverWait

def before_all(context):
    """Run once before any testing begins."""
    options = FirefoxOptions()
    options.set_preference('intl.locale.requested', 'en')
    options.headless = False
    context.driver = Firefox(options=options)
    context.driver.implicitly_wait(5)
    context.driver.set_window_size(1024, 768)
    context.wait = WebDriverWait(context.driver, 30)

    logging.disable(logging.ERROR)

(The problem is that the behave tests do not find the German button texts)

Haggerboy
  • 11
  • 3
  • 1
    It doesn't look like you used the solution from the linked answer. Django sets the language based on the `Accept-Language` header sent by the browser. I don't know what `intl.locale.requested` does. – Håken Lid May 24 '22 at 09:33
  • Ah so I used a fix from another thread that said to use intl.locale.requested and I seem to have over-read it as being the same in the linked thread. Thank you so much for pointing that out. – Haggerboy May 27 '22 at 08:02

0 Answers0