免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2412 | 回复: 0
打印 上一主题 下一主题

一个简单的stardict的自动测试脚本(基于dogtail) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-04 15:59 |只看该作者 |倒序浏览
系统环境:
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')
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/12325/showart_150896.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP