Ocra生成的exe不接受参数

时间:2017-04-10 20:36:42

标签: ruby-on-rails ruby selenium-webdriver command-line-arguments ocra

正在使用像ocra testing.rb -- sample

这样的ocra构建.exe

这里传递''sample''作为下面代码的参数并构建一个exe

require "selenium-webdriver"

$var = ARGV[0]

driver = Selenium::WebDriver.for :chrome
wait = Selenium::WebDriver::Wait.new(:timeout => 20)

puts $var


driver.navigate.to "https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier"
sleep 5
input = driver.find_element(:id, "Email")
input.send_keys($var)
button = driver.find_element(:id, "next")
button.click
sleep 5

这里的问题是,在构建.exe之后,当我试图通过传递一个不同的参数(值)来运行exe时,它总是采用与参数“sample”相同的值,因为它是硬代码。

C:\Users\shivaj\Downloads>testing.exe -- test1

它作为样本

请帮我解决这个问题,我刚刚制作了一个有问题的示例程序,但实际程序更多地与它有关。任何帮助表示赞赏。感谢您的帮助 !

2 个答案:

答案 0 :(得分:1)

我想这是因为您将参数分配给变量,并在构建exe时提供参数。

我使用一些使用参数的脚本,并使用ocra转换为exe。

我所做的是以下

@Html.Partial("EditStatus", new ViewDataDictionary { { "item", someInteger } });

然后,当您构建exe时,您不提供参数,代码将运行正常,因为ARGV将在那里但是为空。

答案 1 :(得分:0)