进行 Cucumber/Watir 测试以测试图像旋转器/循环是否正常工作。我的策略是通过 css 类抓取旋转器中的活动图像并将其转储到变量中。然后我单击下一个按钮并通过 css 类在旋转器中抓取活动图像(现在应该是新图像)并将其转储到第二个变量中。然后我应该可以说 img_rot_1 != img_rot_2 并让测试返回真或假。这是我遇到麻烦的部分。
我是 Ruby 新手,所以我可能会遗漏一些简单的东西。这是测试。
require 'step_definition/setup'
test_setup = Wsetup.new 'http://loginurl', 'uname', 'pass' # browser object created here as # test_setup.b
img_rot_1 = String.new
img_rot_2 = String.new
When /^I click the next image button$/ do
test_setup.do_login
test_setup.b.goto('http://psu.dev1.fayze2.com/node/56')
img_rot_1 = test_setup.b.li(:class => 'flex-active-slide').img.src
test_setup.b.link(:class => 'flex-next').click
end
Then /^the rotator should move to the next image$/ do
img_rot_2 = test_setup.b.li(:class => 'flex-active-slide').img.src
img_rot_1 != img_rot_2
end
img_rot_1 != img_rot_2 和 img_rot_1 == img_rot_2 都通过了 - 那么我错过了什么?