ldtp/ldtp2

Doubleclickrow just click once

tuxskar opened this issue · 8 comments

I am trying to use this function to send a double click in a tree row and it just click once, also the documentation of this function say that this method just click once:

>ldtp.doubleclickrow.__doc__
Single click row matching given text

    @param window_name: Window name to type in, either full name,
    LDTP's name convention, or a Unix glob.
    @type window_name: string
    @param object_name: Object name to type in, either full name,
    LDTP's name convention, or a Unix glob. 
    @type object_name: string
    @param row_text: Row text to select
    @type row_text: string

    @return: row index matching the text on success.
    @rtype: integer

That's documentation bug :-) can you please provide the scenario to reproduce with gedit or other common app that exist on any Linux distribution ?

Thanks

I tried this in gedit on Ubuntu 12.10:

doubleclickrow('dlgOpenFiles', 'tblFiles', '-nationals.txt')
5
singleclickrow('dlgOpenFiles', 'tblFiles', '
-nationals.txt')
5

It worked as expected, do I miss something ? I use latest LDTP from git head. Thanks

I'm trying to active row in a treeview using PyGTK in a window, instead of what you are trying that is doubleclick in a dlgwindow, maybe that's the problem.

I'm using the LDTP from git, and sometimes it show me this error, for example to reproduce what have you tried:

In [2]: ldtp.launchapp("gedit")
In [3]: ldtp.getwindowlist()
['frmDesktop',
 'frmGuake!',
 u'frmDoubleclickrowjustclickonce\xb7Issue#2\xb7ldtp/ldtp2-Chromium',
 'frmSoftwareUpdater',
 'frm*UntitledDocument1-gedit']
In [5]: ldtp.getobjectlist('frm*UntitledDocument1-gedit')
 ---------------------------------------------------------------------------
Fault                                     Traceback (most recent call last)
<ipython-input-5-20f04c786445> in <module>()
----> 1 ldtp.getobjectlist('frm*UntitledDocument1-gedit')

/usr/local/lib/python2.7/dist-packages/ldtp/client.pyc in __call__(self, *args, **kwargs)
     67                                          ', '.join(map(repr, args) + ['%s=%s' % (k, repr(v)) \
     68                                                                           for k, v in kwargs.items()])))
---> 69         return self.__send(self.__name, args)
     70 
     71 class Transport(xmlrpclib.Transport):

/usr/lib/python2.7/xmlrpclib.pyc in __request(self, methodname, params)
   1576             self.__handler,
   1577             request,
-> 1578             verbose=self.__verbose
   1579             )
   1580 

/usr/local/lib/python2.7/dist-packages/ldtp/client.pyc in request(self, host, handler, request_body, verbose)
    188                     raise LdtpExecutionError(e.faultString.encode('utf-8'))
    189                 else:
--> 190                     raise e
    191 
    192     def __del__(self):

Fault: <Fault 8002: "'ascii' codec can't decode byte 0xc2 in position 27: ordinal not in range(128)">

This menssage also appears If I have more than one terminal with python interpreter opened or if I try to use some random window's name

Second one is different issue, maybe we should track in another one, anyways.

To debug incase of this exception, In first terminal run the following commands:

export LDTP_DEBUG=2
ldtp

In second terminal:

ipython

import ldtp
ldtp.getobjectlist('window name')

When ever you see exception on terminal 2, check whats being printed in terminal 1 and paste that here.

Let me try the first issue in pygtk based app.

Thanks

well, I have here what I have tried to run into ipython and the error:

In [2]: ldtp.launchapp("gedit")
Out[2]: 7105

In [3]: ldtp.getwindowlist()
Out[3]: 
['frmDesktop',
 'frmGuake!',
 'pnl0',
 'pnl1',
 'pnl2',
 'pnl3',
 'pnl4',
 'pnl5',
 'pnl6',
 'pnl7',
 u'frmDoubleclickrowjustclickonce\xb7Issue#2\xb7ldtp/ldtp2-Chromium',
 'frmUntitledDocument1-gedit']

In [4]: ldtp.getobject('frmUntitledDocument1-gedit')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-afc4ad40b483> in <module>()
----> 1 ldtp.getobject('frmUntitledDocument1-gedit')

AttributeError: 'module' object has no attribute 'getobject'

