summaryrefslogtreecommitdiff
path: root/Object-Oriented_LDTP.mdwn
blob: f3159d68f4e7a5ef0b65f82c597b4f10c7c16c27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# 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