1、安装 Application Driver 下载
Application Driver直接安装地址:
https://github.com/Microsoft/WinAppDriver/releases
安装完成后,默认在系统的:
C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe
2、 inspect.exe 可视化定位元素软件
这个工具是用来查看运行软件(uwp、win32、win form、wpf)
的 UI 元素的 Name、ID、Text 等等。包含在 Windows SDK 中。
安装完 Visual Studio2015后,可以在 C盘下找到:
C:\Program Files (x86)\Windows Kits\10\bin\x64\inspect.exe
3、安装 Windows SDK 下载
https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk
4、需要 Win10 环境
开启开发人员模式(设置-》更新和安全-》针对开发人员-》开发人员模式)
5、安装 node.js,npm,appium
node和 npm下载安装:
http://nodejs.org/
appium安装命令:
cnpm install -g appium
maven 依赖
<dependencies>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>4.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<version>1.1</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
代码
private static RemoteWebDriver rw = null;
public static void main(String[] args) throws Exception{
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("platformName","Windows");
cap.setCapability("deviceName","WindowsPC");
cap.setCapability("app","C:\\Users\\Administrator\\Desktop\\XXXXX\\XXXX.exe");
rw = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),cap);
rw.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}