Data-Driven Tests
How do I use Excel with Watir for data-driven tests?
require 'win32ole'
excel = WIN32OLE::new("excel.Application")
workbook = excel.Workbooks.Open("c:\\examples\\example_sheet.xls")
worksheet = workbook.WorkSheets(1) # get first workbook
worksheet.Select # just to make sure macros are executed, if your sheet doesn't have macros you can skip this step.
value = worksheet.Range("a12").Value # get the value at cell a12 in worksheet.
data = worksheet.Range("a1:c12").Value # returns 2D array with values starting from cell a1 to cell c12
Assalamu alaikum shahadath khan bhai,
ReplyDeleteI am a newbie for watir. Cann u please explain Watir Data driven technique with an example??
Thank u