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 = {&#39;push_button&#39; : [&#39;click&#39;, &#39;hasstate&#39;], &#39;menu&#39; : [&#39;selectmenuitem&#39;], &#39;menu_item&#39; : [&#39;selectmenuitem&#39;]}<br>
<br>class component:<br>&nbsp;&nbsp; def __init__ (self, window, name):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.window = window<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://self.name">self.name</a> = name<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.role = ldtp.getobjectproperty (window, name, &#39;class&#39;)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if invokableFunctions.has_key (self.role):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; functions = invokableFunctions [self.role]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for function in functions:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.__dict__ [function] = ldtp.__dict__ [function]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.__dict__ [function].func_defaults = (window, name)<br>
&nbsp;&nbsp; def hasstate (checkState):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if isinstance (checkState, type (state)) == False:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise ldtp.LdtpExecutionError (&#39;Argument should be of type state&#39;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ldtp.hasstate (self.window, <a href="http://self.name">self.name</a>, checkState)<br>
<br>class context:<br>&nbsp;&nbsp; def __init__ (self, window):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.window = window<br>&nbsp;&nbsp; def child (self, name):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return component (self.window, name)<br><br>e = context (&#39;*-gedit&#39;)<br>f = e.child (&#39;btnFind&#39;)<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&#39;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 (&#39;*-gedit&#39;, &#39;btnFind&#39;) # Clicks on button with label &#39;Find&#39;, in any window title that ends with &#39;-gedit&#39;.<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 (&#39;*-gedit&#39;, &#39;btnFind&#39;, ldtp.state.VISIBLE) and none of them are optional arguments.<br>
<br>My Question:<br>What I&#39;m trying to do with the above implementation is, use the initial two arguments from the object, which I have created - context --&gt; window, component --&gt; object name and then the last argument get from user, like<br>
<br>e = context (&#39;*-gedit&#39;)<br>f = e.child (&#39;btnFind&#39;)<br>f.hasstate (state.VISIBLE) # obviously, I get an error. My assumption is, hasstate takes first 2 arguments as string, but I&#39;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>