运行 RSpec/Watir 脚本异常终止
我正在使用 Ruby 1.8.6、Watir 1.6.6 和 RSpec 1.3.0。当我运行以下脚本时,它“终止”(EclipsePDT IDE 中给出的术语),但没有列出错误。当我从 Windows 上的 c 提示符运行它时,除了没有“终止”之外,情况也是如此。浏览器永远不会打开。有人有线索吗?如果我去掉describe、it和end行,它运行正常。
describe 'FaceBook' do
before :all do
@b = Watir::Browser.new
@b = Watir::IE.start('http://www.facebook.com')
end
it 'Default Page links' do
@b.link(:class, 'fbxWelcomeBoxName').text.should == 'Dave McNulla'
@b.link(:href, 'http://www.facebook.com/?ref=home').text.should == 'Home'
@b.link(:href, 'http://www.facebook.com/dave.mcnulla').text.should == 'Profile'
end
it 'Home Page links' do
@b.link(:href, 'http://www.facebook.com/?ref=home').click
@b.link(:href, 'http://www.facebook.com/?ref=home').text.should == 'Home'
@b.link(:href, 'http://www.facebook.com/dave.mcnulla').text.should == 'Profile'
end
it 'Profile Page links' do
@b.link(:text, 'Profile').click
@b.link(:href, 'http://www.facebook.com/?ref=home').text.should == 'Home'
@b.link(:href, 'http://www.facebook.com/dave.mcnulla').text.should == 'Profile'
end
after :all do
@b.close
end
end
I am using Ruby 1.8.6, Watir 1.6.6, and RSpec 1.3.0. When I run the following script, it "terminates" (term given in EclipsePDT IDE) but no error is listed. Same when I run it from the c-prompt on windows, except no "terminate". The browser never opens. Anybody got a clue? It runs OK if I take off the describe, it, and end lines.
describe 'FaceBook' do
before :all do
@b = Watir::Browser.new
@b = Watir::IE.start('http://www.facebook.com')
end
it 'Default Page links' do
@b.link(:class, 'fbxWelcomeBoxName').text.should == 'Dave McNulla'
@b.link(:href, 'http://www.facebook.com/?ref=home').text.should == 'Home'
@b.link(:href, 'http://www.facebook.com/dave.mcnulla').text.should == 'Profile'
end
it 'Home Page links' do
@b.link(:href, 'http://www.facebook.com/?ref=home').click
@b.link(:href, 'http://www.facebook.com/?ref=home').text.should == 'Home'
@b.link(:href, 'http://www.facebook.com/dave.mcnulla').text.should == 'Profile'
end
it 'Profile Page links' do
@b.link(:text, 'Profile').click
@b.link(:href, 'http://www.facebook.com/?ref=home').text.should == 'Home'
@b.link(:href, 'http://www.facebook.com/dave.mcnulla').text.should == 'Profile'
end
after :all do
@b.close
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我终于发现 RSpec 测试脚本是通过在命令行上调用“spec”来运行的,如下所示:
我假设我通过调用 Ruby 来运行它们,就像我在 TestUnit 文件上所做的那样。
现在我需要弄清楚如何从 Eclipse PDT 中调用“spec”。感谢所有提出想法的人。我更欣赏它,因为我一开始就没有很好地表达我的问题。
戴夫
I finally found out that RSpec test scripts run from calling 'spec' on the command line as in:
I had assumed that I ran them by calling Ruby, as I had done on TestUnit files.
Now I need to figure out how to call 'spec' from within Eclipse PDT. Thanks to everybody that brought in ideas. I appreciate it even more because I did a poor job of presenting my problem in the first place.
Dave
我发现的一个问题是您打开了两个浏览器。我会将其替换
为:
One problem I see is that you open two browsers. I would replace this:
with:
如果您将其添加到
before :all
块是否有帮助:当我需要 rubygems 和 watir 时,您的代码会在我的机器上打开浏览器。
Does it help if you add this to
before :all
block:Your code opens the browser at my machine when I require rubygems and watir.
我添加了一些 put 语句来查看哪些部分正在运行以及哪些部分从未到达:
输出:
显然,测试用例的块没有运行。
I added some puts statements to see which parts were running and which parts were never arrived at:
Output:
Apparently, the blocks for the test cases is not running.