diff options
author | Joe Rayhawk <jrayhawk@freedesktop.org> | 2013-05-20 17:13:29 -0700 |
---|---|---|
committer | Joe Rayhawk <jrayhawk@freedesktop.org> | 2013-05-20 17:13:29 -0700 |
commit | df5522ffd60e22b6f094d47aed37006cef94d311 (patch) | |
tree | 447cb52b7a4c1cd8ba49d1fd1e05c18f733251cc /Object-Oriented_LDTP.mdwn | |
parent | a8f446fc9136957e38d7cf1b9b39bd0e2c1e6ada (diff) |
moin2mdwn: convert page Object-Oriented_LDTP
Diffstat (limited to 'Object-Oriented_LDTP.mdwn')
-rw-r--r-- | Object-Oriented_LDTP.mdwn | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/Object-Oriented_LDTP.mdwn b/Object-Oriented_LDTP.mdwn new file mode 100644 index 0000000..51086c5 --- /dev/null +++ b/Object-Oriented_LDTP.mdwn @@ -0,0 +1,114 @@ + + +# Object Oriented LDTP bundled with LDTP package + +With this implementation, the code can be like + +* Approach 1 + + +[[!format txt """ +from ooldtp import * + +gedit = context ('*-gedit') +btnFind = gedit.getchild ('btnFind') +btnFind.click () +"""]] +* Approach 2 + + +[[!format txt """ +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: + +[[!format txt """ +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: + + +[[!format txt """ +frmgedt.btncopy.click() +frmgedit.mnuOpen.click() +"""]] +and + + +[[!format txt """ +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: + + +[[!format txt """ + 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: ==== + +[[!format txt """ + frmGedit.mnuAbout.select() + or write this + Window('*gedit').Menu('mnuHelp;mnuAbout').select() +"""]] + * ==== to click a button: ==== + +[[!format txt """ + 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 |