In [5]: ldtp.getobjectlist('frmUntitledDocument1-gedit')
---------------------------------------------------------------------------
Fault                                     Traceback (most recent call last)
<ipython-input-5-03313b18e0f9> in <module>()
----> 1 ldtp.getobjectlist('frmUntitledDocument1-gedit')

/usr/local/lib/python2.7/dist-packages/ldtp/client.pyc in __call__(self, *args, **kwargs)
     67                                          ', '.join(map(repr, args) + ['%s=%s' % (k, repr(v)) \
     68                                                                           for k, v in kwargs.items()])))
---> 69         return self.__send(self.__name, args)
     70 
     71 class Transport(xmlrpclib.Transport):

/usr/lib/python2.7/xmlrpclib.pyc in __request(self, methodname, params)
   1576             self.__handler,
   1577             request,
-> 1578             verbose=self.__verbose
   1579             )
   1580 

/usr/local/lib/python2.7/dist-packages/ldtp/client.pyc in request(self, host, handler, request_body, verbose)
    188                     raise LdtpExecutionError(e.faultString.encode('utf-8'))
    189                 else:
--> 190                     raise e
    191 
    192     def __del__(self):

Fault: <Fault 8002: 'error'>

And here it is what shows the other terminal with just ldtp comand running:

 ~ ⮀ ldtp
