Forum Discussion
If you want to output the resulting value e.g. to the log, use:
Log.Message(str(get_test_suite(your_excel_file_driver)))
tests_to_run is a local variable inside get_test_suite() function.
- Rajesh28 years agoContributor
Hi baxatob. I was asking like how to print only the first value?
Like from ['TC1138', 'TC996', 'TC1135', 'TC1138', 'TC1140'] i need to print only 'TC1138'.
Can you help with this problem?
- baxatob8 years agoCommunity Hero
my_list = [1, 2, 3, 4, 5] my_list[0] == 1 my_list[-1] == 5
etc...You ask very fundamental questions. I believe you need to open Python's Tutorial where you will find all answers and more.
It's impossible to code something without that knowledge.
- Rajesh28 years agoContributor
baxatob I know to print the values from the list.
my_list = [1, 2, 3, 4, 5] my_list[0] == 1 my_list[-1] == 5
But i am not able to print using the script which you have sent
test_case_container = DDT.ExcelDriver("C:\\TestCases.xls", "Sheet1") def get_test_suite(test_case_container): tests_to_run = [] # creating an empty list
while not test_case_container.EOF(): if test_case_container.Value["ExecutionFlag(Y/N)"] == "Y": tests_to_run.append(test_case_container.Value["TCID"])
test_case_container.Next() return tests_to_runWhen i call this method inside a script i will get the result as ['TC1138', 'TC996', 'TC1135', 'TC1138', 'TC1140'].
Now i need to fetch the first value from the list.
I have tried with this code:
test_case_container = DDT.ExcelDriver("C:\\Users\\TESTPC\\Desktop\\TestDoc.xlsx", "Sheet1", True)
def get_test_suite():
tests_to_run = [] # creating an empty list
while not test_case_container.EOF():
if(test_case_container.Value["Execute-Flag(Y/N)"] == "Y"):
test=tests_to_run.append(test_case_container.Value["TCID"])
test_case_container.Next()
return tests_to_run
def test():
Log.Message(str(get_test_suite()))
A=[get_test_suite()]
Log.Message(str(A[1]))But i am not able to fetch the values. Can you please help with this problem?
Related Content
Recent Discussions
- 4 days ago
- 4 days ago