I'm using Watir to do some automated testing for a website. This particular test I'm pulling an array of sku numbers from an Excel sheet and then randomly selecting one from the array to use as my test. The number is placed into a search field and it pulls back my product.
Here's my problem: I'm pulling the data from Excel and I printed the data in console to verify the right data was harvested. ok When the sku is put into the search box on the website it is formatting like so: ["000000"]
I need to eliminate the square brackets and the quotes.
I researched about pretty print and though that would do the trick. Here is the pretty print I added:
def pretty_print(q)
q.group(1, '[','"','"',']') {
q.seplist(self) {|v|
q.pp v
}
}
end
Here is the code for getting the sku from the array and my attempt to apply the pretty print method from above to the string "sk":
puts = "Data path : " + path
workbook = excel.Workbooks.Open(path)
worksheet = workbook.WorkSheets(1)
worksheet.Select
puts "getting 2D Array from column range a2:a100 in sheet 2"
sku1 = worksheet.Range("a2:a5").Value
puts (sku1)
$count = 1
$count.times do |count|
sk = sku1[rand(sku1.length)]
method_name = :"test_#{count}_#{sk}"
define_method method_name do
pp (sk)
search_string = sk
Any help is greatly appreciated!!!