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 に答える