AutoIt实现selenium上传文件

1,安装autoIt

2,工程中建文件夹,例如:script,将autoit 复制到该文件夹,并且编辑视频所在的文件夹的路径,编辑“au3”格式的文件

 

3,编辑完成后生成EXE文件(工具自带转换器,转换即可),将AUTOIT文件(au3格式)和刚刚生成的EXE文件放入工程文件夹中;

4,脚本即可调用该软件

 

        phoExePath = curPath + Dom4jXml.getValue("SICK_FIRPHO_PATH");

           Reporter.log(phoExePath);

 

           WebElement addfire = driver.findElement(By.id("qiniuFile"));

           addfire.click(); 

           Thread.sleep(3000);

           try {

              //调用autoit exe来上传照片

              Runtime.getRuntime().exec(phoExePath);

              Thread.sleep(5000);

           } catch (IOException e) {

              Reporter.log("[ERROR]"+e);

              //ScreenShotPC.screenShot("PublishSickCaseWebElements.publishSickCase");

              Assert.fail(e.toString());

           }

5,INIT.xml的文件内容(xml文本参数)

 

<?xml version="1.0" encoding="UTF-8"?>

<!--PC启动配置参数-->

<infos>

   <capabilities>

    <SICK_FIRPHO_PATH>\\script\\addVideo.exe</SICK_FIRPHO_PATH>

   </capabilities>

</infos>

 

 

 

参数中包括的exe文件在工程中所在目录

 

posted @ 2016-12-12 10:30  "花田李氏  阅读(310)  评论(0编辑  收藏  举报