## Android 并发测试
Appium 给用户提供了在单机上启动多个 Android sessions 的方案。可以使用任意可用端口启动 Appium 服务。
注意,在*同一设备上*不能运行多个 session
以下是启动多个 Android sessions 的一些重要参数:
- `udid` 设备id
- `chromedriverPort` chromedriver 端口(如果使用 webviews or chrome)
- `mjpegServerPort` 如果使用 [appium-uiautomator2-driver](https://github.com/appium/appium-uiautomator2-driver),需要为每个并发 session 设置一个唯一的 MJPEG 服务端口,否则可能会有端口冲突问题,如[这个问题](https://github.com/appium/appium/issues/7745)。
- `systemPort` 如果使用 [appium-uiautomator2-driver](https://github.com/appium/appium-uiautomator2-driver),需要为每个并发 session 设置一个唯一的系统端口,否则可能会有端口冲突问题,如[这个问题](https://github.com/appium/appium/issues/7745)。
### iOS 并发测试
Xcode9 以来,Appium 支持在真机和模拟器上进行并发测试。可以使用任意可用端口启动 Appium 服务。
以下是在 iOS 上启动多个 session 的重要参数:
#### 真机
- `udid` 每个并发 session 必须设置唯一的设备UDID。
- `wdaLocalPort` 每个并发 session 必须设置唯一的端口号,默认的端口号是8100。
- `derivedDataPath` 需要为每个 driver 实例设置唯一的导出数据根路径,这样有助于避免冲突,以及加快并发执行速度。
#### 模拟器
- 为每个并发 session 设置唯一的模拟器 UDID 或者一组唯一的 `deviceName` 和 `platformVersion`。`udid`,模拟器 UDID(可以从 xcrun simctl list 中获取),`deviceName` 和 `platformVersion`,可以定位到对应设备名和平台版本号的模拟器。
- `wdaLocalPort` 每个并发 session 必须设置唯一的端口号,默认的端口号是8100。
- `derivedDataPath` 需要为每个 driver 实例设置唯一的导出数据根路径,这样有助于避免冲突,以及加快并发执行速度。
### 故障排查
在 Jenkins 上运行时,当在相同机器上运行多个并发测试 jobs 时, 需要注意[ProcessTreeKiller](https://wiki.jenkins.io/display/JENKINS/ProcessTreeKiller)。
如果在一个测试 job 里使用大量模拟器,当第一个测试结束,Jenkins 可能会 kill 掉所有模拟器,这会导致剩下的测试 jobs 报错!
使用 `BUILD_ID=dontKillMe` 来防止这个问题发生。
本文由 [nicole1010](https://github.com/nicole1010) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
- 关于TesterHome和MTSC
- 关于Appium
- 简介
- Appium 客户端
- 入门指南
- 已支持的平台
- API 文档
- Appium驱动
- XCUITest (iOS)
- XCUITest Real Devices (iOS)
- UIAutomation (iOS)
- UIAutomation Safari Launcher (iOS)
- UIAutomator (Android)
- UIAutomator2 (Android)
- Espresso (Android)
- Windows
- Mac
- Appium命令
- Status
- Execute Mobile Command
- Session
- Create
- End
- Get Session Capabilities
- Go Back
- Screenshot
- Source
- Timeouts
- Timeouts
- Implicit Wait
- Async Script
- Orientation
- Get Orientation
- Set Orientation
- Geolocation
- Get Geolocation
- Set Geolocation
- Logs
- Get Log Types
- Get Logs
- Events
- Log event
- Get events
- Settings
- Update Settings
- Get Device Settings
- Settings
- Update Settings
- Get Device Settings
- Execute Driver Script
- Device
- Activity
- Start Activity
- Current Activity
- Current Package
- App
- Install App
- Is App Installed
- Launch App
- Background App
- Close App
- Reset App
- Remove App
- Activate App
- Terminate App
- Get App State
- Get App Strings
- End Test Coverage
- Clipboard
- Get Clipboard
- Set Clipboard
- Emulator
- Power AC
- Power Capacity
- Files
- Push File
- Pull File
- Pull Folder
- Interactions
- Shake
- Lock
- Unlock
- Is Locked
- Rotate
- Keys
- Press keycode
- Long press keycode
- Hide Keyboard
- Is Keyboard Shown
- Network
- Toggle Airplane Mode
- Toggle Data
- Toggle WiFi
- Toggle Location Services
- Send SMS
- GSM Call
- GSM Signal
- GSM Voice
- Network Speed
- Performance Data
- Get Performance Data
- Performance Data Types
- Screen Recording
- Start Screen Recording
- Stop Screen Recording
- Simulator
- Perform Touch ID
- Toggle Touch ID Enrollment
- System
- Open Notifications
- System Bars
- System Time
- Display density
- Authentication
- Finger Print
- Element
- Find Element
- Find Elements
- Actions
- Click
- Send Keys
- Clear
- Attributes
- Text
- Name
- Attribute
- Selected
- Enabled
- Displayed
- Location
- Size
- Rect
- CSS Property
- Location in View
- Other
- Submit
- Active Element
- Equals Element
- Context
- Get Context
- Get All Contexts
- Set Context
- Interactions
- Mouse
- Move To
- Click
- Double Click
- Button Down
- Button Up
- Touch
- Single Tap
- Double Tap
- Move
- Touch Down
- Touch Up
- Long Press
- Scroll
- Flick
- Multi Touch Perform
- Touch Perform
- W3C Actions
- Web
- Window
- Set Window
- Close Window
- Get Handle
- Get Handles
- Get Title
- Get Window Size
- Set Window Size
- Get Window Position
- Set Window Position
- Maximize Window
- Navigation
- Go to URL
- Get URL
- Back
- Forward
- Refresh
- Storage
- Get All Cookies
- Set Cookie
- Delete Cookie
- Delete All Cookies
- Frame
- Switch to Frame
- Switch to Parent Frame
- Execute Async
- Execute
- 编写 & 运行Appium脚本
- Running Tests
- Desired Capabilities
- The --default-capabilities flag
- Finding Elements
- Touch Actions
- CLI Arguments
- Server Security
- Web/Web Views
- Mobile Web Testing
- Automating Hybrid Apps
- Using ios-webkit-debug-proxy
- Using Chromedriver
- Image Comparison
- iOS
- Low-Level Insights on iOS Input Events
- XCUITest Mobile Gestures
- XCUITest Mobile App Management
- iOS Pasteboard Guide
- iOS Predicate Guide
- iOS Touch ID Guide
- iOS Install Certificate
- tvOS support
- Pushing/Pulling files
- Audio Capture
- Android
- Low-Level Insights on Android Input Events
- UiSelector Guide
- Espresso Datamatcher Guide
- Android Code Coverage Guide
- Activities Startup Troubleshooting Guide
- How To Execute Shell Commands On The Remote Device
- Android Device Screen Streaming
- How To Emulate IME Actions Generation
- How To Test Android App Bundle
- Other
- Reset Strategies
- Network Connection Guide
- Using Unicode with Appium
- Troubleshooting
- Tutorial
- Swipe Tutorial
- Screen
- Element
- Partial screen
- Simple
- Multiple scroll views
- Add scroll layout
- Tricks and Tips
- Screen
- Element
- Element search
- Fast
- Slow
- Guide
- 进阶概念
- 定位图像中的元素
- 使用定位元素的插件
- 迁移到 XCUITest
- 在 Appium 中使用 Selenium Grid
- Appium Logs Filtering
- 跨域 iframes
- 使用自定义 WDA 服务器
- 使用不同版本的 Xcode 运行
- The Event Timings API
- 并行测试的设置
- The Settings API
- Memory Collection
- 向Appium项目做贡献
- 从源代码运行 Appium
- 开发者概述
- 标准开发命令
- Appium 风格指南
- 如何编写文档
- Appium 包结构
- 鸣谢