tidevice+appium在windows系统实施iOS自动化

之前使用iOS手机做UI自动化都是在Mac电脑上进行的,但是比较麻烦,后来看到由阿里开源的tidevice工具可以实现在windows上启动WDA,就准备试一下,记录一下过程。

tidevice的具体介绍可以参考一下这篇文章:tidevice 开源:不依赖 Xcode 也能启动 WDA · TesterHome
https://testerhome.com/topics/27758

环境准备

使用tidevice需要用到的环境包括:

python

tidevice

iTools

appium v1.20.0以上

已经安装WDA的iOS真机

安装tidevice

安装好python环境后,使用以下命令安装tidevice
pip3 install -U tidevice

安装后输入命令tidevice version查看版本

命令tidevice list查看连接的设备

命令tidevice applist查看设备上安装的应用

启动WDA

使用命令tidevice -u [设备udid] wdaproxy -B [wda的bundleid] --port 8100启动WDA

此时在浏览器中打开地址http://127.0.0.1:8100/status ,显示如下信息就表示WDA启动正常了

使用Appium+tidevice进行自动化

在appium配置中参照以下设置:

{

"platformName": "ios",

"deviceName": "iPhone",

"platformVersion": "13.6",

"bundleId": "目标app的bundleid",

"udid": "iphone的udid",

"webDriverAgentUrl": "http://localhost:8100",

"noReset": true,

"usePrebuiltWDA": false,

"useXctestrunFile": false,

"skipLogCapture": true,

"automationName": "XCUITest"

}

例如:

package testcase;

import io.appium.java_client.ios.IOSDriver;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.remote.DesiredCapabilities;

import org.openqa.selenium.support.ui.WebDriverWait;

import java.net.MalformedURLException;

import java.net.URL;

import java.util.function.Function;

public class IosTest {

private static IOSDriver iosDriver;

public static void main(String[] args) throws MalformedURLException {

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability("udid", "设备序列号");

capabilities.setCapability("deviceName", "设备名称");

capabilities.setCapability("platformVersion", "11.3");

capabilities.setCapability("bundleId", "被测应用的bundleId");

capabilities.setCapability("webDriverAgentUrl", "http://localhost:8100");

capabilities.setCapability("usePrebuiltWDA", "false");

capabilities.setCapability("useXctestrunFile", "false");

capabilities.setCapability("skipLogCapture", "true");

capabilities.setCapability("platformName", "iOS");

capabilities.setCapability("automationName", "XCUITest");

iosDriver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

WebElement element = findElement(iosDriver, "//XCUIElementTypeButton[@name='理财']");

element.click();

element = findElement(iosDriver, "//XCUIElementTypeStaticText[@name='全部']");

element.click();

}

private static WebElement findElement(WebDriver driver, String xpath){

WebDriverWait wait = new WebDriverWait(driver, 60);

return wait.until(new Function<WebDriver, WebElement>() {

public WebElement apply(WebDriver webDriver) {

return webDriver.findElement(By.xpath(xpath));

}

});

}

}

遇到的问题

1.最开始使用appium1.15.1,创建driver时appium一直报错

后来才发现tidevice要求appium要在1.20.0及以上版本

相关推荐
Haha_bj5 分钟前
Flutter ——flutter_screenutil 屏幕适配
android·ios
Haha_bj23 分钟前
Flutter ——device_info_plus详解
android·flutter·ios
雨中风华4 小时前
Linux, macOS系统实现远程目录访问(等同于windows平台xFsRedir软件的目录重定向)
linux·windows·macos
山水域5 小时前
SKAdNetwork 6.0 深度实战:多窗口转化值(Conversion Value)建模与数据分层架构
ios
yuuki2332335 小时前
【C++】继承
开发语言·c++·windows
非凡ghost6 小时前
PowerDirector安卓版(威力导演安卓版)
android·windows·学习·软件需求
JavinLu6 小时前
ios 配置了代理且使用 chls.pro/ssl 下载不了证书,无法弹出下载证书的提示问题
网络协议·ios·ssl
G31135422738 小时前
免费苹果 Plist 文件在线制作 iOS IPA 安装工具
ios
疯狂敲代码的老刘8 小时前
JDK 1.6到25 全版本网盘合集 (Windows + Mac + Linux)
java·linux·windows·macos·jdk
love530love9 小时前
Windows 下 GCC 编译器安装与排错实录
人工智能·windows·python·gcc·msys2·gtk·msys2 mingw 64