当前位置: 首页 > news >正文

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及以上版本

 

http://www.lryc.cn/news/115148.html

相关文章:

  • 面试热题(LRU缓存)
  • 微信小程序开发【从0到1~入门篇】2023.08
  • P1398 [NOI2013] 书法家
  • 【构建卷积神经网络】
  • SSH 认证原理
  • 基于DETR (DEtection TRansformer)开发构建MSTAR雷达影像目标检测系统
  • Java分布式微服务1——注册中心(Eureka/Nacos)
  • (文章复现)建筑集成光储系统规划运行综合优化方法matlab代码
  • 【Redis】——RDB快照
  • 微服务监控技术skywalking的部署与使用(亲测无坑)
  • DLA 神经网络的极限训练方法:gradient checkpointing
  • python excel 操作
  • 记一次Linux启动Mysql异常解决
  • ATFX汇市:美联储年内或仍将加息依次,美指向下空间不大
  • 【博客687】k8s informer的list-watch机制剖析
  • 用Python获取链家二手房房源数据,做可视化图分析数据
  • Yield Guild Games:社区更新 — 2023 年第二季度
  • Stable Diffusion - 运动服 (Gymwear Leggings) 风格服装与背景的 LoRA 配置
  • js-7:javascript原型、原型链及其特点
  • 无涯教程-Perl - continue 语句函数
  • 【贪心算法】leetcode刷题
  • PyMySQL库版本引起的python执行sql编码错误
  • 第二章-算法
  • ‘vue’不是内部或外部命令,也不是可运行的程序或批处理文件的原因及解决方法
  • HBase API
  • Qt6之QListWidget——Qt仿ToDesk侧边栏(1)
  • Prometheus技术文档--基本安装-docker安装并挂载数据卷-《十分钟搭建》
  • Android 数据库之GreenDAO
  • kotlin 编写一个简单的天气预报app(六)使用recyclerView显示forecast内容
  • jpa Page 1 of 0 containing UNKNOWN instances错误关于like问题的解决记录