欢迎来到天天文库
浏览记录
ID:21618408
大小:58.42 KB
页数:19页
时间:2018-10-19
《sikuli常见问题解决》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Sikuli常见问题常见问题如何实现拖拽如何操作下拉列表框如何在脚本中使用中文如何在log中显示日期如何将数字转换成字符串如何定义全局变量Sikuli打不开怎么办如何更改匹配相识度如何指定一个相对位置并点击如何设置鼠标移动延迟如何等待一个图像的出现如何取得一个图像的坐标如何实现拖拽ip=App("iPhoneSimulator")ip.focus()ipw=ip.window()#ipw.highlight(2)bottom="1318343141834.png"#seecommentmBottom=ipw.find(bottom)p
2、=mBottom.getTopLeft().above(10).right(15)hover(p)mouseDown(Button.LEFT)mouseMove(p.above(100))mouseUp()whilenotipw.exists(image-of-delete-button,0): hover(p) mouseDown(Button.LEFT) mouseMove(p.above(100))#chooseyourstepping mouseUp() wait(1)click(ipw.
3、getLastMatch())#shouldclickdeletebuttonTheonlymodificationneededistousebelowinsteadofdownx1,y1,x2,y2=(100,100,500,600)start=Location(x1,y1)end=Location(x2,y2)stepX=10#adjustthisasneededstepY=int((y2-y1)/((x2-x1)/stepX))run=startmouseMove(start);wait(0.5)mouseDown(Butt
4、on.LEFT);wait(0.5)whilerun.getX())ifdd: click(dd)#openslist sleep(0.5)#toavoidtimingp
5、roblems type(Key.DOWN)#heregoesyournavigation type(Key.ENTER)else: popup("Sorry,nodropdownfound")youmayfind,thatyourdropdownentryisfoundevenifthecontentisnotexactly,whattheimagesays.Totestdifferentsituations,producethesesituationsandthenusepreview(clickontheimagein
6、theIDE).Playaroundwiththesimilarityslider.ifyouclickok,yourimageisturnedintoapatternobject(pattern(image).similar(decimalbetween0and1).Youcanuseitdirectly(useinsteadoffind():find(Pattern().similar(0.8))#thestandardinthemomentis0.73thismeans:onlyfindimageswitha
7、similarityofatleast0.8Thishelpedintheexampletoassure,thatthedropdownwasonlyclickedwhenshowing:byrelevancy.如何在脚本中使用汉字请参考http://www.python.org/dev/peps/pep-0263/解决方案:在脚本文件的前面添加如下代码:#!/user/bin/python#-*-coding:utf-8-*-(必须放在脚本文件的第一行,试过)如何在log中显示日期解决方案:importdatetimenow=datetime
8、.datetime.now()printnow.strftime('%Y-%m-%d%H:%M:%S')如何将数字转换成字符串参考htt
此文档下载收益归作者所有