0

我是 Ruby 新手,正在运行这个测试:

require 'selenium-webdriver' 
require 'capybara' 
require 'capybara/cucumber' 
require 'rspec/expectations' 
require 'test/unit'


driver = Selenium::WebDriver.for :firefox 
 Capybara.default_driver = :selenium

 Given /^I am on the homepage$/ do
 driver.navigate.to "http://testurl:8080/" 
 end

When(/^I enter admin authentication$/) do 
usrname = > driver.find_element(:name, 'username') 
usrname.send_keys "admin" 
puts "Username Entered" 
passwd = driver.find_element(:name, 'password')
passwd.send_keys "admin" 
puts "Password Entered" 
passwd.submit 
puts "Details Submitted" 
end

Then(/^I should be on the homepage$/) do
 sleep 5 
displayName = driver.find_element(:id, 'prefs_menu') 
assert displayName.text == "Administrator" #
puts "Correct User Display Name" 
end

我不断收到错误

 undefined method `assert' for #<Object:0x2895258> (NoMethodError) ./features/login_steps.rb:42:in `/^I should be on the homepage$/' features\login.feature:10:in `Then I should be on the homepage'

它可能是我完全忽略的东西 - 但有什么帮助吗?

4

1 回答 1

0

尝试这个

assert(displayName.text == "Administrator")
于 2013-10-02T15:41:44.027 回答