2

I have a dozen of selenium webdriver scripts written in Ruby and I have used both rubyscript2exe and ocra gems in an attempt to end up with a 'bundled' executable but to no avail. Problem is, my scripts are grabbing test data from Excel files; and this is causing havoc when trying to create the executable.

It works fine on the machine which has the original excel file but when taken home away from its native path it 'll just refuse to run. Do I need to declare my paths in my code in a relative way and not explicitly? Is there a command in Ruby like 'require' but for an Excel file for example?

I will be grateful if anyone knows a way to make a ruby executable (or even an installer/application builder) which will somehow include the Excel files running in parallel with the script.

* Resolved *

Admins you can close this one if you want.

It was pretty simple but couldn't figure it out on the first place. If you want to included additional non ruby files in your final executable you can use the line below..:

ocra yourscript.rb test.xls docs\documentantion.doc excel\additional.xls

4

1 回答 1

0

一旦你使用 Ocra 打包一个 exe,文件就会被锁定在其中,如果它们是不可变的,你也可以将数据存储在脚本中并直接从那里写出来。如果没有 excel 文件你绝对不能做到这一点,你也可以考虑通过脚本创建一个。如果您使用的是与 exe 一起分发的外部 excel 文件,那么您最好参考相对于脚本 (Dir.pwd) 的 excel 文件的路径。另外,从分隔的文本文件而不是 excel 中收集数据不是更有效吗?

于 2012-07-25T20:45:37.257 回答