擅长:python、mysql、java
<p>答案已经在最近的一篇文章中找到:<br/>
<a href="https://stackoverflow.com/questions/32728302/change-language-on-firefox-with-selenium-python">Change language on Firefox with Selenium Python</a></p>
<p>代码如下:</p>
<pre><code>def get_webdriver(attempts=3, timeout=60, locale='en-us'):
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("intl.accept_languages", locale)
firefox_profile.update_preferences()
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
</code></pre>