使用 Selenium Python 更改 Firefox 上的语言

Dru*_*ala 5 python selenium locale webdriver remotewebdriver

我正在尝试将 Selenium Webdriver Firefox 的语言从英语更改为西班牙语。

我有以下代码:

def get_webdriver(attempts=3, timeout=60):
  firefox_profile = webdriver.FirefoxProfile()
  firefox_profile.set_preference("intl.accept_languages", "es-es")

  desired_capabilities = getattr(
      DesiredCapabilities, "FIREFOX").copy()

  hub_url = urljoin('http://hub:4444', '/wd/hub')
  driver = webdriver.Remote(
    command_executor=hub_url, desired_capabilities=desired_capabilities,
    browser_profile=firefox_profile)

  return driver
Run Code Online (Sandbox Code Playgroud)

但是,返回的司机仍然是英语而不是西班牙语。我错过了什么?如何将语言设置为西班牙语?

Jos*_*rah -1

我对 Selenium 不太了解,但根据我的研究,您可能使用了错误的语言关键字。从这个链接

https://groups.google.com/forum/#!topic/nightwatchjs/qwtLPIAJa_c

看起来应该是QASpanish而不是es-es。您是否检查过以确保使用了正确的关键字?