我使用ocra构建.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
它把它作为样本
请帮我解决这个问题,我只是做了一个有问题的示例程序,但实际的程序与它有更多的关系。任何帮助都是非常感谢的。谢谢你的帮助!
发布于 2017-05-29 18:21:00
我想这是因为您将参数赋给了一个变量,并且在构建exe时提供了一个参数。
我使用一些使用参数的脚本,这些脚本使用ocra转换为exe。
我所做的如下
ARGV.each do|arg|
# do whatever with arg
end然后,当您构建exe时,您不需要提供参数,代码将正常运行,因为ARGV将在那里,但为空。
发布于 2017-05-29 18:08:15
目前不支持Ocra:https://github.com/larsch/ocra/issues/48
https://stackoverflow.com/questions/43332492
复制相似问题