Coder Social home page Coder Social logo

atxserver2-ios-provider's Introduction

atxserver2-ios-provider

Apple device provider for atxserver2. iOS真机管理

Requirements

  • Python >= 3.6
  • WebDriverAgent(appium)
  • NodeJS 8

Appium 1.9.0 在WDA中新增了一个 mjpegServer,这个用来做屏幕同步感觉很方便。

所以这里的WebDriverAgent我们使用了appium修改的

Install

安装libimobiledevice工具包

brew uninstall --ignore-dependencies libimobiledevice
brew uninstall --ignore-dependencies usbmuxd

brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd

brew install --HEAD libimobiledevice
brew install ideviceinstaller
brew link --overwrite ideviceinstaller

下载安装atxserver2-ios-provider, 并初始化其中的ATX-WebDriverAgent

git clone https://github.com/openatx/atxserver2-ios-provider
cd atxserver2-ios-provider

# install dependencies
pip3 install -r requirements.txt
npm install # 如遇到错误,请检查是否是NodeJS 8
  • 启动方式1:使用 xcode 工程自动启动 WebDriverAgent

WebDriverAgent的初始化。目前项目中已有的WebDriverAgent有点老了。推荐使用appium的Fork的版本。

brew install carthage

git clone https://github.com/appium/WebDriverAgent Appium-WebDriverAgent
cd Appium-WebDriverAgent && ./Scripts/bootstrap.sh
open WebDriverAgent.xcodeproj

然后找台手机接到苹果电脑上。 按照这个文档https://testerhome.com/topics/7220 对WebDriverAgent项目进行下设置。 有条件的话还是弄一个苹果的开发者证书比较方便。个人可以用免费的证书(需要修改BundleID),另外隔几天证书就会过期。

每台设备都需要先用xcode,注册下,能跑起来WDA test,弄完之后接着往下看。

命令行

# export USER_PORT=8100 # WDA监听端口
# export MJPEG_SERVER_PORT=9100 # MJPEG-SERVER端口

# 避免命令行运行出错,运行一次即可
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

# 解锁keychain,防止签名权限不足问题
security unlock-keychain ~/Library/Keychains/login.keychain
# security unlock-keychain -p $PASSWORD ~/Library/Keychains/login.keychain

# test if wda can run?
# xcodebuild -project WebDriverAgent.xcodeproj \
#            -scheme WebDriverAgentRunner \
#            -destination 'platform=iOS Simulator,name=iPhone 6' \
#            test

SERVER_URL="http://localhost:4000" # 这里修改成atxserver2的地址
WDA_DIRECTORY="./Appium-WebDriverAgent" # WDA项目地址
python3 main.py -s $SERVER_URL -W $WDA_DIRECTORY
  • 启动方式2:手动通过外部程序启动

如果使用 tidevice 等别的方式手动启动 wda ,启动命令需加上 --manually-start-wda 阻止 atx 启动 wda。

  • 启动方式3:自动通过 tidevice 启动

好处:只要事先在手机上装好 wda ,电脑就可以不用再弄 wda 了。

pip3 install -U "tidevice[openssl]" # 安装 tidevice ,python 版本需要 > 3.6。详情参考 https://github.com/alibaba/taobao-iphone-device

# 确认 tidevice 可用
tidevice -v

# 启动应用
SERVER_URL="http://localhost:4000" # 这里修改成atxserver2的地址
WDA_BUNDLE_PATTERN="*WebDriverAgent*" # WDA bundle id 通配符
python3 main.py -s $SERVER_URL --use-tidevice --wda-bundle-pattern $WDA_BUNDLE_PATTERN

会自动通过 tidevice -u <UUID> wdaproxy -B <WDA_BUNDLE_PATTERN> --port 0 在连上设备后启动设备上的 wda

Developer 开发人员备注

appium-WebDriverAgent一些API说明

设备设置

参考: http://docs.quamotion.mobi/cloud/on-site/connecting-ios-devices/

2022-01-05:目前已支持模拟器,可以直接使用无需安装 wda 。感谢 @Vancheung 提供的 PR

