Question

I need to have my webdriver tests hit multiple servers. My solution was to pass in a command line parameter but when run the code below using

ruby webdriver/e2e/*.rb -s=localhost

or

ruby webdriver/e2e/*.rb --server=localhost

but I get the following error. I get the following error

C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:49:in `process_args': invalid argument: -s=localhost (OptionParser::InvalidArgument)
    from C:/Ruby193/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
    from C:/Ruby193/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
    from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:21:in `run'
    from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
    from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
    from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'

test.rb

require 'test/unit'
require 'optparse'

class SuperTestClass < Test::Unit::TestCase
    def setup 
         @server = "https://localhost/"
         optparse = OptionParser.new do|opts|            
             opts.on( '-s', '--server server', 'Server to run tests against' ) do|server|
                 @server = server
             end
         end

        ...
    end
    ...
end

UPDATE

I changed

opts.on( '-s', '--server server', 'Server to run tests against' ) do|server|

to

  opts.on( '-serv', '--server server', 'Server to run tests against' ) do|server|

but it didn't fix it

Was it helpful?

Solution 2

I don't think tests can take parameters. I ended up using rake to set env paramters.

task :selenium,[:env,:type] do |t, args|
    args.with_defaults  :env => 'local',:type => 'all'

    case args.env
        when 'local'
            ENV['URL'] = 'localhost'
            ...
    end

    puts
    puts '****Running '+args.type+' tests on: '+ ENV['URL']
    puts

    Rake::Task[args.type].execute
end

OTHER TIPS

Unfortunately i cannot find the doc so i can't prove my theory, but I think that the short -s option is already reserved for something else.

Try changing the short argument to something else and try again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top