zoukankan      html  css  js  c++  java
  • RF+Selenium2Library+Sikuli集成环境搭建

    Sikuli是通过截图来编写代码的脚本语言,他是对于Selenium不好处理的一些模态窗口、flash等的利器。废话少说,直接开始安装吧。安装RF+Selenium2Library的环境这里就不说了,不会的看一下http://blog.csdn.net/xc5683/article/details/10017915这篇文档就好了。

    1、安装Sikuli http://sikuli.org,去官网直接下载Sikuli-X-1.0rc3 (r905)-win32.exe安装就可以了。安装它之前需要先安装Java。

    2、安装Jython环境:官网http://www.jython.org,下载jython-installer.jar。安装方法:java -jar jython-installer-2.5.3.jar

    安装好之后,将c:jython2.5.3in目录加入到path环境变量中。

    3、配置rf远程调用sikuli环境:

    a、新建一个文件夹c: f_sikuli

    b、将sikuli安装目录下的C:Program FilesSikuli Xsikuli-script.jar拷贝到c: f_sikuli下

    c、下载文件http://robotframework.googlecode.com/hg/tools/remoteserver/robotremoteserver.py到c: f_sikuli中

    d、在c: f_sikuli下新建文件SikuliRemoteLibrary.py,文件内容如下:

    import sys  
    from robotremoteserver import RobotRemoteServer  
    from org.sikuli.script import *  
      
    class SikuliRemoteLibrary:  
      
        def __init__(self):  
            self.SS = Screen()  
            self.PT = Pattern()  
      
        def _wait(self, imgFile, timeOut, similarity):  
    		try:  
    			self.PT = Pattern(imgFile)  
    			self.PT = self.PT.similar(float(similarity))  
    			self.SS.wait(self.PT, float(timeOut))  
    		except FindFailed, err:  
    			print "ERR: _wait"  
    			raise AssertionError(err)  
      
        def click_object(self, imgFile, timeOut, similarity):  
    		try:  
    			self._wait(imgFile, timeOut, similarity)  
    			self.SS.click(imgFile)  
    		except FindFailed, err:  
    			raise AssertionError("Cannot click [" + imgFile + "]")  
      
        def object_exists(self, imgFile, similarity, timeOut):  
    		try:  
    			self._wait(imgFile, timeOut, similarity)  
    		except FindFailed, err:  
    			raise AssertionError("Could not find [" + imgFile + "]")  
      
        def type_at_object(self, imgFile, txt, timeOut, similarity):  
    		try:  
    			self._wait(imgFile, timeOut, similarity)  
    			self.SS.type(imgFile, txt)  
    		except FindFailed, err:  
    			raise AssertionError("Cannot type at [" + imgFile + "]")  
      
        def paste_at_object(self, imgFile, txt, timeOut, similarity):  
    		try:  
    			self._wait(imgFile, timeOut, similarity)  
    			self.SS.paste(imgFile, txt)  
    		except FindFailed, err:  
    			raise AssertionError("Cannot paste at [" + imgFile + "]")  
      
    if __name__ == '__main__':  
        SRL = SikuliRemoteLibrary()  
        RobotRemoteServer(SRL, *sys.argv[1:])  


    e、将c: f_sikuli目录添加到CLASS_PATH环境变量下

    f、打开cmd,到c: f_sikuli目录下,执行jython.bat SikuliRemoteLibrary.py

    如果出现:Robot Framework remote server starting at localhost:8270,说明配置成功,可以使用了

    如果出现:no named module sikuli的错误,请将sikuli-script.jar解压一下就可以了(注意解压选择解压到当前文件夹就可以)

    4、RIDE中使用sikuli

    a、在RIDE中新建一个测试用例

    b、需要加入Remote和Screenshot库


    c、在用例中直接写用例就可以了




  • 相关阅读:
    TabControl添加关闭按钮
    Windows & RabbitMQ:集群(clustering) & 高可用(HA)
    Windows & RabbitMQ:Shovel
    15项最佳电子产品影响人类未来
    收藏很久的开关电源书籍
    我也不想这样(转载)
    vbs 脚本轻松搞定JDK的环境变量配置
    开关电源基本知识
    浅谈软件开发定律系列之帕金森定律(Parkinson’s Law)
    堕落的时候看看——清华大学老师的一席话
  • 原文地址:https://www.cnblogs.com/pangblog/p/3306215.html
Copyright © 2011-2022 走看看