pavanmac
8 years agoContributor
How to fetch the value from excel .
Scenario :
I have read an array [1138,1139,1140] and now for 1138 i have to do the actions(assume login)
I have given the necessary steps to do it. So if it fetches 'Ctrl_ID' then it should pass 'button'
So from excel how to fetch those repeated
Ctrl_ID | Ctrl_Type | Action | Data | Ctrl_ID | Ctrl_Type | Action | Data |
buttonok | button | click | Password | Textbox | Sendkeys | pass123 |
continues till Ctrl_ID is NULL.
Condition is to use "TUPLES" and do the same.
Better approach is to go Row wise instead having column wise, As below
Ctrl_ID Ctrl_Type Action Data buttonok button click Password Textbox Sendkeys pass123 If Row wise approach you can use below,
function rowWise() { var excelDriver = DDT.ExcelDriver("<excel file name>"); var cno_Col1 = getColumnNo(excelDriver,str_ColName); excelDriver.First(); while(!excelDriver.EOF()) { if(DDT.CurrentDriver.Value(cno_Col1) != "") { Log.Message(DDT.CurrentDriver.Value(cno_Col1)); } else { break; } } } function getColumnNo(obj_Driver,str_ColName) { for(var i = 0 ; i < obj_Driver.ColumnCount ; i++) { if(obj_Driver.ColumnName(i) == str_ColName) { return i; } } }
if Column wise approach then you can use below,
function colWise() { var excelDriver = DDT.ExcelDriver("<excel file name>"); var cno_Col1 = 0; excelDriver.First(); var cno_Col1 = getColumnNo(excelDriver,str_ColName); while(!excelDriver.EOF()) { if(DDT.CurrentDriver.Value(cno_Col1) != "") { skpiNo = cno_Col1; cno_Col1 = getNextColumnNo(excelDriver,str_ColName,skpiNo); Log.Message(DDT.CurrentDriver.Value(cno_Col1)); } else { break; } } } function getColumnNo(obj_Driver,str_ColName) { for(var i = 0 ; i < obj_Driver.ColumnCount ; i++) { if(obj_Driver.ColumnName(i) == str_ColName) { return i; } } } function getNextColumnNo(obj_Driver,str_ColName,skipper) { for(var i = 0 ; i < obj_Driver.ColumnCount ; i++) { if(obj_Driver.ColumnName(i) == str_ColName && i > skpiNo) { return i; } } }
Array = [ctrl_id, data, action, keys] Array[0] == ctrl_id Array[1] == data Array[2] == action Array[3] == keys
So you can use: Log.Message(Array[0])
or more tricky: [Log.Message(value) for value in Array]