当需要oci8时脚本失败

时间:2012-12-12 19:49:04

标签: ruby watir-webdriver oci8

我是ruby的新手,我有这个奇怪的问题。我在64位Win7上安装了ruby 1.9.3p125,Oracle11gXE(版本11.2.0.2.0)。我能够毫无问题地运行这个脚本:

require 'watir-webdriver'
browser = Watir::Browser.new
browser.close

还有这个脚本:

require 'oci8'
conn = OCI8.new('username/passwd')
conn.logoff

但是一旦我这样做了:

require 'watir-webdriver'
require 'oci8'
browser = Watir::Browser.new
browser.close

事情出错了 - 我收到了这个错误:

C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': 193: %1 is not a valid Win32 application.   - C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/openssl.so (LoadError)
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/1.9.1/openssl.rb:17:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/1.9.1/net/https.rb:22:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/default.rb:1:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote.rb:9:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/firefox/bridge.rb:6:in `<module:Firefox>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/firefox/bridge.rb:3:in `<module:WebDriver>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/firefox/bridge.rb:2:in `<module:Selenium>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/firefox/bridge.rb:1:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/firefox.rb:12:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/common/driver.rb:31:in `for'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver.rb:65:in `for'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/browser.rb:35:in `initialize'
        from problem.rb:3:in `new'
        from problem.rb:3:in `<main>'
Press any key to continue . . .

另一方面,这很好用:

require 'watir-webdriver'
require 'oci8'
conn = OCI8.new('username/passwd')
conn.logoff
你可以帮我解决这个问题吗?当'oci8'需要时,似乎'watir-webdriver'有一些问题。但这可能是错误的假设 - 可能是一些配置问题。谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

请尝试以下代码。

require 'watir-webdriver'
require 'openssl' # <-- Add this line to load openssl.so before oci8.
require 'oci8'
browser = Watir::Browser.new
browser.close

加载openssl.so时会引发LoadError。 就我测试而言,在oci8之后加载openssl会产生相同的错误,并且反向工作正常。