Autoit 工具的使用

2017年4月5日 263点热度 0人点赞 0条评论

在我们实现自动化的过程中经常遇到有些动作没法完成,比如遇到上传功能,这个就有windows窗口的弹出,而我们用的是web自动化工具,所以就有局限性了,这时,我们就可以用Autoit工具去实现它,下面就简单介绍下:


1)安装 setup.exe

2)录制工具在下面这个路径

图片

3)录制

图片

 4)没法直接回放,需要保存脚本,再编译下

图片

 5)网页保持之前的最大化去操作。这个工具是基于坐标来实现的,所以弊端还是很大,比如你录制的放在别人的电脑上,由于分辨率不同录制的也就不同了。

6)Autoit的元素识别功能,这个很重要

图片

图片

长按 移动就可以获取

这个元素很重要这是一个唯一属性

图片

7)了解更多我们可以去开始菜单,这里有个手册

图片

图片

 ControlClick点击

图片

 package testng_study;

import java.io.IOException;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.testng.annotations.AfterMethod;

import org.testng.annotations.BeforeMethod;

import org.testng.annotations.Test;

public class Audiot {

private WebDriver driver;

private String url;

@BeforeMethod

public void beforeMethod() {

System.out.println("beforeMethod");

System.setProperty("webdriver.chrome.driver",

"C:\\Driver\\chromedriver.exe");

driver = new ChromeDriver(); // 初始化chrome

url = "file:///C:/Users/Lipin/workspace/guoliping_selenium/content/autotest.html";

}

@Test

public void test001() {

System.out.println("test001");

driver.get(url);

driver.findElement(By.name("file")).click();

autoit("D:\\Autoit\\upload.exe");

}

private void autoit(String cmd) {

// TODO Auto-generated method stub

try {

System.out.println("autoit");

Runtime.getRuntime().exec(cmd);

} catch (IOException e) {

e.printStackTrace();

}

}

@AfterMethod

public void afterMethod() throws InterruptedException {

Thread.sleep(3000);

driver.quit();

}

}

 关注更多!!!!

图片

 

 

52210Autoit 工具的使用

这个人很懒,什么都没留下

文章评论