如何在iOS上更快地运行appium测试? [英] How to make appium tests run faster on iOS?

查看:480
本文介绍了如何在iOS上更快地运行appium测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在使用appium进行iOS应用程序测试,我在mac mini机器上用Java编写了测试。我正在使用Jenkins CI来运行我的测试。我想更快地运行我的测试,因为它在iOS模拟器上非常慢。例如,如果我通过sendkeys()函数在textfield中输入任何值,如'testdata'那么在模拟器中输入速度很慢。它先从模拟器的键盘上写下't'然后'e'然后's'等等。

Currently, I am using appium for iOS app testing and I have written tests in Java on mac mini machine. I’m using Jenkins CI to run my tests. I want to run my tests faster as currently its quite slow on iOS simulator. For example, if I enter any value in textfield via sendkeys() function like ’testdata’ then typing speed in emulator is slow. It first write character ’t’ then ‘e’ then ’s’ and so on from simulator’s keyboard.

以下是我的问题,


  1. 我有没有办法执行我的测试通过sendkeys()函数进入文本字段时,模拟器上的速度更快,特别是

  2. 我有没有办法在没有模拟器的情况下以无头方式运行我的测试?


推荐答案

不要在iOS上使用发送密钥



你实际上不应该使用 sendKeys ,因为它很慢且很无聊。

Don't use send keys on iOS

You're actually not supposed to use sendKeys on iOS because it's slow and flakey.

你应该为Java使用 setValue 用于ruby lib的lib和类型

You're supposed to use setValue for the Java lib and type for the ruby lib

setValue 在Java库中定义这里

setValue is defined in Java library here.

它应该在WebElement上调用。

It is meant to be called on a WebElement.

driver.find_element(By.locator(value)).setValue("foo")



使用iOS模拟器是运行测试的最佳选择



仪器与您的应用程序交互需要实时模拟器或真实设备*。您可以遵循一些最佳实践来改进测试代码,这可能会使测试更快。

Using the iOS Simulator is the best option for running tests

A live simulator or real device* is required for Instruments to interact with your application. There are some best practices you can follow to improve your test code which will likely make the tests quicker.


  1. 不要使用sleeps来尝试等待元素 - 而是不断轮询驱动程序以查看元素是否显示且可点击。

  2. 使用 setValue 而不是sendKeys

  3. 停止使用Xpath定位器策略。它在iOS上很有趣而且很慢。使用UIAutomation或AccessibilityId定位器策略。

  4. 仅在需要与元素交互时获取元素

  1. Do not use "sleeps" to try and wait for an element -- instead constantly poll the driver for if the element is displayed and clickable.
  2. Use setValueinstead of sendKeys
  3. Stop using Xpath locator strategy. It is flakey and slow on iOS. Use UIAutomation or AccessibilityId locator strategy.
  4. Only get the elements when you need to interact with them



< h3> *不建议使用Real Devices for iOS(当性能很重要时)

自动化真实设备在每次操作之间都有一秒的内置延迟。

*Using Real Devices for iOS is not suggested (when performance matters)

Automating a real device has a builtin delay of one second between every action.

无论Appium服务器有多快,或者您的测试脚本是多少,Appium将执行命令推送到仪器工作队列和执行时都会有延迟设备。

No matter how quick the Appium server is, or your test script is, there is a delay between when Appium pushes the "execute" command to the instruments work queue and when it is executed on the device.

这篇关于如何在iOS上更快地运行appium测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