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)