page.should have_content - 导致错误的特殊字符 [英] page.should have_content - Special Characters causing error

查看:36
本文介绍了page.should have_content - 导致错误的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Capybara 进行基本的 Rspec 测试,该测试可打开网页并检查主页中是否包含字符串.这些测试需要检查网站上 8 个不同语言子域中的每一个,而我遇到了代码中特殊字符的一些问题.

I am working on a basic Rspec test using Capybara that opens a webpage and checks that a string is contained within the home page. The tests require checking eaching of 8 different language sub domains on the sites and I have run into some problems with the special characters in the code.

以下代码有效:

it "should have an American Home page", :js => true do
  visit '/'
  page.should have_content('Workforce Management from InVision')
end

it "should have an English Home page", :js => true do
  visit '/uk/'
  page.should have_content('Workforce Management from InVision')
end

以下代码不起作用

it "should have a Spanish Home page at '/es/callcenter'", :js => true do
  visit '/es/'
  page.should have_content('Gestión de la plantilla con InVision')
end

我认为这与Gestión"一词中的 ó 有关.任何想法如何阻止这个问题的发生?

I think that this is in relation to the ó in the word "Gestión". Any ideas how to stop this problem from occurring?

推荐答案

尝试在规范文件的第一行添加 # encoding: UTF-8.

Try adding # encoding: UTF-8 on the first line of the spec file.

这篇关于page.should have_content - 导致错误的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