【问题标题】:Problem connecting to localhost with watir使用 Watir 连接到 localhost 时出现问题
【发布时间】:2011-02-25 12:55:40
【问题描述】:

我有一组黄瓜测试通常在我们的网站上运行良好。但是,如果我进行任何更改并希望在本地运行测试,测试会立即失败,甚至在初始页面完成加载之前也是如此。

我在没有黄瓜的情况下尝试 IRB 并得到相同的错误,使用以下代码:

require 'rubygems'
require 'watir'

browser = Watir::Browser.new
browser.goto("http://localhost:1234/somepath")

browser.text_field(:id, 'Username').set('jimbob')

失败并显示以下内容:

WIN32OLERuntimeError: unknown property or method `document'
    HRESULT error code:0x800706b5
      The interface is unknown.
        from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/ie-class.rb:467:in `method_missing'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/ie-class.rb:467:in `document'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/container.rb:836:in `locate_input_element'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/input_elements.rb:5:in `locate'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/element.rb:55:in `assert_exists'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/input_elements.rb:366:in `set'

版本:

  • 操作系统:Windows 7
  • 浏览器:IE8
  • Ruby:1.8.7(我尝试使用 1.9.2,但没有问题)
  • 女仆:1.7.1

【问题讨论】:

  • 那是准确的复制/粘贴吗?你错过了一个报价。
  • 不,这不是复制/粘贴...但感谢您的关注!看起来 Adam Tegen 已经更新了它。

标签: ruby internet-explorer-8 watir


【解决方案1】:

在对 localhost 使用 Watir 时,您需要在 Windows 7 上以管理员身份运行。

感谢http://chowamigo.blogspot.com/2010/03/setting-up-cucumber-to-use-watir-test.html

【讨论】:

  • 呃!很棒的收获!我不敢相信 是挂断。谢谢!
【解决方案2】:

同样的事情适用于 Server2008 顺便说一句,必须以管理员身份运行命令行窗口才能使 watir 正常工作。我敢肯定,这与 IE 安全有关。

【讨论】: