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.
This is a simple HOWTO for recording and playing back the recorded script.
Requirements: ldtp with ldtpeditor installed Installing LDTP. Download the lastest LDTP source code from Perform actions in the gcalctool. Check out this video to see the actions i recorded in my computer . 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) Note:: After installing LDTP Editor, when I tried to run ldtpeditor, I got an error sayin: 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. 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. The actions you performed while recording will be played back again Click save button to save generated python script, if 2nd tab is empty, then it will try to get the contents of first tab and store it in the file you specify. If file already exist, it will *OVER-WRITE* NOTE: control+c, control+v doesn't work You can run the saved file from command line like: hari@hari-laptop:~$ python frisco.py LDTP Editor Preferences Using the LDTP Preferences, 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. Edit App List: with this option you can edit the names of the windows ldtpeditor supports. For more on how to customize window support see LDTP Editor Wildcard Support.
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: 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: 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: First recognize the string which almost always is contained in your window name (in our example above its "XChat"). Drop the white spaces, so "Mozilla Firefox" becomes "MozillaFirefox". Make sure its unique to your window and is not contained in other windows open when you play your converted script. If such a window exists which may cause trouble while playing, close it! Click on Add. Record and Play as you normally do. You will find that is the Window name is present in any recorded string, its gets wildcard-ed 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: Object Oriented LDTP Scripts: Note: The generated code had many unwanted waittillguiexist. I saw waittillguiexist (”dlg0″) in many p
Inside netbeans editor
How to create LDTP_test_scripts_in_python Running LDTP scripts How_to_execute_scripts Sequencing set of LDTP scripts using ldtprunner_XML file Script input Data_XML file - Useful to maintain a generic script
GIT 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
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
LDTP Editor Wildcard Support (new)
click ("frmXChat:shrink@FreeNode/#mandriva(+tncPz)", "tbtnT")
click ("frmXChat:shrink@FreeNode/#opensocial(+sn)", "tbtnS") click ("*XChat*", "tbtnT")
click ("*XChat*", "tbtnS")
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:
raisefrom 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:
raiseKnown issues
Demo of LDTP Recording
Reference
