Ruby problem

fun4uoc

Supreme Member
Joined
Dec 25, 2007
Messages
1,205
Reaction score
1,049
Just started playing around with Ruby and have run into an issue.

I have it hardcoded to pull a random name and store it in a variable.

Code:
firstname = "Becky","Mary","Anabel","Geneva","Margart","Christina","Diane"

first = firstname.sample(1)

wd.find_element(:id, "first_name").send_keys "#{first}"


This works fine when checking with puts, however, when I run it it enters this in the field. ["Joyce"]

If I just do it like this it works fine.
Code:
wd.find_element(:id, "first_name").send_keys "Joyce"

I've tried pulling names from a txt and csv file with the same results. Tried several methods i've found on google to remove the [""] but they all caused the bot to not even run.

Any ideas?

Thanks
 
Last edited:
your var "first" is an array with just one value! To get the string inside of this array you have to use either "#{first.first}" or "#{first[0]}"
 
Doh!!!

That did it, thanks bud.
 
Back
Top