Forum Discussion

Rajesh2's avatar
Rajesh2
Contributor
8 years ago
Solved

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...
  • Rajesh2's avatar
    Rajesh2
    8 years ago

    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..!!

  • baxatob's avatar
    baxatob
    8 years ago

    Hi,

     

    You should call the get_value() routine within Log.Message():

     

    Log.Message(get_value("Raj"))

    It works for me.

  • baxatob's avatar
    baxatob
    8 years ago

    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)

  • baxatob's avatar
    baxatob
    8 years ago

    At first you need to import your class:

     

    from Script1 import Excel
    
    class Common_Functions(Excel):
        ...