system.listMethods()
system.methodHelp('activatetext')
system.methodHelp('activatewindow')
system.methodHelp('appendtext')
system.methodHelp('appundertest')
system.methodHelp('check')
system.methodHelp('checkrow')
system.methodHelp('click')
system.methodHelp('closewindow')
system.methodHelp('comboselect')
system.methodHelp('comboselectindex')
system.methodHelp('copytext')
system.methodHelp('cuttext')
system.methodHelp('decrease')
system.methodHelp('delaycmdexec')
system.methodHelp('deletetext')
system.methodHelp('deregisterevent')
system.methodHelp('deregisterkbevent')
system.methodHelp('doesmenuitemexist')
system.methodHelp('doesrowexist')
system.methodHelp('doubleclick')
system.methodHelp('doubleclickrow')
system.methodHelp('enterstring')
system.methodHelp('expandtablecell')
system.methodHelp('generatekeyevent')
system.methodHelp('generatemouseevent')
system.methodHelp('getaccesskey')
system.methodHelp('getallitem')
system.methodHelp('getallstates')
system.methodHelp('getapplist')
system.methodHelp('getcellsize')
system.methodHelp('getcellvalue')
system.methodHelp('getcharcount')
system.methodHelp('getchild')
system.methodHelp('getcombovalue')
system.methodHelp('getcpustat')
system.methodHelp('getcursorposition')
system.methodHelp('getlastlog')
system.methodHelp('getmax')
system.methodHelp('getmaxvalue')
system.methodHelp('getmemorystat')
system.methodHelp('getmin')
system.methodHelp('getminincrement')
system.methodHelp('getminvalue')
system.methodHelp('getobjectinfo')
system.methodHelp('getobjectlist')
system.methodHelp('getobjectnameatcoords')
system.methodHelp('getobjectproperty')
system.methodHelp('getobjectsize')
system.methodHelp('getpanelchildcount')
system.methodHelp('getrowcount')
system.methodHelp('getslidervalue')
system.methodHelp('getstatusbartext')
system.methodHelp('gettabcount')
system.methodHelp('gettablerowindex')
system.methodHelp('gettabname')
system.methodHelp('gettextvalue')
system.methodHelp('getvalue')
system.methodHelp('getwindowlist')
system.methodHelp('getwindowsize')
system.methodHelp('grabfocus')
system.methodHelp('guiexist')
system.methodHelp('guitimeout')
system.methodHelp('handletablecell')
system.methodHelp('hasstate')
system.methodHelp('hidelist')
system.methodHelp('imagecapture')
system.methodHelp('increase')
system.methodHelp('inserttext')
system.methodHelp('invokemenu')
system.methodHelp('isalive')
system.methodHelp('ischildindexselected')
system.methodHelp('ischildselected')
system.methodHelp('istextstateenabled')
system.methodHelp('keypress')
system.methodHelp('keyrelease')
system.methodHelp('launchapp')
system.methodHelp('listsubmenus')
system.methodHelp('maximizewindow')
system.methodHelp('menucheck')
system.methodHelp('menuitemenabled')
system.methodHelp('menuuncheck')
system.methodHelp('minimizewindow')
system.methodHelp('mouseleftclick')
system.methodHelp('mousemove')
system.methodHelp('mouserightclick')
system.methodHelp('objectexist')
system.methodHelp('objtimeout')
system.methodHelp('onedown')
system.methodHelp('oneleft')
system.methodHelp('oneright')
system.methodHelp('oneup')
system.methodHelp('onwindowcreate')
system.methodHelp('pastetext')
system.methodHelp('poll_events')
system.methodHelp('press')
system.methodHelp('registerevent')
system.methodHelp('registerkbevent')
system.methodHelp('remap')
system.methodHelp('removecallback')
system.methodHelp('rightclick')
system.methodHelp('scrolldown')
system.methodHelp('scrollleft')
system.methodHelp('scrollright')
system.methodHelp('scrollup')
system.methodHelp('selectall')
system.methodHelp('selecteditemcount')
system.methodHelp('selectindex')
system.methodHelp('selectitem')
system.methodHelp('selectlastrow')
system.methodHelp('selectmenuitem')
system.methodHelp('selectpanel')
system.methodHelp('selectpanelindex')
system.methodHelp('selectpanelname')
system.methodHelp('selectrow')
system.methodHelp('selectrowindex')
system.methodHelp('selectrowpartialmatch')
system.methodHelp('selecttab')
system.methodHelp('selecttabindex')
system.methodHelp('setcellvalue')
system.methodHelp('setcursorposition')
system.methodHelp('setlocale')
system.methodHelp('setmax')
system.methodHelp('setmin')
system.methodHelp('settextvalue')
system.methodHelp('setvalue')
system.methodHelp('showlist')
system.methodHelp('simulatemousemove')
system.methodHelp('singleclickrow')
system.methodHelp('startprocessmonitor')
system.methodHelp('stateenabled')
system.methodHelp('stopprocessmonitor')
system.methodHelp('uncheck')
system.methodHelp('uncheckrow')
system.methodHelp('unhandletablecell')
system.methodHelp('unmaximizewindow')
system.methodHelp('unminimizewindow')
system.methodHelp('unselectall')
system.methodHelp('unselectindex')
system.methodHelp('unselectitem')
system.methodHelp('verifycheck')
system.methodHelp('verifydropdown')
system.methodHelp('verifyhidelist')
system.methodHelp('verifymenucheck')
system.methodHelp('verifymenuuncheck')
system.methodHelp('verifypartialmatch')
system.methodHelp('verifypartialtablecell')
system.methodHelp('verifypushbutton')
system.methodHelp('verifyscrollbarhorizontal')
system.methodHelp('verifyscrollbarvertical')
system.methodHelp('verifyselect')
system.methodHelp('verifysettext')
system.methodHelp('verifysetvalue')
system.methodHelp('verifyshowlist')
system.methodHelp('verifysliderhorizontal')
system.methodHelp('verifyslidervertical')
system.methodHelp('verifytablecell')
system.methodHelp('verifytabname')
system.methodHelp('verifytoggled')
system.methodHelp('verifyuncheck')
system.methodHelp('wait')
system.methodHelp('waittillguiexist')
system.methodHelp('waittillguinotexist')
system.methodHelp('windowuptime')
launchapp('gedit', [], 0, 1, 'C')

