How to fetch the data from a Grid/dataset/table?
Hi,
Greetings,
NOTE: Please solve my queries on the basis of Python language as i am working in Python
I am working in a project where in we are using TestComplete with Python language. I have some queries, Can anyone please clarify my queries as soon as possible..
Query1:
How to fetch the data from a Grid/dataset/table? I have attached the Screenshot of the Grid. Can anyone please let me know how to fetch the firstname or lastname. When i object spy on the grid it is not spying the data present in it, but it is spying on the Grid layout.
I have tried with adding it into a table in TC and then fetching from it. But it is tidious as we need to keep on updating the table manually everytime it gets updated. Please suggest any other solutions.
NOTE: Screenshot attached(GridImage.png)
Query2:
I need to fetch the data from excel file and send that data as argument in the application. I am able to fetch using DDT driver. driver.Value[0 or 1 or 2...] but i want to fetch the data on the basis of the column Name. Like if the Column name is FirstName then it should fetch the data from that column only. Can anyone please suggest how to go about this?
Query3:
How to get a snapshot on the failure of the script?
Query4:
Can we get the report in Excel format.
Hi baxatob Thank you so much for the solution.
But we are facing some issue. It is returning the value of only first row.
As Pavan name was in first row it returned the Age of that Name.
But when i gave Log.Message("Raj") which is in third row, the code isn't working.
while not source.EOF(): if source.Value["NAME"] == name: return source.Value["AGE"] source.Next()
Can we know why it is not working for the same. If you know the solution, Can you please help us with the same..!!
Hi,
You should call the get_value() routine within Log.Message():
Log.Message(get_value("Raj"))
It works for me.
In your case get_value() is a class method. You should use a keyword self as a first argument, while defining your function:
class Excel: def get_value(self, RowValue, ColumnName, name): ...
P.S. You do not need these delays : Delay(1000)
At first you need to import your class:
from Script1 import Excel class Common_Functions(Excel): ...