Tidevice is an iOS automation tool developed by an internal team of Alibaba, using pure Python to reverse the iOS communication protocol. At present, Taobao and other business divisions have fully used this technology to collect performance of iOS applications and automate UI.

Note: The application under test does not need to be modified and is not limited to Mac.

Open source address:

Github.com/alibaba/tao…

What can TiDevice do for you?

Install, start, stop, and view applications

Start WDA (WebDriverAgent) (Note: this operation does not depend on XcodeBuild and can be used across platforms)

Running UITests (cross-platform)

Performance collection (similar to PerfDog)

Screenshots, syslog collection and so on

Those familiar with the LibiMobileDevice toolset may know most of the functions mentioned above. In order to facilitate the daily use of TiDevice, the existing functions in LibiMobileDevice have been re-implemented (such as screenshots, viewing logs, application installation). So with TiDevice you can do all the daily operations.

In addition to these well-known features, TiDevice can also complete the launch of WDA, performance capture for iOS devices.

Some people may not know what WDA is, here is a brief introduction. WDA (WebDriverAgent) is a facebook project designed to automate black box iOS. As an App, the project runs on iOS phones, and the tested application does not need to make any changes (such as access to SDK) for non-invasive testing. The only inconvenience is that the phone has to be connected to a Mac and use XCodeBuild, which is only available on the Mac, to run WDA, which makes it difficult to promote.

This article will focus on how TiDevice accomplishes WDA startup. The principle is simple: TiDevice communicates with the phone by emulating XCodeBuild and sending specific commands to the phone to start WDA, which allows it to run iOS automation on Linux and Windows without Mac restrictions, something it couldn’t do before TiDevice.

The installation

Pip3 install -u tidevice pip3 install -u tidevice Run a few commands to test tidevice version. Check the tiDevice version. Check the tiDevice list

Common commands

Tidevice install example.ipa

Install the app using the URL (change the URL to the correct one for actual use) tiDevice install example.org/demo.ipa

The app starts tiDevice Launch com.apple.Preferences

Screenshot tidevice screenshot.jpg

View system logs tidevice syslog

Other commonly used commands help command view, basically commonly used commands have tidevice -h

Start the WebDriverAgent

At present, the most popular way of iOS black box automation is through WDA. Before TiDevice, WDA could only be started with XcodeBuild, and running XcodeBuild required a Mac.

Instead of using XcodeBuild, TiDevice uses USBMUxD to communicate directly with the service on the phone to start WDA on the phone. Usbmux has open source implementations on different platforms, so TiDevice runs not only on Mac, but also on Linux and Windows.

Apple, of course, won’t tell us anything about the USBMUX protocol. But because usBMUx is a socket itself, we can intercept its content, and most of it has been cracked, according to the open source community. Start WDA once with XcodeBuild, then find the key communication, and use Python to simulate and play it back.

Compared to XCodeBuild, TiDevice starts faster (around 2s) and is more stable due to streamlined communication.

A bunch of theories. Let’s see how it works, shall we

The premise condition

The cable connects the iPhone to the PC

You already have WebDriverAgent on your phone. This can be installed using xcode compiled source code or webDriverAgent. ipa re-signed with the developer certificate.

Linux and Windows do not have the USBMUx service by default, so you can install it in advance. Refer to this issue:

Github.com/alibaba/tao…

Once the prerequisites are OK, you can start WDA by executing commands as shown in the following figure.

And verify whether the WDA work the simplest way is to open a browser, web site: http://localhost:8100/status to see the following output shows WDA work as normal

Or you can use Appium scheduling directly

Run UITests

Some users may have strong development ability and are used to writing UI automation cases directly with OC or Swift. It is also supported through TiDevice.

XCTest UITests Demo project written by OC github.com/FeiHuang93/… Once compiled and installed on the phone with Xcode, there are two applications

TestXCTestUITests Applications that perform tests

TestXCTest Application to be tested

Run the following command

tidevice xctest –bundle-id philhuang.testXCTestUITests.xctrunner –target-bundle-id philhuang.testXCTest

Once the application under test and the application under test are packaged into an IPA, it can run on multiple phones.

conclusion

Now this project is in good use inside Ali, hope to welcome more trial feedback. If it works, I hope you can leave your Star github.com/alibaba/tao…

  • Author: Sun Shengxiang
  • Source: Tao Technology public account