How to fetch the value from excel .
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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; } } }
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much for the solution.
Can you do the same in python??
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am new to it and working as intern.
Could you please help me out with Python ??( Testcomplete)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry @pavanmac i can't help you here since i don't know anything on Python
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My question here is :
Now as tc1138 is selected. It should navigate through different steps.
I have attached the screen shot.
From Testcase 1138 row of excel it should fetch all the cell values with column name ctrl_ID , CTrl_type Action Data.
How to go about this?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @baxatob
As the ctrl_ID is repeating for test case in excel row. I am not able to fetch the value for all the ctrl_id and condition is
(ctrl_id , ctrl_type , atcion , data) these 4 set of values can be increased or decreased and code should work in spite of this.
Attachment show these 4 set of values.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Paste your code which you getting the value of that four items.
I will try to help you
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As @shankar_r said better to use the following file structure:
Ctrl_ID | Ctrl_Type | Action | Data |
buttonok | button | click | |
Password | Textbox | Sendkeys | pass123 |
You can place each test case in the separate sheet.
