我在我的代码中使用了Capybara,Selenium和Chrome,我才意识到代码在具有非英语语言环境的计算机上失败(因为Chrome正在请求使用不同语言的页面)。
我如何强迫英语成为唯一被接受的语言?
答案 0 :(得分:2)
您需要在驱动程序注册中设置配置文件首选项或专用配置文件类:
profile = Selenium::WebDriver::Chrome::Profile.new
profile['intl.accept_languages'] = 'en'
Capybara::Selenium::Driver.new(app, browser: :chrome, profile: profile, ...other)