I have a test working when I hard code a URL in the ruby file for Selenium to execute however I need to run the same test against multiple URLS with just a different sub-domain
When I run the following I get an error that split is an unknown method
require 'rubygems'
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome
pageLoad = sleep 1
subD = ARGV.split(",")
instances = []
subD.each do |test|
instances << test
end
instances.each do |cub|
url = 'http://' sub '.test.com'
driver.get url
puts "#{url}"
begin
driver.find_element(:id, 'user_login').send_keys 'user 1'
driver.find_element(:id, 'user_password').send_keys 'password1'
driver.find_element(:id, 'login_button').click
puts 'Logging In'
rescue StandardError
puts 'Unable to login'
end
pageLoad
puts 'Test Complete'
sleep 5
end
driver.quit
This is the error
test.rb:8:in `<main>': undefined method `split' for ["test1,test2,test3"]:Array (NoMethodError)
Inputting
ruby test.rb test1,test2,test3
CodePudding user response:
ARGV is an array not a string, you either need to pass each subdomain separately and then iterate through ARGV, or access the first member of ARGV with ARGV[0]