连接iOS设备

  1. 确保设备已经解锁
  2. 使用数据线将苹果手机连接到电脑上(Mac)
  3. 当出现是否信任该设备时选择

设备开启自动化

  1. 按下HOME -> 设置(Settings) -> 开发者(Developer) -> Enable UI Automation
  2. 回到 设置(Settings) -> Safari浏览器 -> 翻到最后 高级(Advanced) -> 打开 Web检查器(Web inspector)
  3. 设置(Settings) -> 通用 -> 设备管理 -> 点击开发者应用中的栏目

持续运行的设备设置

默认情况下设备会锁屏的,而当设备锁屏的时候,就自动化不了了。最简单的一个办法就是保持设备常亮

  1. Home -> 设置(Settings) -> 显示与亮度(Settings & Brightness)
  2. 亮度调到低(可以是最低)
  3. 自动锁定(Auto-Lock) 设置为 永不(Never)

References

LICENSE

MIT

atxserver2-ios-provider's People

Contributors

chenhengjie123 avatar codeskyblue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atxserver2-ios-provider's Issues

IOS多个手机每次编译测试都停留卡在这一步

Test Case '-[UITestingUITests testRunner]' started.
t = 0.00s Start Test at 2019-05-21 17:49:34.560
t = 0.03s Set Up
2019-05-21 17:49:34.636460+0800 WebDriverAgentRunner-Runner[804:489681] Built at May 21 2019 17:48:37
2019-05-21 17:49:34.712818+0800 WebDriverAgentRunner-Runner[804:489681] ServerURLHere->http://172.21.14.177:8100<-ServerURLHere
2019-05-21 17:49:34.714397+0800 WebDriverAgentRunner-Runner[804:489787] Using singleton test manager
每次在xcode Build test设备到这里就卡住了,请问是什么情况?

运行错误Cannot find module 'mjpeg-consumer'

[D 190710 10:42:24 heartbeat:88] websocket send: {'udid': 'fa22e915edd5932b7dbad053fbab506651a1fead', 'provider': {'wdaUrl': 'http://10.211.55.3:20002'}, 'properties': {'ip': '10.168.1.172', 'version': '12.3.1', 'sdkVersion': '12.2'}, 'command': 'update', 'platform': 'apple'}
internal/modules/cjs/loader.js:628
throw err;
^

Error: Cannot find module 'mjpeg-consumer'
Require stack:

  • /Users/virtual/Desktop/atxserver2/atxserver2-ios-provider/wdaproxy.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Module.require (internal/modules/cjs/loader.js:683:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object. (/Users/virtual/Desktop/atxserver2/atxserver2-ios-provider/wdaproxy.js:16:23)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:839:10) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/Users/virtual/Desktop/atxserver2/atxserver2-ios-provider/wdaproxy.js'
    ]
    }
    [D 190710 10:43:25 idb:261] [fa22e..ad:“hp”的 iPhone-iPhone 7 Plus] is fine

尝试通过npm install mjpeg-consumer 也是无法安装这个模块

连接iphone设备 显示离线状态附日志

[D 210128 14:07:40 idb:400] [00008..2E:iPhone (2)-iPhone 11] waiting for wda
[D 210128 14:07:41 idb:397] [00008..2E:iPhone (2)-iPhone 11] request wda/status error: Stream closed
[W 210128 14:07:42 idb:366] [00008..2E:iPhone (2)-iPhone 11] process quit [(84252, 66), (84253, None), (84254, None)]
[D 210128 14:07:42 idb:239] terminate wda processes
[E 210128 14:07:42 idb:220] [00008..2E:iPhone (2)-iPhone 11] WDA unable to start
[D 210128 14:07:42 idb:239] terminate wda processes
[D 210128 14:07:42 heartbeat:88] websocket send: {'udid': '00008030-000E1DC401C1802E', 'provider': None, 'command': 'update', 'platform': 'apple'}

有人在Windows和Linux上接过iphone手机吗?可以直接在atxserver2里面展示吗?

