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.

2810015513_68257528f7

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

Requirements:__

Installing LDTP.

Note:: After installing LDTP Editor, when I tried to run ldtpeditor, I got an error sayin:

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.

Record using LDTP Editor

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

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

LDTP Editor Wildcard Support (new)

Reasons to add window support to ldtpeditor:

Ldtpeditor recognizes all windows it records by the window name. It ignores the white spaces, so if you are working with Xchat you will find lines like these recorded:

click ("frmXChat:shrink@FreeNode/#mandriva(+tncPz)", "tbtnT")
click ("frmXChat:shrink@FreeNode/#opensocial(+sn)", "tbtnS") 

Here "frmXChat:shrink@FreeNode/#mandriva(+tncPz)" and "frmXChat:shrink@FreeNode/#opensocial(+sn)" are the window names. It is this window name that the LDTP engine later uses when you play the converted python scripts. You will notice that as you continue recording, the window name changes. So if the window name is not exactly the same when you are playing the converted code, ldtpeditor gives and error.

To overcome this difficulty we introduce the feature of window name support. This feature takes advantage of the LDTP engine's ability to recognise windows using wildcards.

So when we add the window name 'XChat' in the "Supported Application" list, here is what the ldtpeditor records:

click ("*XChat*", "tbtnT")
click ("*XChat*", "tbtnS")

Thus the converted code runs even when the window name changes as long as it contains the string "XChat".

To help ldtpeditor recognize the application you are working with follow the following very simple steps:

LDTP Editor Object Oriented LDTP (OOLDTP) Support (new):

LDTP Editor can now generate ooldtp scripts when the "Generate ooldtp scripts" option is selected in preferences.

Normal LDTP Scripts:

from ldtp import *
from ldtputils import *
try:
selectrow ("*BuddyList*", "ttbl0", "Ashim Paul")
selectrow ("*BuddyList*", "ttbl0", "D. Dhinesh\nProxy War..")
waittillguinotexist ("*BuddyList*")
waittillguiexist ("*XChat*")
click ("*XChat*", "btnConnect")
selectmenuitem ("*XChat*", "mnuChannelTab")
waittillguinotexist ("*XChat*")
except LdtpExecutionError, msg:
raise

Object Oriented LDTP Scripts:

from ldtp import *
from ldtputils import *
from ooldtp import *
try:
    BuddyList = context("*BuddyList*")
    BuddyList.selectrow ("ttbl0", "Ashim Paul")
    BuddyList.selectrow ("ttbl0", "D. Dhinesh\nProxy War..")
    BuddyList.waittillguinotexist ()
    XChat = context("*XChat*")
    XChat.waittillguiexist ()
    XChat.click ("btnConnect")
    XChat.selectmenuitem ("mnuChannelTab")
    XChat.waittillguinotexist ()
except LdtpExecutionError, msg:
    raise


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 at lists.freedesktop.org or nagappan at gmail dot com or sp2hari at gmail dot com

Known issues

Recording TO DO

Demo of LDTP Recording

Reference

RecordHOWTO (last edited 2008-08-30 09:52:07 by Shreyank Gupta)