Java+Selenium+Sikulix定位web系统中的swfupload上传控件
图形化自动化测试软件Sikulix
1、下载Sikulix控件java语言相关Jar包
2、将sikulixapi.jar包build path到项目中
3、创建一个demo
package com.yunxiao.testidsp; import org.sikuli.script.*; public class TestSikuli { public static void main(String[] args) throws FindFailed { Screen screen=new Screen(); String imgPath="/Users/****/Desktop/WorkFile/TestJavaIDSP/SikuliDemo/resource/"; //双击谷歌图标 screen.doubleClick(imgPath+"chrome.png"); } }
4、对于上传控件swfupload操作一样。例子如下:
//调用sikuli-x
Screen screen=new Screen(); String imgPath="/Users/******/Desktop/WorkFile/TestJavaIDSP/SikuliDemo/resource/"; screen.doubleClick(imgPath+"screen.png"); Thread.sleep(1500); //进入桌面 screen.click(imgPath+"desktop.png"); Thread.sleep(1500); //搜索导入文件 screen.type(imgPath+"search.png", "Stu"); Thread.sleep(1500); //点击文件 screen.click(imgPath+"file.png"); Thread.sleep(1500); //点击打开 screen.click(imgPath+"open.png"); Thread.sleep(2000); //点击确定上传 screen.click(imgPath+"confirm.png");