sikuli环境搭建及使用

1、下载sikuli安装包
链接:https://pan.baidu.com/s/1ltoqdzZtmottc0geVj6vBQ
提取码:6975

解压缩就可以使用

2、使用必需安装jre6以上版本
链接:https://pan.baidu.com/s/1tCxuE3717EkuGa8e9r60HQ
提取码:791m

配置环境变量,jre bin路径
C:\Program Files (x86)\Java\jre6\bin

3、sikuli使用
1、findAll(图片)

findAll() searches the entire screen for all the matchingvisual patterns and returns a list of locations of those similar patterns. Thiscapability allows us to obtain all the checked items are on the screen. Then,we can simply write a for loop in standard Python syntax and call click() oneach element in the list.
在这里插入图片描述
典型例子:Uncheck AllCheckboxes

2、点击操作

click(x)

左键点击元素x

rightClick(x)

右键点击元素x

3、below()
在这里插入图片描述在这里插入图片描述

4、dragDrop()

This function takes two images asarguments. The first image describes the source GUI object to drag and thesecond image describes the appearance of the destination location where the GUIobject should be dragged to and dropped.
在这里插入图片描述
典型例子:Working with Sliders

5、right()
在这里插入图片描述

表示在右边

6、popup(string)

弹出一个提示框
例:
popup(“Obama has updated his message”)
运行:
在这里插入图片描述

7、键盘操作:
在这里插入图片描述
8、Resizinga Window

This tutorial demonstrates how to use Sikuli script to resize a window by dragging its bottom-right corner.
In order to do so, you have to evaluate the current position of this corner on the screen,
move the mouse pointer to the applicable click point and then perform one or more drag actions.
在这里插入图片描述

9、表示方位的词:

Nearby(number)、above()、below()、left()、right()、getCenter()

10、位置偏移

Location(t.x-30,t.y+30)

其实用图形法会方便和舒服:点击图片,进入设置界面,点击偏移选项卡,然后可以用鼠标设置偏移量,点到哪就偏移到哪,如果想偏移到更远的地方,就滚动鼠标滑轮,可以放大缩小页面,选择偏移点。

11、屏幕翻页

其他键盘操作类型参数见Key (built-in class)

12、读写文件(其实就是python的语法)

#打开 写文件

f=open(‘c:/wy.txt’,‘a’)

t=“hello\n”

f . write(t)

f.close()

#打开 读文件

f=open(‘c:/wy.txt’,‘r’)

t=f.read()

popup(t)

#open(路径+文件名,读写模式)

#读写模式:r只读,r+读写,w新建(会覆盖原有文件),a追加,b二进制文件.常用模式

13、input(“字符串”)

显示一个输入框,以供输入。要输入中文应该在前面加u

即input(u“字符串”),不然会乱码

14、if语句

If 条件 and 条件:#(注意有冒号,‘#’号表示注释)

   语句

15、openApp(应用程序路径名)

打开应用程序,注意应用程序的路径名里的斜杠“\”要改为双斜杠“\”。

16、复制、粘贴操作

type(“c”,KEY_CTRL) #复制

type(“v”,KEY_CTRL) #粘贴

17、waitVanish(“20120902172907.png”,300)

waitVanish()最好带时间,不然还没消失就返回消失的信息了。

我觉得用下面的代替好些

while exists(“image.png”):
wait(1) #ifthe image exist it will wait until the image disappear

18、sikuli输入中文

input(u"请输入想要获取并下载多少个页面的App资源:")

popup(u”chinese”)

在前面加‘u’避免乱码,‘u’是unicode还是utf8,我就不清楚了。

19、设定循环次数

for x inrange(10): #循环10次,x不用预先定义

   循环体

20、编程小经验

1、用sikuli编程的时候,最好是保存为可执行文件来测试,因为有些功能直接测试是测试不出来的,比如type(“c”,KEY_CTRL) #复制,直接运行测试(好像)是无效的,当时我还困惑了很久。后来无意中保存为可执行文件后才发现是可以的。

2、用sikuli编程时,多用wait()语句,因为很多时候没有给它一定的识别时间,就容易出错。

还有的就是,进行复制粘贴操作时,如果需要切换到另外一个页面粘贴,再切回来,如果中间不wait一段时间,等粘贴完成,很可能就没有粘贴成功。

转载:https://blog.csdn.net/airfer/article/details/47726939

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值