【问题标题】:JRuby Watir phantomjs exception Unknown error (Windows says "The operation completed successfully.", but it did not.)JRuby Watir phantomjs 异常未知错误(Windows 说“操作成功完成。”,但它没有。)
【发布时间】:2014-04-24 21:12:56
【问题描述】:

尝试通过 phantomjs 驱动程序使用 JRuby 和 watir-webdriver 并获得以下异常。适用于 :chrome 和 :firefox 但使用 :phantomjs 失败。在同事的机器上也试过这个,如果失败了。可以在 JRuby 上使用 webdriver/phantomjs 吗?

详情如下:

jruby 1.7.12 (1.9.3p392) 2014-04-15 643e292 on Java HotSpot(TM) 64-Bit Server VM 1.7.0-b147 [Windows 7-amd64]

watir-webdriver (0.6.9)

phantomjs -v
1.9.7

irb(main):001:0> require 'watir-webdriver'
=> true
irb(main):002:0> b = Watir::Browser.new :phantomjs
ChildProcess::Error: Unknown error (Windows says "The operation completed successfully.", but it  did not.)
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/childprocess-    0.5.3/lib/childprocess/windows/lib.rb:325:in `handle_for'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/childprocess-0.5.3/lib/childprocess/jruby.rb:48:in `windows_handle_for'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/childprocess-0.5.3/lib/childprocess/windows/lib.rb:306:in `handle_for'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/childprocess-0.5.3/lib/childprocess/windows/process_builder.rb:137:in `std_stream_hadle_for'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/childprocess-0.5.3/lib/childprocess/windows/process_builder.rb:109:in `setup_io'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/childprocess-0.5.3/lib/childprocess/windows/process_builder.rb:32:in `start'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/childprocess-0.5.3/lib/childprocess/windows/process.rb:68:in `launch_process'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/childprocess-0.5.3/lib/childprocess/abstract_process.rb:82:in `start'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/selenium-webdriver-2.41.0/lib/selenium/webdriver/phantomjs/service.rb:42:in `start'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/selenium-webdriver-2.41.0/lib/selenium/webdriver/phantomjs/bridge.rb:20:in `initialie'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/selenium-webdriver-2.41.0/lib/selenium/webdriver/common/driver.rb:45:in `for'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/selenium-webdriver-2.41.0/lib/selenium/webdriver.rb:67:in `for'
    from C:/jruby-1.7.12/lib/ruby/gems/shared/gems/watir-webdriver-0.6.9/lib/watir-webdriver/browser.rb:46:in `initialize'
    from (irb):2:in `evaluate'
    from org/jruby/RubyKernel.java:1101:in `eval'
    from org/jruby/RubyKernel.java:1501:in `loop'
    from org/jruby/RubyKernel.java:1264:in `catch'
    from org/jruby/RubyKernel.java:1264:in `catch'
    from C:/jruby-1.7.12/bin/jirb:13:in `(root)'

【问题讨论】:

  • 这也是在 Windows 7 上
  • 你下载了 phantomjs 并把它放在了路径上的某个地方吗?
  • 实际上在仔细检查堆栈跟踪时,看起来 webdriver 正在使用子进程 gem,这是由于某种原因而窒息的原因

标签: selenium-webdriver phantomjs jruby watir-webdriver child-process


【解决方案1】:

这似乎与尝试在 Jruby 上运行子进程 gem 有关。这是我个人第一次看到这个问题,并且我在 jruby 上使用 watir-webdriver(以及 webdriver)运行了很多东西。但我没有尝试在我的浏览器中使用 phantomJS。

当我用 ruby​​ 1.9.3 尝试这个时,它对我有用

C:\Rubies>ruby --version
ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
C:\Rubies>irb
irb(main):001:0> require 'watir-webdriver'
=> true
irb(main):002:0> b = Watir::Browser.new :phantomjs
=> #<Watir::Browser:0x..f887d0e36 url="about:blank" title="">
irb(main):003:0> b.goto "http://google.com"
=> "http://www.google.com/"
irb(main):004:0> puts b.title
Google
=> nil

使用 Windows 8,当我尝试使用 Jruby 时,当前版本 1.7.19 和 9.0.0 的预发布版本都遇到了与您相同的错误。如上所示,Ruby 1.9.3 工作正常。我还尝试了 Ruby 2.0 (2.0.0p598) 和 2.1.5 (2.1.5p273) 的 64 位版本,它运行良好。 (尽管对于这两种情况,如果您在尝试安装或更新 gems 时遇到 ssl 错误,您可能需要manually update rubygems

我真的不知道问题是 jruby 还是子进程 gem,所以我不确定应该在哪里提交错误来修复这个问题。同时,如果你想使用phantomJS作为你的浏览器,我建议你不要使用jruby,直到可以追踪到故障原因并修复。

我将稍微编辑问题的标签,看看我们是否可以引起任何使用 Jruby 或相关 gem 的专家的注意。

PS 对于 Windows 用户,由于 PIC 现在不受支持并且 RVM 2.0 上的开发刚刚开始,我建议查看 URU 作为在 ruby​​ 版本之间快速移动的一种方法。

【讨论】:

  • 因为这适用于普通 ruby​​,我假设问题出在 jruby 上,并在该项目中提交了以下问题 github.com/jruby/jruby/issues/2598 您可以跟踪它以查看他们是否接受并解决问题跨度>
猜你喜欢
  • 2011-10-01
  • 1970-01-01
  • 2022-11-16
  • 2012-06-15
  • 2012-02-12
  • 2014-03-24
  • 2019-05-26
  • 2018-12-03
  • 1970-01-01
相关资源
最近更新 更多