簡體   English   中英

Ocra生成的exe不接受參數

[英]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&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

它作為樣本

請幫我解決這個問題,我剛剛制作了一個有問題的示例程序,但實際的程序更多地與它有關。 任何幫助表示贊賞。 感謝您的幫助 !

我想這是因為您將參數分配給變量,並在構建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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM