在Ruby Watir - WebDriver中,尝试将一个类的方法调用到另一个类中,会产生错误

时间:2011-02-10 18:37:28

标签: watir

这是我的第一堂课,我将其命名为Login.rb

require 'watir-webdriver'
require 'test/unit'
require 'test/unit/ui/console/testrunner'

module Loukya
  class TestGoogle < Test::Unit::TestCase
    def test_watir_search(url, link, loginID)
      mobilityServer = url
      backEnd = link
      userID = loginID
      shortSleep  = 02  
      longSleep   = 15  
      @ie = Watir::Browser.new :chrome
      sleep(longSleep)
      @ie.goto mobilityServer + '/mobileItsmWebApp/user/index#_login'
      @ie.image(:src, '/mobileItsmWebApp/images/icons/DownArrow20x20.png').click
      @ie.link(:text, 'Settings').click
      @ie.link(:text, 'Server').click
      @ie.link(:text, 'Add URL').click
      @ie.text_field(:name, 'serverUrl').set backEnd
      @ie.link(:text, 'Add URL').click
      @ie.text_field(:name, 'username').set userID
      @ie.link(:text, 'Log In').click
      sleep(shortSleep)
      assert(@ie.text.include?("Home"))
    end
  end
end

这是我的第二堂课,我将其命名为Incident.rb

require 'watir-webdriver'
require 'test/unit'
require 'test/unit/ui/console/testrunner'
require 'C:\Users\challagl\Desktop\mobility team\Automated Tests\New Folder\Login'

class TestIncident < Test::Unit::TestCase
  def test_ci
    wcf = Loukya::TestGoogle.new
    wcf.test_watir_search("http://localhost:8080", "http://15.80.162.12:13080", "Incident.Manager")
  end
end

当我运行第二堂课时,我收到以下错误,请帮帮我。感谢。

>ruby Incident.rb
Loaded suite Incident
Started
FE
Finished in 0.002 seconds.

  1) Failure:
default_test(Loukya::TestGoogle) [Incident.rb:11]:
No tests were specified.

  2) Error:
test_ci(TestIncident):
ArgumentError: wrong number of arguments (0 for 1)
    Incident.rb:12:in `initialize'
    Incident.rb:12:in `new'
    Incident.rb:12:in `test_ci'

2 tests, 1 assertions, 1 failures, 1 errors
>Exit code: 1

1 个答案:

答案 0 :(得分:0)

我认为问题在于您创建了一个类型为testcase的类,但它没有测试。

为了有效,testcase需要包含一个断言