4

am building .exe using ocra like this ocra testing.rb -- sample

here am passing ''sample'' as argument to the below code and building an 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

the issue here is ,after building the .exe and when i tried to run exe by passing a different argument (value) it always takes the same value as "sample" to the argument as it was hard code .

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

it puts as sample

Please help me out with this ,i just made a sample program with issue but the actual program has more to do with it . Any help is appreciated . Thank you for the help !

meher
  • 49
  • 5

2 Answers2

1

I suppose this is because you assign the parameter to a variable and while building the exe you provide a parameter.

I use some scripts that use parameters and that are converted to exe using ocra.

What I do is the following

ARGV.each do|arg|
  # do whatever with arg
end

And then, when you build the exe you don't provide a parameter, the code will run fine because ARGV will be there but empty.

peter
  • 41,770
  • 5
  • 64
  • 108
0

Currently is not supported by Ocra: https://github.com/larsch/ocra/issues/48