** (ldtp:6869): WARNING **: Unable to open bus connection: Empty address ''
window:create(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:create [frame | Untitled Document 1 - gedit] [application | gedit]
window:deactivate(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:deactivate [frame | Guake!] [application | guake]
window:activate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:activate [frame | Untitled Document 1 - gedit] [application | gedit]
window:activate(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:activate [frame | Guake!] [application | guake]
window:deactivate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:deactivate [frame | Untitled Document 1 - gedit] [application | gedit]
getwindowlist()
getobjectlist('frmUntitledDocument1-gedit')
Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/web/server.py", line 156, in process
    self.render(resrc)
  File "/usr/lib/python2.7/dist-packages/twisted/web/server.py", line 191, in render
    body = resrc.render(self)
  File "/usr/lib/python2.7/dist-packages/twisted/web/resource.py", line 216, in render
    return m(request)
  File "/usr/local/lib/python2.7/dist-packages/ldtpd/xmlrpc_daemon.py", line 125, in render_POST
    **kwargs).\
--- <exception caught here> ---
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 134, in maybeDeferred
    result = f(*args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/ldtpd/core.py", line 1128, in getobjectlist
    gui, _window_name=self._get_window_handle(window_name, True)
  File "/usr/local/lib/python2.7/dist-packages/ldtpd/utils.py", line 825, in _get_window_handle
    gui, name = self._internal_get_window_handle(window_name)
  File "/usr/local/lib/python2.7/dist-packages/ldtpd/utils.py", line 866, in _internal_get_window_handle
    w_name = name = u'%s%s' % (obj_name[0], tmp_name)
exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 27: ordinal not in range(128)
window:deactivate(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:deactivate [frame | Guake!] [application | guake]
window:destroy(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:destroy [frame | Guake!] [application | guake]
window:destroy(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:destroy [frame | Guake!] [application | guake]
window:activate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:activate [frame | Untitled Document 1 - gedit] [application | gedit]
window:deactivate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:deactivate [frame | Untitled Document 1 - gedit] [application | gedit]
window:create(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:create [frame | Guake!] [application | guake]
window:activate(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:activate [frame | Guake!] [application | guake]
'frmUntitledDocument1-gedit'window:deactivate(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:deactivate [frame | Guake!] [application | guake]
window:destroy(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:destroy [frame | Guake!] [application | guake]
window:destroy(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:destroy [frame | Guake!] [application | guake]
window:activate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:activate [frame | Untitled Document 1 - gedit] [application | gedit]
window:deactivate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:deactivate [frame | Untitled Document 1 - gedit] [application | gedit]
window:activate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:activate [frame | Untitled Document 1 - gedit] [application | gedit]
window:deactivate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:deactivate [frame | Untitled Document 1 - gedit] [application | gedit]
window:activate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:activate [frame | Untitled Document 1 - gedit] [application | gedit]
window:deactivate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:deactivate [frame | Untitled Document 1 - gedit] [application | gedit]
window:activate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:activate [frame | Untitled Document 1 - gedit] [application | gedit]
window:deactivate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:deactivate [frame | Untitled Document 1 - gedit] [application | gedit]
window:activate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:activate [frame | Untitled Document 1 - gedit] [application | gedit]
window:deactivate(0, 0, Untitled Document 1 - gedit)
    source: [frame | Untitled Document 1 - gedit]
    host_application: [application | gedit] window:deactivate [frame | Untitled Document 1 - gedit] [application | gedit]
window:create(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:create [frame | Guake!] [application | guake]
window:activate(0, 0, Guake!)
    source: [frame | Guake!]
    host_application: [application | guake] window:activate [frame | Guake!] [application | guake]

I installed gtk-3-examples and launched gtk3-demo:

getwindowlist()
['frmDesktop', 'pnl0', 'pnl1', 'pnl2', 'pnl3', 'pnl4', 'pnl5', 'pnl6', 'pnl7', 'frmUntitledDocument1-gedit', 'dlgOpenFiles', 'frmnagappan@nalagappan:~', 'dlg0', 'dlgLauncherWindow', 'dlg1', 'dlg2', 'dlg3', 'dlg4', 'dlg5', 'dlg6', 'dlg7', 'dlg8', 'dlg9', 'dlg10', 'dlgunity-dash', 'dlg11', 'dlg12', 'dlg13', 'dlg14', 'dlg15', 'dlgSwitcher', 'dlgHud', 'frmGTK+CodeDemos']
getchild('_Demos', role='tree_table')
['ttbl0']
doubleclickrow('_Demos', 'ttbl0', 'Builder')
3
singleclickrow('_Demos', 'ttbl0', 'Button Boxes')
4
singleclickrow('Demos', 'ttbl0', 'Tree')
32
doubleclickrow('_Demos', 'ttbl0', 'Editable Cells')
33

On last command (with expanded Tree View manually), I see Editable Cells, then executing the above command, it launched a new window with Editable Cells

Fixed exception in git head

After that fix, I can reproduce your example and it works also for me in gtk3-demo application, and it works for my project as well!, thank you 👍 😄