代码执行得很好,但是,处理这种简单的代码要花很多时间
require 'watir'
browser = Watir::Browser.new :firefox
browser.goto "https://google.com"
这是OCRA进程的命令行日志,当我离开它一个小时之后,我不得不通过CTRL + C退出代码,但从未产生任何结果。有什么想法吗?
=== Loading script to check dependencies
=== Attempting to trigger autoload of Gem::ConfigFile
=== Attempting to trigger autoload of Gem::DependencyList
=== Attempting to trigger autoload of Gem::DependencyResolver
=== Attempting to trigger autoload of Gem::Installer
=== Attempting to trigger autoload of Gem::Licenses
=== Attempting to trigger autoload of Gem::Source
=== Attempting to trigger autoload of Gem::RequestSet
=== Attempting to trigger autoload of Gem::SpecFetcher
=== Attempting to trigger autoload of Gem::SourceList
=== Attempting to trigger autoload of RubyInstaller::Runtime::Components::Base
=== WARNING: RubyInstaller::Runtime::Components::Base was defined autoloadable,
but caused NameError
=== Attempting to trigger autoload of RubyInstaller::Runtime::Colors
=== Attempting to trigger autoload of RubyInstaller::Runtime::ComponentsInstalle
r
=== Attempting to trigger autoload of RubyInstaller::Runtime::Ridk
=== Attempting to trigger autoload of RubyInstaller::Runtime::PACKAGE_VERSION
=== Attempting to trigger autoload of Selenium::WebDriver::Chrome
=== Attempting to trigger autoload of Selenium::WebDriver::Edge
=== Attempting to trigger autoload of Selenium::WebDriver::IE
=== Attempting to trigger autoload of Selenium::WebDriver::PhantomJS
=== WARNING: Selenium::WebDriver::PhantomJS was not loadable
=== Attempting to trigger autoload of Selenium::WebDriver::Safari
=== Attempting to trigger autoload of Selenium::WebDriver::Support
=== Attempting to trigger autoload of CGI::HtmlExtension
=== Detected gem did_you_mean-1.1.0 (loaded, files)
=== 14 files, 32780 bytes
=== Detected gem ocra-1.3.10 (loaded, files)
=== 5 files, 210830 bytes
=== Detected gem rubyzip-1.2.1 (loaded, files)
=== 36 files, 92674 bytes
=== Detected gem ffi-1.9.25-x64-mingw32 (loaded, files)
=== 70 files, 1785972 bytes
=== Detected gem childprocess-0.9.0 (loaded, files)
=== 19 files, 43107 bytes
=== Detected gem selenium-webdriver-3.13.0 (loaded, files)
=== 120 files, 1191026 bytes
=== Detected gem watir-6.11.0 (loaded, files)
=== 97 files, 280749 bytes
=== Detected gem json-2.1.0 (loaded, files)
=== 37 files, 1721174 bytes
=== Detected gem openssl-2.0.7 (loaded, files)
=== WARNING: Gem openssl-2.0.7 root folder was not found, skipping
=== Detected gem psych-2.2.2 (loaded, files)
=== WARNING: Gem psych-2.2.2 root folder was not found, skipping
=== Detected gem watir-scroll-0.4.0 (loaded, files)
=== 9 files, 4494 bytes
=== Detected gem io-console-0.4.6 (loaded, files)
=== WARNING: Gem io-console-0.4.6 root folder was not found, skipping
=== Detected gem rake-12.0.0 (loaded, files)
=== 43 files, 111973 bytes
=== Including 59 encoding support files (3909616 bytes, use --no-enc to exclude)
答案 0 :(得分:0)
您使用的是什么红宝石版本?我用2.3.3和所需的gem尝试了您的代码,但出现了一些错误。
对于OCRA,您可以在构建exe时尝试以下参数:
ocra script.rb --no-autoload --add-all-core
如果它是窗口应用程序,请尝试以下操作:
ocra script.rb --no-autoload --add-all-core --windows C:\Ruby23-x64\lib\tcltk\
--add-all-core
=>将所有核心ruby库添加到可执行文件中。
--no-autoload
=>不要加载/包含script.rb的自动加载。
--windows <path-to-gui-folder>
=>强制Windows应用程序(rubyw.exe)
如果在没有--add-all-core
的情况下也可以使用,请不要添加它,这样您的exe文件就会更轻。
希望它能对您有所帮助!
从OCRA git page:
如果需要从与主脚本相同的目录中“要求”其他源文件,请在脚本的开头使用$:.unshift File.dirname($0)
。
如果您需要将文件添加到exe,则可以将其添加到命令行末尾,如下所示:
ocra script.rb --no-autoload --add-all-core src/**/* files/boo.txt