系统环境:
Suse 10.0
Python 2.4
dogtail...060804的CVS+自行修改
pyspi 060804的cvs
stardict为RPM安装,版本是2.4.2
主要测试过程如下:
启动应用程序,读取$HOME/Desktop/wordList中的单词逐个查询,查询完毕后查前一个查过的单词,然后接下来查这个单词在字典中的前一个和后一个单词,最后退出。
如果想要测试过程中的屏幕截图,请自行在合适的位置添加
screenshot()
欢迎交流~~~~~
#!/usr/bin/python
from dogtail.config import config
from dogtail.procedural import *
from dogtail.utils import screenshot
#import dogtail.i18n
#dogtail.i18n.loadTranslationsFromPackageMoFiles('gedit')
# Load the UTF-8 demo file. Use codecs.open() instead of open().
from os import environ, path
environ['LANG']='en_US.UTF-8'
if not path.isfile(path.join(path.expandvars("$HOME"), "Desktop", "wordList")):
print "Please put file \"wordList\" in your $HOME/Desktop"
raise IOError,'File not exists'
# Load our persistent Dogtail objects
import dogtail.tc
TestString = dogtail.tc.TCString()
from codecs import open
try:
wl = open(path.join(path.expandvars("$HOME"), "Desktop", "wordList"))
except IOError:
raise IOError, 'Can not open worldList'
#start stardict
run('stardict')
focus.application('stardict')
click('dialog information')
click('Clear')
#screenshot()
while True:
#get the word from wordList
word = wl.readline()
#End of wordList
if len(word) == 0:
break
focus.text()
#query the word and sleep to show the result
focus.widget.text = word
sleep(2)
#clear the text
click('Clear')
wl.close()
#test gtk-undo, go back, and go forward
print "query the previous word in the list"
click('gtk-undo')
sleep(2)
#screenshot()
print "query the previous word in the dictionary"
click('go back')
sleep(2)
print "query the next word in the dictionary"
click('go forward')
sleep(2)
print "query the next word in the dictionary"
click('go forward')
sleep(2)
click('quit')
阅读(2988) | 评论(0) | 转发(0) |