目前我Windows上接入会提示报错,这个是iproxy命令在Windows上报错还是啥?想问一下有没有成功的案例可以参考呢?
[D 211209 19:09:10 idb:356] exec: tidevice -u "xxxx877a643ec5e986ccfb6ed1d24636d3685c0 iPhone7" wdaproxy -B ATX-WebDriverAgent --port 0
[D 211209 19:09:12 idb:356] exec: ./iproxy.sh 20000 8100 "xxxx877a643ec5e986ccfb6ed1d24636d3685c0 iPhone7"
ERROR:tornado.application:Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x03D1D5D0>>, <Task finished coro=<WDADevice.run_wda_forever() done, defined at D:\Python\atxserver2-ios-provider-master\idb.py:206> exception=OSError(8, '%1 ▒▒▒▒▒▒Ч▒▒ Win32 Ӧ▒ó▒▒▒', None, 193, None)>)
Traceback (most recent call last):
File "D:\python3.7.8\lib\site-packages\tornado\ioloop.py", line 741, in _run_callback
ret = callback()
File "D:\python3.7.8\lib\site-packages\tornado\ioloop.py", line 765, in _discard_future_result
future.result()
File "D:\Python\atxserver2-ios-provider-master\idb.py", line 215, in run_wda_forever
ok = await self.run_webdriveragent()
File "D:\Python\atxserver2-ios-provider-master\idb.py", line 343, in run_webdriveragent
silent=True)
File "D:\Python\atxserver2-ios-provider-master\idb.py", line 357, in run_background
p = subprocess.Popen(*args, **kwargs)
File "D:\python3.7.8\lib\subprocess.py", line 800, in init
restore_signals, start_new_session)
File "D:\python3.7.8\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
OSError: [WinError 193] %1 ▒▒▒▒▒▒Ч▒▒ Win32 Ӧ▒ó▒▒▒
[D 211209 19:09:12 heartbeat:88] websocket send: {'udid': 'xxxx877a643ec5e986ccfb6ed1d24636d3685c0 iPhone7', 'provider': None, 'colding': False, 'properties': {'name': '', 'product': 'Unknown', 'brand': 'Apple'}, 'command': 'update', 'platform': 'apple'}

[bug]ios14.2 ,设备横屏时获取坐标问题

image
如图,横屏时设备窗口会有留白。

image
点击涂红区域,实际获取的坐标并非设备屏幕应该点击的坐标。
我推测是计算方式有问题,从前端来看,不是按class canvas-bg来算的,而是class screen debugarea计算的。

使用node 8,npm install 出错问题

darindeMacBook-Pro:atxserver2-ios-provider darin$ nvm use 8.0.0
Now using node v8.0.0 (npm v5.0.0)
darindeMacBook-Pro:atxserver2-ios-provider darin$ npm install

> [email protected] install /Users/darin/Documents/auto-test/atxserver2-ios-provider/node_modules/buffertools
> node-gyp rebuild

ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
Traceback (most recent call last):
  File "/Users/darin/.nvm/versions/node/v8.0.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "/Users/darin/.nvm/versions/node/v8.0.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "/Users/darin/.nvm/versions/node/v8.0.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main
    return gyp_main(args)
  File "/Users/darin/.nvm/versions/node/v8.0.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 514, in gyp_main
    options.duplicate_basename_check)
  File "/Users/darin/.nvm/versions/node/v8.0.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 98, in Load
    generator.CalculateVariables(default_variables, params)
  File "/Users/darin/.nvm/versions/node/v8.0.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 77, in CalculateVariables
    import gyp.generator.xcode as xcode_generator
  File "/Users/darin/.nvm/versions/node/v8.0.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py", line 7, in <module>
    import gyp.xcodeproj_file
  File "/Users/darin/.nvm/versions/node/v8.0.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py", line 152, in <module>
    _new_sha1 = hashlib.sha1
