English 中文(简体)
Watir 试图匹配版权声明时出错
原标题:Error with watir trying to match copyright statement

Hi Im using watir with rspec and running into problem with the frong with the frong matter of the frong of the full of code. 我使用有胸肌的瓦蒂尔语 并遇到以下的代码块的问题:

I cant understand what Im doing wrong. The exact error I get is "syntax error, unexpected $end, expecting keyword_end @b.text.include? "Ark © 1"

describe "Copyright statement" do 
   it "should exist" do 
    @b.text.include? "Ark © 1"
   end
end

任何帮助都会感激不尽 谢谢

最佳回答

我在网上找到一个解决方案, 搜索错误“ 强” 无效的多字节字符( US- ASCII) ”

将此行添加到顶部有助于对版权声明的帮助!

# encoding: UTF-8

它只是文件顶部的一个简单评论, 但它解决了版权特性和Rspec/Ruby 1.9的问题。

感谢大家的帮助和支持 我真的很感激!

问题回答

我觉得你的缩进表已经偏离了第一端 需要另一个空间排队

describe "Copyright statement" do 
   it "should exist" do 
    @b.text.include? "Ark © 1"
   end 
end

@ChuckvanderLinden和我认为真正的问题在于你失踪和结束, 但看不到文件的其余部分, 我们无法肯定。

我确实从Dave Thomas那里 找到了这个消息

http://pragdave.blogs.pragprog.com/pragdave/2008/12/ruby-19-can- check-our-indentation.html" rel=“nofollow”>http://pragdave.blogs.pragprog.com/pragdave/2008/12/ruby-19-can-check-our-indentation.html

如果您用 -w 标记运行文件, 它将会让你更好地了解问题所在, 以及您代码中的确切位置 。

ruby -w samplefile.rb

这将给您类似以下输出的输出 :

t.rb:5: warning: mismatched indentations at  end  with  if  at 3
t.rb:9: warning: mismatched indentations at  end  with  def  at 2
t.rb:10: syntax error, unexpected $end, expecting keyword_end

更容易定位出错地点

@steveRobillard 在他的回复中处理了缺失的最终错误信息, 但是您在如何试图使用 rspec 方面还有另一个大问题。 问题在于您没有真正做任何事情 。 包括吗? 方法? 方法, 因为没有 。 您的代码正在执行该方法, 但只是有效地将返回到比特桶的真假丢弃。 此测试永远不会失败, 因为您缺少任何验证 。 我认为这条线需要更近一点 。

describe "Copyright statement" do 
   it "should exist" do 
     @b.text.should include "Ark © 1"
   end 
end     

纠正这个可能不会解决你遗漏的终点问题, 但是如果没有类似的东西, 你的测试实际上不是在测试任何东西。

另外,如果是我的话,我不仅希望看到版权在 html的某个地方, 而且在某个特定的地方,比如脚脚, 通常在某种容器里,比如div。如果div有脚脚的ID, 那么那部分代码就会是这样的。

it "should be found within the footer" do
  @browser.div(:id =>  footer ).text.should include  copyright © Yoyodyne 1984 
end

观察Watir使用的 spec 的好方法是查看 watir 本身的 spec 文件,例如 div 元素的外观和它应该做的一切测试,例如 < a href=> https://github.com/watir/watir/watirspec/blob/master/div_spec.rb" rel=“nofollow> > https://github.com/watir/watirspec/blob/master/div_spec.rb





相关问题
Selenium not working with Firefox 3.x on linux

I am using selenium-server , selenium rc for UI testing in my application . My dev box is Windows with FireFox 3.5 and every thing is running fine and cool. But when i try to run selenium tests on my ...

Best browser for testing under Safari Mobile on Linux?

I have an iPhone web app I m producing on a Linux machine. What s the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It s a "slimmed down" ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Is there any error checking web app cralwers out there?

Wondering if there was some sort of crawler we could use to test and re-test everything when changes are made to the web app so we know some new change didn t error out any existing pages. Or maybe a ...

热门标签