Hi Anand and Bangpypers,<br><br>I need python + LDTP help.<br><br># ============= code starts here ============<br><br>import ldtp<br><br>state = ldtp.state<br>invokableFunctions = {'push_button' : ['click', 'hasstate'], 'menu' : ['selectmenuitem'], 'menu_item' : ['selectmenuitem']}<br>
<br>class component:<br> def __init__ (self, window, name):<br> self.window = window<br> <a href="http://self.name">self.name</a> = name<br> self.role = ldtp.getobjectproperty (window, name, 'class')<br>
if invokableFunctions.has_key (self.role):<br> functions = invokableFunctions [self.role]<br> for function in functions:<br> self.__dict__ [function] = ldtp.__dict__ [function]<br> self.__dict__ [function].func_defaults = (window, name)<br>
def hasstate (checkState):<br> if isinstance (checkState, type (state)) == False:<br> raise ldtp.LdtpExecutionError ('Argument should be of type state')<br> return ldtp.hasstate (self.window, <a href="http://self.name">self.name</a>, checkState)<br>
<br>class context:<br> def __init__ (self, window):<br> self.window = window<br> def child (self, name):<br> return component (self.window, name)<br><br>e = context ('*-gedit')<br>f = e.child ('btnFind')<br>
f.click ()<br>f.hasstate (state.VISIBLE)<br><br># ============= code starts here ============<br><br>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.<br>
<br>Now, with the above steps, I'm able to use any function that has two arguments.<br><br>Like, click takes two arguments, window name and the object name, in which the click action has to take place.<br><br>Ex: click ('*-gedit', 'btnFind') # Clicks on button with label 'Find', in any window title that ends with '-gedit'.<br>
<br>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.<br>
<br>My Question:<br>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<br>
<br>e = context ('*-gedit')<br>f = e.child ('btnFind')<br>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.<br>
<br>Thanks<br>Nagappan<br><br>-- <br>Linux Desktop Testing Project - <a href="http://ldtp.freedesktop.org">http://ldtp.freedesktop.org</a><br><a href="http://nagappanal.blogspot.com">http://nagappanal.blogspot.com</a>