Object Oriented LDTP bundled with LDTP package

With this implementation, the code can be like

Approach 1

from ooldtp import *

gedit = context ('*-gedit')
btnFind = gedit.getchild ('btnFind')
btnFind.click ()

Approach 2

from ooldtp import *

gedit = context ('*-gedit')
gedit.click ('btnFind')

Welcome to Object-Oriented LDTP (EXPERIMENTAL) by Palm Source

What it is Object-Oriented LDTP?

Till now LDTP supports this kind of syntax:

click('*gedit', btncopy)
selectmenuitem('*gedit', 'mnuFile;mnuOpen')

it does not support appmap anymore. however I prefer using appmap to maximize its maintainability of our automation script. and I want ldtp have ability to using the following syntax to write script:

frmgedt.btncopy.click()
frmgedit.mnuOpen.click()

and

Window('frm*gedit').PushButton('btncopy').click()
Window('frm*gedit').MenuItem('mnuFile;mnuOpen').pick()

so I write a wrapper for LDTP, it wraps/improves most of LDTP API.

How to use?

use convert.py to generate the window declaration

  • cmd line:
    • convert windowname output e.g.
    • convert frm*gedit geditclass.py it will generate geditclass.py

open the file, you can find the code looks like below:

from window import *

class Gedit(Window):
    name = '*gedit'

    btncopy = Window.PushButton('btncopy', name)
    btncut = Window.PushButton('btncut', name)
    btnfind = Window.PushButton('btnfind', name)
    btnfindandreplace = Window.PushButton('btnfindandreplace', name)
    btngtkundo = Window.PushButton('btngtk-undo', name)

    mnuAbout = Window.MenuItem('mnuHelp;mnuAbout', name)
    mnuAda = Window.MenuItem('mnuView;mnuHighlightMode;mnuSources;mnuAda', name)
    mnuAllLowerCase = Window.MenuItem('mnuEdit;mnuChangeCase;mnuAllLowerCase', name)
    mnuAllUpperCase = Window.MenuItem('mnuEdit;mnuChangeCase;mnuAllUpperCase', name)
    # ...
frmGedit = Gedit()

now you can do something like this

To select a menuitem:

frmGedit.mnuAbout.select()
or write this
Window('*gedit').Menu('mnuHelp;mnuAbout').select()

To click a button:

frmGedit.btnfind.click()
or write this
Window('*gedit').PushButton('btnfind').click()

You can find more wrapped APIs in window.py

also you can add your own methods to this class.

That's all, enjoy it ;)

Found any bug please email me:

tae.ccf(at)gmail.com