I see, learn and rediscover… everyday!
 
LDTP Editor

LDTP Editor

Want to use LDTP to test your application? Or do you want to automate the actions you do often? Or are you a GNU/Linux user who want to show “magic” to your friends by recording your actions and playing them back? You can use LDTP for this. But one small issue with LDTP is that you should know the LDTP Python API to write any test suite. But with the new LDTP Editor, this makes your job really simple. A screenshot of the LDTP Editor is shown below.

 

LDTP Editor

 

This is a simple HOWTO for recording and playing back the recorded script.

Installing LDTP.

  • Download the lastest LDTP source code from http://people.freedesktop.org/~nagappan/ldtp-0.9.2.tar.gz.
  • Uncompress the file.
  • Compile the code using ./configure and make
  • If you don’t have the access to install softwares, run the ldtpeditor file in the python folder
  • If you have access to install softwares, then run “make install”

Note:: After installing LDTP Editor, i when i tried to run ldtpeditor, got an error saying

hari@hari-laptop:~/ldtp/ldtp-0.9.2$ ldtpeditor
(ldtpeditor:11130): libglade-WARNING **: could not find glade file '/usr/share/local/ldtp/glade/ldtpeditor.glade'
Glade file not found

The ldtpeditor.glade file is present in the python folder. I got this error because i compiled the code as ./configure. If i had done it as ‘./configure –prefix=/usr’, then i wouldn’t have got this error. Anyway i copied the file manually to that folder.

hari@hari-laptop:~/ldtp/ldtp-0.9.2$ sudo mkdir -p /usr/share/local/ldtp/glade/
hari@hari-laptop:~/ldtp/ldtp-0.9.2$ sudo cp python/ldtpeditor.glade /usr/share/local/ldtp/glade/
hari@hari-laptop:~/ldtp/ldtp-0.9.2$ ldtpeditor

After that when i ran ldtpeditor, it ran without any issues.

Recording using LDTP Editor

For this let us consider recording the actions performed in gcalctool.

  • First make sure Assistive Technology is enabled in your desktop. If you are not sure about this, open gnome-control-center and in that open Assistive Technology Preferences. You should have Enable Assistive Technologies checked to use LDTP.
  • If you are enabling Assistive Technology only now, logout and login again.
  • Run ldtpeditor and gcalctool.
  • Make sure both you have enabled ‘Always on Top’ or both the applications and both the window doesn’t overlap with each other.
  • Click the Start button the LDTP Editor. All actions performed after this are recorded.
  • Perform actions in the gcalctool. Check out this video to see the actions i recored in my computer .
  • After you’re done with the actions in the gcalctool, click the Stop button in the LDTP Editor.
  • You can see that the ‘Recorded Code’ tab is updated with code as when you perform actions in gcalctool.
  • Click the convert button in the LDTP Editor. You’ll see that the Generated LDTP Code and Generated LDTP XML tabs are filled with generated code.
  • The Play button is not working now. I wrote the patch for that yesterday night ;-).
  • Save the contents of the ‘Generated LDTP Code’ into a python file (for ex frisco.py) . Note that if the file name you specify already exists, then it OVERWRITES the filename without any warning.
  • Then run hari@hari-laptop:~$ python frisco.py
  • The actions you performed while recording will be played back again 🙂

Currently the Play button in the LDTP Editor is not enabled. But you can make it work by applying the patch mentioned below. I guess this patch will be added to LDTP Editor in a week or so. So check the ChangeLog file before applying the patch.

LDTP Editor Preferences

Using the LDTP Prefereces, you can control what all actions you can control. A brief summary about the options given in the Preferences window.

  • Listen key events
    This option is not yet implemented. Checking/Unchecking this doesn’t make any difference now.
  • Listen mouse events
    This option is not yet implemented. Checking/Unchecking this doesn’t make any difference now.
  • Generate LDTP Code
    Only when if this option is enabled, Convert will generated to LDTP code in the ‘Generated LDTP Code’ tab. This is enabled by default when you run LDTP Editor.
  • Generate Data XML
    If this option is enabled, the LDTP Editor will generate data XML for the actions you perform.
  • Generate keyboard events code
    Generates code for the keyboard events you performed during the recording session.
  • Generate wait time code
    Calculates the delay one takes between each action during the recording session and generates code so that similar time delay is generated while play back.
  • Generate Memory / CPU statistics.
    The code to generate Memory and CPU statistics will be generated. You need to install pystatgrab and libstatgrab packages.

Patching to make the Run button work

  • Copy this patch file to your ldtp folder.
  • Runhari@hari-laptop:~/ldtp/ldtp-0.9.2$ cd ldtp-0.9.2
    hari@hari-laptop:~/ldtp/ldtp-0.9.2$ patch -p0 < ldtpeditor_runbutton.patch
  • Compile the code again and run ldtpeditor. This time after you Convert the Code, you can Run the code from the LDTP Editor. 🙂

Note:: The generated code had many unwanted waittillguiexist. I saw waittillguiexist(“dlg0”) in many places. If your playback is stopped because of this, remove that before running the scripts.
Sometime the resource will go high as the application map info is collected from the application, so no need to worry.

If you find any issues regarding LDTP Editor, report it to ldtp-dev@lists.freedesktop.org or nagappan@gmail.com or sp2hari@gmail.com

All patches are welcome. 🙂

One comment

  1. Hi,

    I am facing this issue while installing LDTP Editor in ubuntu 10.04.

    Traceback (most recent call last):
    File “/usr/local/bin/ldtpeditor”, line 81, in
    raise ImportError, ‘libldtpcodegen not found’
    ImportError: libldtpcodegen not found

    Thanks in advance

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.