I am trying to make a variable that I can increment each time after I use it. The $companyLevel os the variable that I need to increment.
count = 20
# Variables (20)
while count > 0
$levelName = ""; 8.times{$levelName << (65 + rand(25)).chr}
$companyLevel = "CLev5"
browser2.button(:id, "addCompanyLevel").click
sleep 2
browser2.text_field(:id, $companyLevel).set $levelName
$companyLevel += 1
count -= 1
end
How do I create a variable that will have a number at the end that will increment each time it is used?
Thanks.
Since you already have a count, why does this need to be a variable? why not just do simple string concatenation to create the value you want on the fly
companyLevel = "CLev" + count.to_s
Unless you need to perhaps read up on what an 'array' is?
I'd suggest you purchase and read the book "Everyday Scripting with Ruby" it's a great way to lean the basics of the ruby language and geared towards testers.