分类: Python/Ruby
2006-09-28 13:51:40
-----------
Dogtail
-----------
1 #!/usr/bin/python
2 from dogtail.config import config
3 from dogtail import tree
4 from dogtail.utils import screenshot, run
5 import dogtail.i18n
6 dogtail.i18n.loadTranslationsFromPackageMoFiles('stardict')
7
8 from time import sleep
9 from os import environ
10 environ['LANG']='en_US.UTF-8'
11
12 run('stardict')
13 treeroot = tree.root.application('stardict')
14 treeroot.button('Clear').click()
15 sleep(1)
16
17 newtxt = treeroot.child(roleName = 'text')
18 newtxt.text = "hello"
19 sleep(1)
20
21 screenshot()
22
23 treeroot.button('go back').click()
24 sleep(1)
25
26 treeroot.button('quit').click()
-------
LDTP
-------
1 #!/usr/bin/python
2
3 from ldtp import *
4 from ldtputils import *
5
6 from time import sleep
7 from os import environ
8 environ['LANG']='en_US.UTF-8'
9
10 launchapp('stardict')
11 try:
12 waittillguiexist('frmStarDict')
13
14 click('frmStarDict', 'btnClear')
15 sleep(1)
16
17 enterstring('frmStarDict', 'txt0', 'hello')
18 sleep(1)
19
20 imagecapture ('StarDict', 'snapshot.png')
21
22 click('frmStarDict', 'btngoback')
23 sleep(1)
24
25 click('frmStarDict', 'btnquit')
26 except ldtp.LdtpExecutionError, x:
27 print "LdtpExecutionError: %s"%x