[BangPypers] python + LDTP help

Nagappan A nagappan at gmail.com
Fri Feb 1 19:08:07 CET 2008

Hi Anand and Bangpypers,

I need python + LDTP help.

# ============= code starts here ============

import ldtp

state = ldtp.state
invokableFunctions = {'push_button' : ['click', 'hasstate'], 'menu' :
['selectmenuitem'], 'menu_item' : ['selectmenuitem']}

class component:
   def __init__ (self, window, name):
      self.window = window
      self.name = name
      self.role = ldtp.getobjectproperty (window, name, 'class')
      if invokableFunctions.has_key (self.role):
         functions = invokableFunctions [self.role]
         for function in functions:
            self.__dict__ [function] = ldtp.__dict__ [function]
            self.__dict__ [function].func_defaults = (window, name)
   def hasstate (checkState):
      if isinstance (checkState, type (state)) == False:
         raise ldtp.LdtpExecutionError ('Argument should be of type state')
      return ldtp.hasstate (self.window, self.name, checkState)

class context:
   def __init__ (self, window):
      self.window = window
   def child (self, name):
      return component (self.window, name)

e = context ('*-gedit')
f = e.child ('btnFind')
f.click ()
f.hasstate (state.VISIBLE)

# ============= code starts here ============

In LDTP, i have already implemented more than 160 functions, thought will
reuse them for making it as OO, as the existing ones are written in
structured way.

Now, with the above steps, I'm able to use any function that has two

Like, click takes two arguments, window name and the object name, in which
the click action has to take place.

Ex: click ('*-gedit', 'btnFind') # Clicks on button with label 'Find', in
any window title that ends with '-gedit'.

I have some other functions, like to set a text value on a give object or to
check the property of an object, like its state (visible / enabled). It can
be achieved with the existing implementation like, ldtp.hasstate ('*-gedit',
'btnFind', ldtp.state.VISIBLE) and none of them are optional arguments.

My Question:
What I'm trying to do with the above implementation is, use the initial two
arguments from the object, which I have created - context --> window,
component --> object name and then the last argument get from user, like

e = context ('*-gedit')
f = e.child ('btnFind')
f.hasstate (state.VISIBLE) # obviously, I get an error. My assumption is,
hasstate takes first 2 arguments as string, but I'm passing the first
argument as integer.


Linux Desktop Testing Project - http://ldtp.freedesktop.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/bangpypers/attachments/20080201/35f4be0a/attachment.htm 

More information about the BangPypers mailing list