在Capybara + Selenium + Chrome

时间:2016-06-28 08:04:12

标签: capybara selenium-chromedriver

我在我的代码中使用了Capybara,Selenium和Chrome,我才意识到代码在具有非英语语言环境的计算机上失败(因为Chrome正在请求使用不同语言的页面)。

我如何强迫英语成为唯一被接受的语言?

1 个答案:

答案 0 :(得分:2)

您需要在驱动程序注册中设置配置文件首选项或专用配置文件类:

profile = Selenium::WebDriver::Chrome::Profile.new
profile['intl.accept_languages'] = 'en'

Capybara::Selenium::Driver.new(app, browser: :chrome, profile: profile, ...other)