AttributeError: 'module' object has no attribute 'sha1'
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/darin/.nvm/versions/node/v8.0.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/Users/darin/.nvm/versions/node/v8.0.0/bin/node" "/Users/darin/.nvm/versions/node/v8.0.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/darin/Documents/auto-test/atxserver2-ios-provider/node_modules/buffertools
gyp ERR! node -v v8.0.0
gyp ERR! node-gyp -v v3.6.1
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/darin/.npm/_logs/2019-12-27T05_49_49_116Z-debug.log

Wda的稳定性问题

我接了ios provider后,拿一个设备不管是ios10 11 12,跑个5分钟的monkey,wda就掉线了。monkey只是基本的坐标点击,感觉不够稳定,我试图延长heart beat或者wda/status的周期,减少wda的符合,但还是不行。而我用facebook的wda就稳定得多,求助

简单说几个问题

1.说明中提到的启动方式 :python3 main.py -s $SERVER_URL,不支持。需要python3 main.py --server ip:4000这种方式启动
2.原始的wda中支持Packages的uninstall 功能 能否支持?
3.原始的wda中支持send text功能 能否支持?
4.ios支持,需要预装 npm install -g express

长时间不操作手机,点击使用提示设备屏幕同步中断

白天正常使用的时候没有任何问题,但是每次第二天早上过来发现点击使用提示长设备屏幕同步中断,刷新页面,点击修复旋转都没用,只能重启provider,请问有没有遇到过类似的问题,如果长时间不操作导致服务跪了有没有监控自动重启服务的机制?

iOS的屏幕同步失败,总是为灰色,FPS/Frames显示为0/0

环境信息:

  • atxserver2-ios-provider部署在MAC OS 10.15.4

  • appium/WebDriverAgent的版本为2.9.0 (使用新版本,无法获取sessionID,参考下面背景信息)

  • node: v8.0.0

问题描述:

  • iOS的屏幕同步失败,总是为灰色,FPS/Frames显示为0/0详情如下图 ,但是/20001/status可以同步页面(参考下面日志信息)。

企业微信截图_de6a4577-56ae-47c0-81c9-364c68897e9b

atx-ios-prover日志信息:
企业微信截图_3ca25132-a01d-4b24-b69b-f0e2aba1496f

背景信息:

  • 使用新版本的appium/WebDriverAgent v2.18.1,无法获取sessionID ,如下图

85276645-c0cd1480-b4b4-11ea-8c25-783d90fc6ca4

Help - Request wda/status error: Stream closed

Help, i faced this problem on ios provider.. how to fixed it? @mingyuan-xia @codeskyblue
[D 210611 21:39:15 idb:414] [9df18..28:iPhone 6 Plus-iPhone 6 Plus] waiting for wda [D 210611 21:39:16 idb:411] [9df18..28:iPhone 6 Plus-iPhone 6 Plus] request wda/status error: Stream closed [D 210611 21:39:17 idb:411] [9df18..28:iPhone 6 Plus-iPhone 6 Plus] request wda/status error: Stream closed [D 210611 21:39:18 idb:411] [9df18..28:iPhone 6 Plus-iPhone 6 Plus] request wda/status error: Stream closed [D 210611 21:39:19 idb:411] [9df18..28:iPhone 6 Plus-iPhone 6 Plus] request wda/status error: Stream closed [D 210611 21:39:20 idb:411] [9df18..28:iPhone 6 Plus-iPhone 6 Plus] request wda/status error: Stream closed [D 210611 21:39:21 idb:411] [9df18..28:iPhone 6 Plus-iPhone 6 Plus] request wda/status error: Stream closed [W 210611 21:39:22 idb:380] [9df18..28:iPhone 6 Plus-iPhone 6 Plus] process quit [(67662, 65), (67663, None), (67664, None)] [D 210611 21:39:22 idb:243] terminate wda processes [W 210611 21:39:22 idb:226] [9df18..28:iPhone 6 Plus-iPhone 6 Plus] wda started failed, retry after 10s [D 210611 21:39:22 idb:355] exec: xcodebuild -project ./WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=fa14de501436b04b115a68eb9cb9f2574f9f7944 test

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.