Ocra generated exe takes no arguments
I am creating an .exe using ocra like ocra testing.rb -- sample
here's passing `` sample '' as an argument for the below code and creating the 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
the problem here is that after creating the .exe file, and when I tried to run the exe by passing a different argument (value), it always takes the same value as "sample" in the argument, as it was hardcode.
C:\Users\shivaj\Downloads>testing.exe -- test1
it fits as a sample
Please help me with this, I just made an example program with the problem, but the actual program has more to do with it. Any help is appreciated. Thank you for your help!
source to share
I assume this is because you are assigning a parameter to a variable and when you create the exe, you provide the parameter.
I am using some scripts that take parameters and that are converted to exe using ocra.
I am doing the following
ARGV.each do|arg|
# do whatever with arg
end
And then when you create the exe you do not provide a parameter, the code will work fine because the ARGV will be there but empty.
source to share