[英]Ocra generated exe doesn't accepts arguments
正在建设.exe使用像这样的ocra testing.rb -- sample
这里传递''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<mpl=default<mplcache=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
它作为样本
请帮我解决这个问题,我刚刚制作了一个有问题的示例程序,但实际的程序更多地与它有关。 任何帮助表示赞赏。 感谢您的帮助 !
我想这是因为您将参数分配给变量,并在构建exe时提供参数。
我使用一些使用参数的脚本,并使用ocra转换为exe。
我所做的是以下内容
ARGV.each do|arg|
# do whatever with arg
end
然后,当您构建exe时,您不提供参数,代码将运行正常,因为ARGV将在那里但是为空。
目前Ocra不支持: https : //github.com/larsch/ocra/issues/48
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.