Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e06729c114 | ||
|
|
9fc35d3ba7 | ||
|
|
7ca35a3373 | ||
|
|
704fec138d |
@@ -1,7 +1,2 @@
|
||||
coverage
|
||||
node_modules
|
||||
examples/javascript-wd
|
||||
packages/*/build/**/*
|
||||
**/*.min.js
|
||||
sample-code
|
||||
**/*.d.ts
|
||||
coverage
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
{
|
||||
"extends": "@appium/eslint-config-appium",
|
||||
"overrides": [
|
||||
{
|
||||
"files": "packages/fake-driver/**/*",
|
||||
"rules": { "require-await": "off" }
|
||||
},
|
||||
{ "files": "packages/support/**/*", "globals": { "BigInt": "readonly" } },
|
||||
{
|
||||
"files": "packages/*/test/**/*",
|
||||
"rules": { "func-names": "off" }
|
||||
}
|
||||
]
|
||||
"extends": "appium"
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# Generated by FOSSA CLI (https://github.com/fossas/fossa-cli)
|
||||
# Visit https://fossa.com to learn more
|
||||
|
||||
version: 3
|
||||
|
||||
project:
|
||||
id: github.com/appium/appium
|
||||
name: appium
|
||||
|
||||
paths:
|
||||
exclude:
|
||||
- ./sample-code
|
||||
- '**/fixtures/**'
|
||||
- '**/demo/**'
|
||||
- '**/example/**'
|
||||
- '**/examples/**'
|
||||
|
||||
targets:
|
||||
only:
|
||||
- type: npm
|
||||
path: .
|
||||
- type: npm
|
||||
path: ./packages/appium
|
||||
- type: npm
|
||||
path: ./packages/base-driver
|
||||
- type: npm
|
||||
path: ./packages/doctor
|
||||
- type: npm
|
||||
path: ./packages/eslint-config-appium
|
||||
- type: npm
|
||||
path: ./packages/fake-driver
|
||||
- type: npm
|
||||
path: ./packages/gulp-plugins
|
||||
- type: npm
|
||||
path: ./packages/support
|
||||
- type: npm
|
||||
path: ./packages/test-support
|
||||
|
||||
revision:
|
||||
branch: 2.0
|
||||
@@ -8,7 +8,6 @@ Briefly describe the issue you are experiencing (or the feature you want to see
|
||||
* Last Appium version that did not exhibit the issue (if applicable):
|
||||
* Desktop OS/version used to run Appium:
|
||||
* Node.js version (unless using Appium.app|exe):
|
||||
* Npm or Yarn package manager:
|
||||
* Mobile platform/version under test:
|
||||
* Real device or emulator/simulator:
|
||||
* Appium CLI or Appium.app|exe:
|
||||
@@ -19,8 +18,8 @@ If necessary, describe the problem you have been experiencing in more detail.
|
||||
|
||||
## Link to Appium logs
|
||||
|
||||
Create a [GIST](https://gist.github.com) which is a paste of your _full_ Appium logs, and link them here.
|
||||
Do _NOT_ paste your full Appium logs here, as it will make this issue very long and hard to read!
|
||||
Create a [GIST](https://gist.github.com) which is a paste of your _full_ Appium logs, and link them here.
|
||||
Do _NOT_ paste your full Appium logs here, as it will make this issue very long and hard to read!
|
||||
If you are reporting a bug, _always_ include Appium logs!
|
||||
|
||||
|
||||
@@ -28,6 +27,6 @@ If you are reporting a bug, _always_ include Appium logs!
|
||||
|
||||
Please remember that with sample code it's easier to reproduce the bug and it's much faster to fix it.
|
||||
|
||||
Please git clone https://github.com/appium/appium and from the `examples` directory, use one of your favourite languages and sample apps to reproduce the issue.
|
||||
Please git clone https://github.com/appium/sample-code and use one of your favourite languages and sample apps to reproduce the issue.
|
||||
|
||||
In case a similar scenario is missing in examples, please submit a PR with one of the sample apps provided.
|
||||
In case a similar scenario is missing in sample-code, please submit a PR with one of the sample apps provided.
|
||||
|
||||
@@ -10,13 +10,12 @@ _Put an `x` in the boxes that apply_
|
||||
- [ ] Bugfix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||
- [ ] Documentation Update (if none of the other choices apply)
|
||||
|
||||
## Checklist
|
||||
|
||||
_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
|
||||
|
||||
- [ ] I have read the [CONTRIBUTING](https://github.com/appium/appium/blob/master/CONTRIBUTING.md) doc
|
||||
- [ ] I have read the [CONTRIBUTING](/CONTRIBUTING.md) doc
|
||||
- [ ] I have signed the [CLA](https://cla.js.foundation/appium/appium)
|
||||
- [ ] Lint and unit tests pass locally with my changes
|
||||
- [ ] I have added tests that prove my fix is effective or that my feature works
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/sample-code/javascript-webdriverio"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "11:00"
|
||||
open-pull-requests-limit: 10
|
||||
- package-ecosystem: npm
|
||||
directory: "/sample-code/javascript-wd"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "11:00"
|
||||
open-pull-requests-limit: 10
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "11:00"
|
||||
open-pull-requests-limit: 10
|
||||
@@ -1,26 +0,0 @@
|
||||
# Configuration for Lock Threads - https://github.com/dessant/lock-threads
|
||||
|
||||
# Number of days of inactivity before a closed issue or pull request is locked
|
||||
daysUntilLock: 365
|
||||
|
||||
# Skip issues and pull requests created before a given timestamp. Timestamp must
|
||||
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable
|
||||
skipCreatedBefore: false
|
||||
|
||||
# Issues and pull requests with these labels will be ignored. Set to `[]` to disable
|
||||
exemptLabels: []
|
||||
|
||||
# Label to add before locking, such as `outdated`. Set to `false` to disable
|
||||
lockLabel: false
|
||||
|
||||
# Comment to post before locking. Set to `false` to disable
|
||||
lockComment: >
|
||||
This thread has been automatically locked since there has not been
|
||||
any recent activity after it was closed. Please open a new issue for
|
||||
related bugs.
|
||||
|
||||
# Assign `resolved` as the reason for locking. Set to `false` to disable
|
||||
setLockReason: false
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
only: issues
|
||||
@@ -1,21 +0,0 @@
|
||||
name: License Checks
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
jobs:
|
||||
fossa-check:
|
||||
name: Run FOSSA Analysis
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: '2.0'
|
||||
- name: fossa analyze
|
||||
run: |
|
||||
npm install
|
||||
curl -sS -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash
|
||||
fossa analyze
|
||||
fossa test
|
||||
env:
|
||||
FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}}
|
||||
@@ -1,40 +0,0 @@
|
||||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
||||
|
||||
name: Node.js CI
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x, 14.x, 16.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Install latest npm
|
||||
run: npm install -g npm
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- name: Run unit tests
|
||||
run: npm test
|
||||
- name: Run E2E tests
|
||||
run: |
|
||||
npm run install-fake-driver
|
||||
npm run e2e-test
|
||||
|
||||
generate_docs:
|
||||
needs: [build]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: |
|
||||
npm install
|
||||
npm run generate-docs
|
||||
@@ -2,16 +2,14 @@
|
||||
*.swp
|
||||
.DS_Store
|
||||
node_modules
|
||||
package-lock.json
|
||||
sample-code
|
||||
*.trace
|
||||
xcuserdata
|
||||
*.sublime-*
|
||||
test/functional/_joined
|
||||
*.iml
|
||||
!examples/java/*.iml
|
||||
*.autosave
|
||||
.idea/
|
||||
!examples/java/.idea/
|
||||
*.log
|
||||
*.t
|
||||
artifacts
|
||||
@@ -25,34 +23,12 @@ lib/devices/android/bootstrap/target/
|
||||
.*~
|
||||
*~
|
||||
org.eclipse.ltk.core.refactoring.prefs
|
||||
/selendroid
|
||||
.appiumconfig*
|
||||
build/
|
||||
.idea
|
||||
*DerivedData
|
||||
__pycache__
|
||||
|
||||
# csharp
|
||||
*.pyc
|
||||
*.pdb
|
||||
.vs
|
||||
|
||||
old
|
||||
.tern-project
|
||||
coverage
|
||||
docs/mkdocs.yml
|
||||
examples/javascript-wd/node_modules
|
||||
examples/php/vendor
|
||||
examples/php/composer.lock
|
||||
examples/java/out/
|
||||
examples/ruby/Gemfile.lock
|
||||
examples/python/test/results/
|
||||
examples/python/test/input
|
||||
examples/python/.pytest_cache/
|
||||
examples/csharp/test/bin
|
||||
examples/csharp/test/obj
|
||||
examples/csharp/test/bin
|
||||
examples/csharp/packages
|
||||
appium.zip
|
||||
.vscode/settings.json
|
||||
.nyc_output
|
||||
*.lerna_backup
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
require: require.resolve('./test/setup.js')
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
assets/
|
||||
submodules/
|
||||
test/
|
||||
_vimrc_local.vim
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
.*~
|
||||
.DS_Store
|
||||
.travis.yml
|
||||
*.log
|
||||
*.trace
|
||||
*.sublime-
|
||||
*.prefs
|
||||
./.npmignore
|
||||
coverage
|
||||
@@ -1,4 +0,0 @@
|
||||
# Do not disable package-lock. Disabling package-lock also disables npm-shrinkwrap
|
||||
package-lock=true
|
||||
save-exact=true
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "7"
|
||||
- "6"
|
||||
env:
|
||||
- CXX=g++-4.8
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.8
|
||||
script:
|
||||
- npm run test
|
||||
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"args": ["--colors", "--timeout", "0", "${file}"],
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"name": "Test - Current File",
|
||||
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
|
||||
"runtimeArgs": ["-r", "@babel/register"],
|
||||
"request": "launch",
|
||||
"skipFiles": ["<node_internals>/**"],
|
||||
"type": "pwa-node",
|
||||
"sourceMaps": true,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"outfiles": [],
|
||||
"env": {
|
||||
"NODE_ENV": "test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Debug",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"console": "integratedTerminal",
|
||||
"args": ["."]
|
||||
},
|
||||
{
|
||||
"name": "Attach Debug",
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"port": 9229
|
||||
},
|
||||
{
|
||||
"name": "Test All",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/_mocha",
|
||||
"args": [
|
||||
"--require",
|
||||
"@babel/register",
|
||||
"--timeout",
|
||||
"999999",
|
||||
"--colors",
|
||||
"${workspaceFolder}/packages/appium/test"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "build",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"label": "npm: build",
|
||||
"detail": "lerna exec gulp transpile"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "npm",
|
||||
"args": [
|
||||
"exec",
|
||||
"--",
|
||||
"lerna",
|
||||
"exec",
|
||||
"--scope=@appium/fake-driver",
|
||||
"--",
|
||||
"gulp",
|
||||
"transpile"
|
||||
],
|
||||
"label": "transpile: @appium/fake-driver",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "npm",
|
||||
"args": [
|
||||
"exec",
|
||||
"--",
|
||||
"lerna",
|
||||
"exec",
|
||||
"--scope=appium",
|
||||
"--",
|
||||
"gulp",
|
||||
"transpile"
|
||||
],
|
||||
"label": "transpile: appium",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "npm",
|
||||
"args": [
|
||||
"exec",
|
||||
"--",
|
||||
"lerna",
|
||||
"exec",
|
||||
"--scope=@appium/support",
|
||||
"--",
|
||||
"gulp",
|
||||
"transpile"
|
||||
],
|
||||
"label": "transpile: @appium/support",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "npm",
|
||||
"args": [
|
||||
"exec",
|
||||
"--",
|
||||
"lerna",
|
||||
"exec",
|
||||
"--scope=@appium/test-support",
|
||||
"--",
|
||||
"gulp",
|
||||
"transpile"
|
||||
],
|
||||
"label": "transpile: @appium/test-support",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "npm",
|
||||
"args": [
|
||||
"exec",
|
||||
"--",
|
||||
"lerna",
|
||||
"exec",
|
||||
"--scope=@appium/gulp-plugins",
|
||||
"--",
|
||||
"gulp",
|
||||
"transpile"
|
||||
],
|
||||
"label": "transpile: @appium/gulp-plugins",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "npm",
|
||||
"args": [
|
||||
"exec",
|
||||
"--",
|
||||
"lerna",
|
||||
"exec",
|
||||
"--scope=@appium/doctor",
|
||||
"--",
|
||||
"gulp",
|
||||
"transpile"
|
||||
],
|
||||
"label": "transpile: @appium/doctor",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "npm",
|
||||
"args": [
|
||||
"exec",
|
||||
"--",
|
||||
"lerna",
|
||||
"exec",
|
||||
"--scope=@appium/base-driver",
|
||||
"--",
|
||||
"gulp",
|
||||
"transpile"
|
||||
],
|
||||
"label": "transpile: @appium/base-driver",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "node_modules/.bin/mocha",
|
||||
"args": [
|
||||
"--bail",
|
||||
"-r",
|
||||
"@babel/register",
|
||||
"-t",
|
||||
"20s",
|
||||
"packages/appium/test/*e2e-specs.js"
|
||||
],
|
||||
"label": "appium: E2E",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "dev",
|
||||
"problemMatcher": [],
|
||||
"isBackground": true,
|
||||
"label": "npm: dev",
|
||||
"detail": "lerna exec --parallel gulp dev"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = (wallaby) => {
|
||||
return {
|
||||
compilers: {
|
||||
'**/*.js': wallaby.compilers.babel(),
|
||||
},
|
||||
debug: true,
|
||||
env: {
|
||||
type: 'node',
|
||||
},
|
||||
files: [
|
||||
'./packages/**/*.js',
|
||||
'./packages/**/*.json',
|
||||
'!./packages/**/build/**',
|
||||
'!./packages/**/test/**/*-specs.js',
|
||||
'!./packages/*/node_modules/**',
|
||||
'!./packages/*/gulpfile.js',
|
||||
'./packages/*/test/**/fixtures/**/*',
|
||||
// below this are fixtures
|
||||
{
|
||||
binary: true,
|
||||
pattern: './packages/support/test/assets/sample_binary.plist',
|
||||
},
|
||||
{
|
||||
instrument: false,
|
||||
pattern: './packages/support/test/assets/sample_text.plist',
|
||||
},
|
||||
{
|
||||
instrument: false,
|
||||
pattern: './packages/base-driver/static/**/*',
|
||||
},
|
||||
{
|
||||
instrument: false,
|
||||
pattern: './packages/gulp-plugins/build/**/*',
|
||||
},
|
||||
{
|
||||
instrument: false,
|
||||
pattern: './test/setup.js'
|
||||
}
|
||||
],
|
||||
testFramework: 'mocha',
|
||||
tests: [
|
||||
'./packages/*/test/**/*-specs.js',
|
||||
'!./packages/*/test/**/*-e2e-specs.js',
|
||||
'!./packages/*/node_modules/**',
|
||||
// this is more of an E2E test and it's tedious to run
|
||||
'!./packages/gulp-plugins/test/transpile-specs.js',
|
||||
],
|
||||
workers: {
|
||||
restart: true,
|
||||
},
|
||||
setup() {
|
||||
require('./test/setup');
|
||||
},
|
||||
runMode: 'onsave'
|
||||
};
|
||||
};
|
||||
@@ -8,7 +8,7 @@ Note that no matter how you contribute, your participation is governed by our
|
||||
### Make changes to the Appium code or docs
|
||||
|
||||
Fork the project, make a change, and send a pull request! Please have a look at
|
||||
our [Style Guide](/docs/en/contributing-to-appium/style-guide.md) before
|
||||
our [Style Guide](/docs/en/contributing-to-appium/style-guide-2.0.md) before
|
||||
getting to work. Please make sure the unit and functional tests pass before
|
||||
sending a pull request; for more information on how to run tests, keep reading!
|
||||
|
||||
|
||||
@@ -52,32 +52,15 @@ and so on.
|
||||
|
||||
The current committers are (in addition to the TC members above):
|
||||
|
||||
* [@hugs](https://github.com/hugs)
|
||||
* [@filmaj](https://github.com/filmaj)
|
||||
* [@aluedeke](https://github.com/aluedeke)
|
||||
* [@sebv](https://github.com/sebv)
|
||||
* [@vgrigoruk](https://github.com/vgrigoruk)
|
||||
* [@DylanLacey](https://github.com/DylanLacey)
|
||||
* [@maudineormsby](https://github.com/maudineormsby)
|
||||
* [@titusfortner](https://github.com/titusfortner)
|
||||
* [@bayandin](https://github.com/bayandin)
|
||||
* [@jdeff](https://github.com/jdeff)
|
||||
* [@moizjv](https://github.com/moizjv)
|
||||
* [@gempesaw](https://github.com/gempesaw)
|
||||
* [@Jonahss](https://github.com/Jonahss)
|
||||
* [@JamieEdge](https://github.com/JamieEdge)
|
||||
* [@saikrishna321](https://github.com/saikrishna321)
|
||||
* [@dpgraham](https://github.com/dpgraham)
|
||||
* [@sravanmedarapu](https://github.com/sravanmedarapu)
|
||||
* [@peepa](https://github.com/peepa)
|
||||
* [@scottdixon](https://github.com/scottdixon)
|
||||
* [@drpy](https://github.com/drpy)
|
||||
* [@Astro03](https://github.com/Astro03)
|
||||
* [@sbonebrake](https://github.com/sbonebrake)
|
||||
* [@moizjv](https://github.com/moizjv)
|
||||
* [@SrinivasanTarget](https://github.com/SrinivasanTarget)
|
||||
* [@triager](https://github.com/triager)
|
||||
* [@ddkjin](https://github.com/ddkjin)
|
||||
* [@stuartbrussell-intuit](https://github.com/stuartbrussell-intuit)
|
||||
* [@vmaxim](https://github.com/vmaxim)
|
||||
* [@christian-bromann](https://github.com/christian-bromann)
|
||||
* [@vrunoa](https://github.com/vrunoa)
|
||||
* [@saikrishna321](https://github.com/saikrishna321)
|
||||
* [@butomo1989](https://github.com/butomo1989)
|
||||
* [@vikramvi](https://github.com/vikramvi)
|
||||
|
||||
### Contributors
|
||||
|
||||
|
||||
@@ -1,97 +1,153 @@
|
||||
## Appium
|
||||
|
||||
[](https://npmjs.org/package/appium)
|
||||
[](https://github.com/appium/appium/actions/workflows/node.js.yml)
|
||||
[](https://david-dm.org/appium/appium)
|
||||
[](https://david-dm.org/appium/appium#info=devDependencies)
|
||||
|
||||
[](https://npmjs.org/package/appium)
|
||||
[](http://issuestats.com/github/appium/appium)
|
||||
[](http://issuestats.com/github/appium/appium)
|
||||
|
||||
[](https://team-appium.ci.cloudbees.com/job/Appium/)
|
||||
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fappium%2Fappium?ref=badge_shield)
|
||||
|
||||
Appium is an open-source, cross-platform test automation tool for native,
|
||||
hybrid, and mobile web and desktop apps. We support simulators (iOS), emulators
|
||||
(Android), and real devices (iOS, Android, Windows, Mac).
|
||||
Appium is an open source, cross-platform test automation tool for native, hybrid and mobile web and desktop apps, tested on simulators (iOS), emulators (Android), and real devices (iOS, Android, Windows, Mac).
|
||||
|
||||
Want to skip straight to the action? Check out our [getting
|
||||
started](/docs/en/about-appium/getting-started.md) doc.
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
Appium supports app automation across a variety of platforms, like iOS,
|
||||
Android, and Windows. Each platform is supported by one or more "drivers",
|
||||
which know how to automate that particular platform. Choose a driver below for
|
||||
specific information about how that driver works and how to set it up:
|
||||
|
||||
* iOS
|
||||
* The [XCUITest Driver](/docs/en/drivers/ios-xcuitest.md)
|
||||
* (DEPRECATED) The [UIAutomation Driver](/docs/en/drivers/ios-uiautomation.md)
|
||||
* Android
|
||||
* The [Espresso Driver](/docs/en/drivers/android-espresso.md)
|
||||
* The [UiAutomator2 Driver](/docs/en/drivers/android-uiautomator2.md)
|
||||
* (DEPRECATED) The [UiAutomator Driver](/docs/en/drivers/android-uiautomator.md)
|
||||
* The [Windows Driver](/docs/en/drivers/windows.md) (for Windows Desktop apps)
|
||||
* The [Mac Driver](/docs/en/drivers/mac.md) (for Mac Desktop apps)
|
||||
* Windows
|
||||
* Mac
|
||||
|
||||
See the [platform support doc](/docs/en/appium-setup/platform-support.md) for more detailed information.
|
||||
|
||||
### Why Appium?
|
||||
|
||||
1. You don't have to recompile your app or modify it in any way, due
|
||||
to the use of standard automation APIs on all platforms.
|
||||
2. You can write tests with your favorite dev tools using any
|
||||
[WebDriver](https://w3c.github.io/webdriver/webdriver-spec.html)-compatible
|
||||
language such as Java, Objective-C, JavaScript (Node), PHP, Python, Ruby,
|
||||
C#, Clojure, or Perl with the Selenium WebDriver API and [language-specific
|
||||
client libraries](/docs/en/about-appium/appium-clients.md).
|
||||
to use of standard automation APIs on all platforms.
|
||||
2. You can write tests with your favorite dev tools using any [WebDriver](https://w3c.github.io/webdriver/webdriver-spec.html)-compatible
|
||||
language such as Java, [Objective-C](https://github.com/appium/selenium-objective-c),
|
||||
JavaScript with Node.js (in [promise, callback](https://github.com/admc/wd) or [generator](https://github.com/jlipps/yiewd) flavors),
|
||||
PHP, Python, [Ruby](https://github.com/appium/ruby_lib), C#, Clojure, or Perl
|
||||
with the Selenium WebDriver API and language-specific client libraries.
|
||||
3. You can use any testing framework.
|
||||
4. Appium has built-in mobile web and hybrid app support. Within the same
|
||||
script, you can switch seamlessly between native app automation and webview
|
||||
automation, all using the WebDriver model that's already the standard for
|
||||
web automation.
|
||||
|
||||
Investing in the
|
||||
[WebDriver](https://w3c.github.io/webdriver/webdriver-spec.html) protocol means
|
||||
you are betting on a single, free, and open protocol for testing that has become
|
||||
a web standard. Don't lock yourself into a proprietary stack.
|
||||
Investing in the [WebDriver](https://w3c.github.io/webdriver/webdriver-spec.html) protocol means you are betting on a single, free and open protocol for testing that has become a defacto standard. Don't lock yourself into a proprietary stack.
|
||||
|
||||
For example, if you use Apple's XCUITest library without Appium you can only
|
||||
write tests using Obj-C/Swift, and you can only run tests through Xcode.
|
||||
Similarly, with Google's UiAutomator or Espresso, you can only write tests in
|
||||
Java/Kotlin. Appium opens up the possibility of true cross-platform native app
|
||||
automation, for mobile and beyond. Finally!
|
||||
If you use Apple's UIAutomation library without Appium you can only write tests
|
||||
using JavaScript and you can only run tests through the Instruments application.
|
||||
Similarly, with Google's UiAutomator you can only write tests in Java. Appium
|
||||
opens up the possibility of true cross-platform native mobile automation. Finally!
|
||||
|
||||
If you're new to Appium or want a more comprehensive description of what this is all
|
||||
about, please read our [Introduction to Appium
|
||||
Concepts](/docs/en/about-appium/intro.md).
|
||||
### I don't get it yet...
|
||||
|
||||
If you're new to Appium, or want a fuller description of what this is all about, please read our [Introduction to Appium Concepts](/docs/en/about-appium/intro.md).
|
||||
|
||||
### Requirements
|
||||
|
||||
Your environment needs to be set up for the particular platforms that you want
|
||||
to run tests on. Each of the drivers above documents the requirements for their
|
||||
particular brand of automation. At a minimum, you will need to be able to run
|
||||
Node.js 10+.
|
||||
Your environment needs to be setup for the particular mobile platforms that you
|
||||
want to run tests on. See below for particular platform requirements.
|
||||
|
||||
### Get Started
|
||||
If you want to run Appium via an `npm install`, hack with or contribute to Appium, you will need
|
||||
[node.js and npm](http://nodejs.org) 4 or greater (use [n](https://github.com/visionmedia/n) or
|
||||
`brew install node` to install Node.js. Make sure you have not installed Node or Appium with `sudo`,
|
||||
otherwise you'll run into problems). We recommend the latest stable version.
|
||||
|
||||
Check out our [Getting Started](/docs/en/about-appium/getting-started.md) guide
|
||||
to get going with Appium.
|
||||
To verify that all of Appium's dependencies are met you can use
|
||||
`appium-doctor`. Install it with `npm install -g appium-doctor` (or run it
|
||||
from [source](https://github.com/appium/appium-doctor)), then run
|
||||
`appium-doctor` and supply the `--ios` or `--android` flags to verify that all
|
||||
of the dependencies are set up correctly.
|
||||
|
||||
There is also a sample code that contains [many examples of tests in a variety
|
||||
of different languages](https://github.com/appium/appium/tree/master/sample-code)!
|
||||
You also need to download the Appium client for your language so you can write tests. The Appium clients are simple extensions to the WebDriver clients. You can see the list of clients and links to download instructions at the [Appium clients list](/docs/en/about-appium/appium-clients.md).
|
||||
|
||||
### Documentation
|
||||
#### iOS Requirements
|
||||
|
||||
For prettily-rendered docs, please visit [appium.io](http://appium.io). You can
|
||||
always find the full list of Appium doc pages at [Appium's GitHub
|
||||
Repo](https://github.com/appium/appium/tree/master/docs/en/) as well.
|
||||
* Mac OS X 10.10 or higher, 10.11.1 recommended
|
||||
* XCode >= 6.0, 7.1.1 recommended
|
||||
* Apple Developer Tools (iPhone simulator SDK, command line tools)
|
||||
* [Ensure you read our documentation on setting yourself up for iOS testing!](/docs/en/appium-setup/running-on-osx.md)
|
||||
|
||||
[update-appium-io.yml](https://github.com/appium/appium/blob/master/ci-jobs/update-appium-io.yml) creates a PR
|
||||
by [CI job](https://dev.azure.com/AppiumCI/Appium%20CI/_build?definitionId=37).
|
||||
in the appium.io repository with the documentation update.
|
||||
#### Android Requirements
|
||||
|
||||
Once the PR has been merged, the latest documentation will be in [appium.io](http://appium.io)
|
||||
* [Android SDK](http://developer.android.com) API >= 17 (Additional features require 18/19)
|
||||
* Appium supports Android on OS X, Linux and Windows. Make sure you follow the
|
||||
directions for setting up your environment properly for testing on different OSes:
|
||||
* [linux](/docs/en/appium-setup/running-on-linux.md)
|
||||
* [osx](/docs/en/appium-setup/running-on-osx.md)
|
||||
* [windows](/docs/en/appium-setup/running-on-windows.md)
|
||||
|
||||
#### Windows Requirements
|
||||
|
||||
* Windows 10
|
||||
* [Documentation](/docs/en/appium-setup/running-on-windows.md)
|
||||
|
||||
#### Mac Requirements
|
||||
|
||||
* Mac OS X 10.7 +
|
||||
* [Documentation](https://github.com/penguinho/appium/blob/mac-driver/docs/en/appium-setup/running-on-osx.md#testing-mac-apps)
|
||||
|
||||
### Quick Start
|
||||
|
||||
Kick up an Appium server, and then run a test written in your favorite [WebDriver](https://w3c.github.io/webdriver/webdriver-spec.html)-compatible language!
|
||||
You can run an Appium server using node.js or using the application, see below.
|
||||
|
||||
#### Using Node.js
|
||||
|
||||
```
|
||||
$ npm install -g appium
|
||||
$ appium
|
||||
```
|
||||
|
||||
As we said above, you may want to run `appium-doctor` to ensure your system is set up properly:
|
||||
|
||||
```
|
||||
$ npm install -g appium-doctor
|
||||
$ appium-doctor
|
||||
```
|
||||
|
||||
#### Using the Appium Desktop App
|
||||
|
||||
* [Download the Appium app](https://www.github.com/appium/appium-desktop/releases/latest/)
|
||||
* Run it!
|
||||
|
||||
### Writing Tests for Appium
|
||||
|
||||
The main guide for getting started writing and running tests is [the running tests](/docs/en/writing-running-appium/running-tests.md) doc, which includes explanations for iOS, Android, and Android older devices. If you're interested in testing on physical hardware, you might be interested in our [real devices guide](/docs/en/appium-setup/real-devices.md).
|
||||
|
||||
(*Note*: If you're automating iOS 10+, be sure to check out our [XCUITest Migration Guide](/docs/en/advanced-concepts/migrating-to-xcuitest.md) since Apple's automation support has changed significantly since iOS 10, with corresponding changes in Appium).
|
||||
|
||||
Essentially, we support a subset of the [Selenium WebDriver JSON Wire Protocol](https://w3c.github.io/webdriver/webdriver-spec.html), and extend it so that you can specify mobile-targeted [desired capabilities](/docs/en/writing-running-appium/caps.md) to run your test through Appium.
|
||||
|
||||
You find elements by using a subset of WebDriver's element-finding strategies.
|
||||
See [finding elements](/docs/en/writing-running-appium/finding-elements.md) for detailed information. We also have several extensions to the JSON Wire Protocol for [automating mobile gestures](/docs/en/writing-running-appium/touch-actions.md) like tap, flick, and swipe.
|
||||
|
||||
You can also automate web views in hybrid apps! See the [hybrid app guide](/docs/en/advanced-concepts/hybrid.md)
|
||||
|
||||
This repository contains [many examples of tests in a variety of different languages](https://github.com/appium/sample-code)!
|
||||
|
||||
For the full list of Appium doc pages, visit [this directory](/docs/en/).
|
||||
|
||||
### How It Works
|
||||
|
||||
Appium drives various native automation frameworks and provides an API based on
|
||||
Selenium's [WebDriver JSON wire protocol](https://w3c.github.io/webdriver/webdriver-spec.html).
|
||||
|
||||
For new iOS versions (9.3 and up), Appium drives Apple's XCUITest library. Our support for XCUITest utilizes Facebook's [WebDriverAgent](https://github.com/facebook/webdriveragent) project.
|
||||
|
||||
For older iOS versions (9.3 and below), Appium drives Apple's UIAutomation library, using a strategy which is based on [Dan Cuellar's](http://github.com/penguinho) work on iOS Auto.
|
||||
|
||||
Android support uses the UiAutomator framework for newer platforms and
|
||||
[Selendroid](http://github.com/DominikDary/selendroid) for older Android platforms.
|
||||
|
||||
Windows support uses Microsoft's [WinAppDriver](https://github.com/Microsoft/WinAppDriver)
|
||||
|
||||
### Contributing
|
||||
|
||||
Please take a look at our [contribution documentation](CONTRIBUTING.md)
|
||||
for instructions on how to build, test, and run Appium from the source.
|
||||
for instructions on how to build, test and run Appium from source.
|
||||
|
||||
### Roadmap
|
||||
|
||||
@@ -104,16 +160,18 @@ Interested in where Appium is heading in the future? Check out the [Roadmap](ROA
|
||||
|
||||
### User Forums
|
||||
|
||||
Announcements and debates often take place on the [Discussion
|
||||
Group](https://discuss.appium.io), be sure to sign up!
|
||||
Announcements and debates often take place on the [Discussion Group](https://discuss.appium.io), be sure to sign up!
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
We put together a [troubleshooting
|
||||
guide](/docs/en/writing-running-appium/other/troubleshooting.md). Please have a look
|
||||
here first if you run into any problems. It contains instructions for checking
|
||||
a lot of common errors and how to get in touch with the community if you're
|
||||
stumped.
|
||||
We put together a [troubleshooting guide](/docs/en/appium-setup/troubleshooting.md).
|
||||
Please have a look here first if you run into any problems. It contains instructions for checking a lot
|
||||
of common errors and how to get in touch with the community if you're stumped.
|
||||
|
||||
### Using Robots
|
||||
|
||||
Using Appium with [Tapster](https://github.com/hugs/tapsterbot) and other robots is possible,
|
||||
check out the [Appium Robots](https://github.com/appium/robots) project!
|
||||
|
||||
### License
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@ exists to outline large-scale future plans for Appium.
|
||||
|
||||
| Project | Description |
|
||||
|---------|-------------|
|
||||
|[Onboarding Overhaul](https://github.com/appium/appium/issues/7169)|The current Appium docs leave a lot to be desired. The format is confusing (it would be better for API docs), the content is outdated, and many things are still undocumented. This project would go back to the drawing board in all of these areas and put together something genuinely helpful for the community, which hopefully reduces the kind of support issues we're currently flooded by.|
|
||||
|[Appium Client Library Updates](https://github.com/appium/appium/issues/7170)|It's been too long since we ensured that Appium's client libraries were up to date with the server|
|
||||
|[Sample Code Overhaul](https://github.com/appium/appium/issues/7171)|Our sample code repo has grown tangled and broken. Let's make a new one with minimal examples which are the same across every language, and actually maintain the repo so as not to let it become overgrown.|
|
||||
|[Test App Overhaul](https://github.com/appium/appium/issues/7172)|Our current test applications (the ones used to test Appium's iOS and Android support) are not ideal. We use too many of them and the ones we use have a random hodgepodge of app SDK features, sometimes not enough to sufficiently test automation support. It'd be great to find a way to ensure our test app(s) have all the features we need to test, and keep in sync with our requirements.|
|
||||
|[iOS Test Startup Time Improvement](https://github.com/appium/appium/issues/7173)|iOS startup times have gotten progressively longer with each iOS release. In part this is Apple's fault and there's not anything we can do about it. But we should investigate and see if we can be more efficient in how we start, especially given that we can now focus on XCUITest and leave Instruments behind|
|
||||
|[Appium Dearchitecture](https://github.com/appium/appium/issues/7174)|OK, we went a bit overboard in Appium 1.5 by exploding Appium into 40+ repos and NPM packages. Let's think a little more critically about it and consolidate into the minimal number of repos/packages that make sense for our code and community patterns.|
|
||||
@@ -41,8 +43,6 @@ exists to outline large-scale future plans for Appium.
|
||||
|
||||
| Project | Description | Completed | Appium Release | Notes |
|
||||
|---------|-------------|-----------|----------------|-------|
|
||||
|[Sample Code Overhaul](https://github.com/appium/appium/issues/7171)|Our sample code repo has grown tangled and broken. Let's make a new one with minimal examples which are the same across every language, and actually maintain the repo so as not to let it become overgrown.|
|
||||
|[Onboarding Overhaul](https://github.com/appium/appium/issues/7169)|Have a new site built with MkDocs that documents all of the Selenium and Appium commands with code samples|1/2018|n/a|appium.io|
|
||||
|[New Appium GUIs](https://github.com/appium/appium/issues/7167)|The current Appium GUIs (Appium.app and Appium.exe) have a number of issues. They aren't maintained by the core Appium team. They're written in Objective-C and C# respectively: two languages, and specifically, two languages other than Appium's core language. Because of this they lag behind the Appium server and are often broken. However, users love them primarily because of the Inspector feature (the thing that lets them graphically navigate their app), so we have to field a ton of complaints about these projects. There's an opportunity to start over. With [Electron](http://electron.atom.io/), we'd be able to take the new version of Appium we're working on and embed it directly inside a Node-based GUI app written using the languages and technologies the core team is experienced with. We'd have one codebase and could distribute the app on Mac, Windows, and Linux. The GUIs would become an official part of Appium's release cycle so they wouldn't be broken.|3/2017|N/A|[Appium Desktop website](https://github.com/appium/appium-desktop)|
|
||||
|[Android 7.1.1 Support](https://github.com/appium/appium/issues/7165)|Google has released Android 7.1.1 (API Level 25). Ensure it works with UiAutomator 1/2|2/2017|1.6.4||
|
||||
|[Android 7.0 Support](https://github.com/appium/appium/issues/7156)|Support Android 7 (Nougat)|11/2016|1.6.3||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"targets": {
|
||||
"node": "12"
|
||||
},
|
||||
"shippedProposals": true
|
||||
}
|
||||
]
|
||||
],
|
||||
"plugins": ["source-map-support", "@babel/plugin-transform-runtime"],
|
||||
"comments": false,
|
||||
"sourceMaps": "both",
|
||||
"env": {
|
||||
"coverage": {
|
||||
"plugins": [
|
||||
[
|
||||
"istanbul",
|
||||
{
|
||||
"exclude": ["test", "build"]
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"test": {
|
||||
"retainLines": true,
|
||||
"comments": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
/* eslint no-console:0 */
|
||||
|
||||
/*
|
||||
* Small tool, launching and monitoring ios-web-kit-proxy, and relaunching
|
||||
* Small tool, launching and monitoring ios-web-kit-proxy, and relauching
|
||||
* on predefined errors.
|
||||
*
|
||||
* Usage:
|
||||
@@ -18,7 +18,7 @@
|
||||
* brew install --HEAD ideviceinstaller
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
const spawn = require('child_process').spawn;
|
||||
const _ = require('lodash');
|
||||
@@ -39,29 +39,29 @@ const handleKillProcess = function (exitCode) {
|
||||
};
|
||||
|
||||
const startProxy = function () {
|
||||
console.log(`RUNNING: ${PROXY_CMD} ${args.join(' ')}`);
|
||||
console.log('RUNNING:', PROXY_CMD, args.join(' '));
|
||||
|
||||
proxy = spawn(PROXY_CMD, args);
|
||||
|
||||
proxy.stdout.on('data', function onStdout (data) {
|
||||
console.log(`stdout: ${data}`);
|
||||
proxy.stdout.on('data', function (data) {
|
||||
console.log('stdout: ' + data);
|
||||
});
|
||||
|
||||
proxy.stderr.on('data', function onStderr (data) {
|
||||
console.log(`stderr: ${data}`);
|
||||
const restartMessage = _(RESTART_ON_MESSAGES).find(function findMessage (message) {
|
||||
proxy.stderr.on('data', function (data) {
|
||||
console.log('stderr: ' + data);
|
||||
const restartMessage = _(RESTART_ON_MESSAGES).find(function (message) {
|
||||
return ('' + data).indexOf(message) >= 0;
|
||||
});
|
||||
if (restartMessage) {
|
||||
console.log(`Detected error message: ${restartMessage}`);
|
||||
console.log('Detected error message:', restartMessage);
|
||||
console.log('Killing proxy!');
|
||||
proxy.kill('SIGTERM');
|
||||
process.nextTick(startProxy);
|
||||
}
|
||||
});
|
||||
|
||||
proxy.on('close', function onClose (code) {
|
||||
console.log(`Child process exited with code ${code}`);
|
||||
proxy.on('close', function (code) {
|
||||
console.log('child process exited with code ' + code);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# parameters: # No params yet, but may add later
|
||||
jobs:
|
||||
- job: generate_docs
|
||||
pool:
|
||||
vmImage: "macOS 10.14"
|
||||
variables:
|
||||
CC: gcc
|
||||
CXX: g++
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '12.x'
|
||||
- script: |
|
||||
# do git stuff
|
||||
npm install
|
||||
brew install hub
|
||||
hub --version
|
||||
git remote add triager https://triager:$GITHUB_TOKEN@github.com/appium/appium
|
||||
git checkout -b generate-docs-$BUILD_SOURCEVERSION
|
||||
git status
|
||||
displayName: Checkout Generate Docs Branch
|
||||
env:
|
||||
GITHUB_TOKEN: $(GITHUB_TOKEN)
|
||||
- script: |
|
||||
# Generate the docs
|
||||
npm run generate-docs
|
||||
git add .
|
||||
|
||||
# log the status so we know what is going on, on failure
|
||||
git status -s
|
||||
|
||||
# If docs were generated, make a PR to update the docs
|
||||
if [[ -n $(git status -s) ]]; then
|
||||
git commit -a -n -m 'Update generated docs [ci skip]'
|
||||
git push triager generate-docs-$BUILD_SOURCEVERSION
|
||||
hub pull-request -b "appium:master" -h "appium:generate-docs-$BUILD_SOURCEVERSION" -m "docs: Update auto-generated docs"
|
||||
fi
|
||||
displayName: Generate Docs and Make PR
|
||||
env:
|
||||
GITHUB_TOKEN: $(GITHUB_TOKEN)
|
||||
@@ -1,2 +0,0 @@
|
||||
jobs:
|
||||
- template: templates/bundle-template.yml
|
||||
@@ -1,3 +0,0 @@
|
||||
const semver = require('semver');
|
||||
const { version } = require('../../package.json');
|
||||
console.log(semver(version).prerelease[0]); //eslint-disable-line no-console
|
||||
@@ -1,22 +0,0 @@
|
||||
const path = require('path');
|
||||
const { fs, logger } = require('appium-support');
|
||||
const { asyncify } = require('asyncbox');
|
||||
const packageJson = require('../../package.json');
|
||||
|
||||
const log = new logger.getLogger('Create Release Branch:');
|
||||
|
||||
async function setPackageJsonVersion (version = `${process.env.MINOR_BRANCH_NAME}.0-rc.0`) {
|
||||
packageJson.version = version;
|
||||
log.info(`Setting version to: ${version}`);
|
||||
await fs.writeFile(
|
||||
path.resolve(__dirname, '..', '..', 'package.json'),
|
||||
JSON.stringify(packageJson, null, 2),
|
||||
'utf8',
|
||||
);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
asyncify(setPackageJsonVersion);
|
||||
}
|
||||
|
||||
module.exports = setPackageJsonVersion;
|
||||
@@ -1,40 +0,0 @@
|
||||
# parameters: # No params yet, but may add later
|
||||
jobs:
|
||||
- job: bundle_and_upload_appium_zip
|
||||
pool:
|
||||
vmImage: 'macOS 10.14'
|
||||
variables:
|
||||
CC: gcc
|
||||
CXX: g++
|
||||
steps:
|
||||
- script: gcc --version
|
||||
displayName: Print GCC Version
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '12.x'
|
||||
- script: npm install
|
||||
displayName: Install NPM Dependencies
|
||||
- script: npm run build
|
||||
displayName: npm run build
|
||||
- script: npm prune --production
|
||||
displayName: Get rid of dev dependencies
|
||||
- script: |
|
||||
curl -o node-darwin.tar.gz https://nodejs.org/dist/v12.16.1/node-v12.16.1-darwin-x64.tar.gz
|
||||
mkdir node-darwin-unpacked
|
||||
tar -xzf node-darwin.tar.gz -C node-darwin-unpacked/ --strip-components 1
|
||||
rm -f node-darwin.tar.gz
|
||||
cp node-darwin-unpacked/bin/node node-darwin
|
||||
rm -rf node-darwin-unpacked
|
||||
displayName: Download NodeJS
|
||||
- script: npm run zip
|
||||
displayName: Create the bundle zip
|
||||
- script: npm install
|
||||
displayName: Reinstall dev dependencies
|
||||
- task: PublishPipelineArtifact@0
|
||||
inputs:
|
||||
targetPath: appium.zip
|
||||
artifactName: appium
|
||||
- script: npm run upload
|
||||
env:
|
||||
GITHUB_TOKEN: $(GITHUB_TOKEN)
|
||||
displayName: Upload to appium/appium-build-store Github Releases
|
||||
@@ -1,31 +0,0 @@
|
||||
# parameters: # No params yet, but may add later
|
||||
jobs:
|
||||
- job: update_appium_io
|
||||
pool:
|
||||
vmImage: 'Ubuntu-18.04'
|
||||
variables:
|
||||
CC: gcc
|
||||
CXX: g++
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '10.x'
|
||||
- script: |
|
||||
pip install mkdocs==0.16.3
|
||||
git config --global user.email "maintainers@appium.io"
|
||||
git config --global user.name "Appium Triager"
|
||||
git clone https://triager:$GITHUB_TOKEN@github.com/appium/appium.io.git --branch=gh-pages
|
||||
pushd appium.io
|
||||
git remote add triager https://triager:$GITHUB_TOKEN@github.com/appium/appium.io
|
||||
git checkout -b docs-$BUILD_SOURCEVERSION
|
||||
bundle install
|
||||
npm install
|
||||
npm run build:docs
|
||||
git add docs
|
||||
git commit -a -n -m "docs: Update documentation for latest version"
|
||||
git push triager docs-$BUILD_SOURCEVERSION
|
||||
hub pull-request -b "appium:gh-pages" -h "appium:docs-$BUILD_SOURCEVERSION" -m "docs: Update documentation for latest version"
|
||||
popd
|
||||
displayName: Make branch with Updated Docs and make PR
|
||||
env:
|
||||
GITHUB_TOKEN: $(GITHUB_TOKEN)
|
||||
@@ -1 +1 @@
|
||||
The latest doc in Chinese, maintained by TesterHome Appium 中文文档小组.
|
||||
The latest doc in Chinese, maintained by [TesterHome Appium 中文文档小组](https://testerhome.com/appium-doc-cn).
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
## 支持 Appium 服务器的客户端程序库列表
|
||||
|
||||
这些库封装了标准的 Selenium 客户端,提供了所有 [JSON Wire protocol](https://w3c.github.io/webdriver/webdriver-spec.html) 指定的常规 selenium 命令,并额外添加操控移动设备相关的命令,例如 **多点触控手势** 和 **屏幕方向**。
|
||||
这些库封装了标准的 Selenium 客户端,提供了所有 [JSON Wire protocol](https://w3c.github.io/webdriver/webdriver-spec.html) 指定的常规 selenium 命令,额外添加操控移动设备相关的命令,例如 **多点触控手势** 和 **屏幕方向**。
|
||||
|
||||
Appium 客户端程序库实现了 [Mobile JSON Wire Protocol](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md)(一个基于官方标准协议的扩展草案),和 [W3C Webdriver 规范](https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html)(一个无关传输的自动化规范;这是定义 MultiAction API 的地方)中的元素。
|
||||
Appium 客户端程序库实现了 [Mobile JSON Wire Protocol](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md)(一个基于标准官方协议的扩展草案)和 [W3C Webdriver 规格](https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html)(一个无关传输的自动化规格;定义 MultiAction API 的地方)中的元素。
|
||||
|
||||
Appium 服务端自身定义了基于官方协议的扩展,帮助 Appium 用户使用各种设备操作(例如在测试会话过程中安装 / 卸载应用)。这就是为什么我们需要 Appium 特定的客户端,而不只是「原生(vanilla)」的 Selenium 客户端。当然,Appium 客户端程序库只是**增加**了功能(实际上,它们只是扩展了标准 Selenium 客户端),因此它们仍适用于常规的 Selenium 会话。
|
||||
Appium 服务端自定义了基于官方协议的扩展,帮助 Appium 用户使用各种设备操作(例如在测试会话过程中安装/卸载应用)。这就是为什么我们需要 Appium 特定的客户端,而不只是“原味”的 Selenium 客户端。当然,Appium 客户端程序库只增加功能(其实它们只是扩展了标准 Selenium 客户端),所以它们仍然适用于常规的 Selenium 会话。
|
||||
|
||||
语言 / 框架 | Github 仓库和安装指南 |
|
||||
语言/框架 | Github 仓库和安装指南 |
|
||||
----- | ----- |
|
||||
Ruby | [https://github.com/appium/ruby_lib](https://github.com/appium/ruby_lib), [https://github.com/appium/ruby_lib_core](https://github.com/appium/ruby_lib_core)
|
||||
Ruby | [https://github.com/appium/ruby_lib](https://github.com/appium/ruby_lib)
|
||||
Python | [https://github.com/appium/python-client](https://github.com/appium/python-client)
|
||||
Java | [https://github.com/appium/java-client](https://github.com/appium/java-client)
|
||||
JavaScript (Node.js) | [https://github.com/admc/wd](https://github.com/admc/wd)
|
||||
JavaScript (Node.js) | [https://github.com/webdriverio/webdriverio](https://github.com/webdriverio/webdriverio)
|
||||
JavaScript (Browser) | [https://github.com/projectxyzio/web2driver](https://github.com/projectxyzio/web2driver)
|
||||
Objective C | [https://github.com/appium/selenium-objective-c](https://github.com/appium/selenium-objective-c)
|
||||
PHP | [https://github.com/appium/php-client](https://github.com/appium/php-client)
|
||||
C# (.NET) | [https://github.com/appium/appium-dotnet-driver](https://github.com/appium/appium-dotnet-driver)
|
||||
RobotFramework | [https://github.com/jollychang/robotframework-appiumlibrary](https://github.com/jollychang/robotframework-appiumlibrary)
|
||||
|
||||
---
|
||||
EOF.
|
||||
|
||||
由 @黑水 翻译,TesterHome 社区 id:sanlengjingvv
|
||||
|
||||
@lihuazhang 校验
|
||||
|
||||
翻译:@[Pandorym](https://github.com/Pandorym)
|
||||
Last english version: ef49649f5e53a644f6732575734aeaea78068234, Feb 22, 2019
|
||||
@lihuazhang 校验
|
||||
@@ -1,73 +1,64 @@
|
||||
## Appium 介绍
|
||||
|
||||
Appium 是一个开源工具,用于自动化 iOS 手机、 Android 手机和 Windows 桌面平台上的原生、移动 Web 和混合应用。**「原生应用」**指那些用 iOS、 Android 或者 Windows SDKs 编写的应用。**「移动 Web 应用」**是用移动端浏览器访问的应用( Appium 支持 iOS 上的 Safari 、Chrome 和 Android 上的内置浏览器)。**「混合应用」**带有一个「webview」的包装器——用来和 Web 内容交互的原生控件。类似于 [Apache Cordova](https://cordova.apache.org) 或 [Phonegap](http://phonegap.com/) 项目,创建一个混合应用使得用 Web 技术开发然后打包进原生包装器创建一个混合应用变得容易了。
|
||||
Appium 是一个开源工具,用于自动化 iOS 手机 、 Android 手机和 Windows 桌面平台上的原生、移动 Web 和混合应用。“原生应用”指那些用 iOS 、 Android 或者 Windows SDK 编写的应用。“移动 web 应用”是用移动端浏览器访问的应用(Appium 支持 iOS 上的 Safari 、Chrome 和 Android 上的内置浏览器)。“混合应用”带有一个 "webview" 的包装器——用来和 Web 内容交互的原生控件。类似 [Phonegap](http://phonegap.com/) 的项目,让用 Web 技术开发然后打包进原生包装器创建一个混合应用变得容易了。
|
||||
|
||||
重要的是,Appium 是跨平台的:它允许你用同样的 API 对多平台(iOS、Android、Windows)写测试。做到在 iOS、Android 和 Windows 测试套件之间复用代码。
|
||||
重要的是,Appium 是跨平台的:它允许你用同样的 API 对多平台写测试,做到在 iOS 、Android 和 Windows 测试套件之间复用代码。
|
||||
|
||||
了解 Appium “支持”这些平台意味着什么、有哪些自动化方式的详细信息,请参见 [Appium 支持的平台](/docs/cn/about-appium/platform-support.md)。
|
||||
了解 Appium “支持”这些平台意味着什么、有哪些自动化方式的详细信息,请参见[ Appium 支持的平台](/docs/cn/appium-setup/platform-support.md)。
|
||||
|
||||
### Appium 的理念
|
||||
|
||||
Appium 旨在满足移动端自动化需求的理念,概述为以下四个原则:
|
||||
|
||||
1. 你不应该为了自动化而重新编译你的应用或以任何方式修改它。
|
||||
Appium 旨在满足移动端自动化需求的理念,概述为以下四个原则:
|
||||
1. 你没有必要为了自动化而重新编译你的应用或者以任何方式修改它。
|
||||
2. 你不应该被限制在特定的语言或框架上来编写运行测试。
|
||||
3. 移动端自动化框架不应该在自动化接口方面重造轮子。
|
||||
4. 移动端自动化框架应该开源,在精神、实践以及名义上都该如此。
|
||||
3. 移动端自动化框架在自动化接口方面不应该重造轮子。
|
||||
4. 移动端自动化框架应该开源,不但在名义上而且在精神和实践上都要实至名归。
|
||||
|
||||
### Appium 的设计
|
||||
|
||||
那么 Appium 项目的架构是如何实现这些理念的呢?为了实现理念#1,我们使用了系统自带的自动化框架。这样,我们不需要把 Appium 特定的或者第三方的代码编译进你的应用,这意味着**你测试使用的应用与最终发布的应用并无二致**。我们使用以下系统自带的自动化框架:
|
||||
那么 Appium 项目的架构如何实现这一理念呢?为了实现第一点要求,我们其实使用了系统自带的自动化框架。这样,我们不需要把 Appium 特定的或者第三方的代码编译进你的应用。这意味着你测试使用的应用与最终发布的应用并无二致。我们使用以下系统自带的自动化框架:
|
||||
|
||||
* iOS 9.3 及以上: 苹果的 [XCUITest](https://developer.apple.com/reference/xctest)
|
||||
* iOS 9.3 及以下: 苹果的 [UIAutomation](https://web.archive.org/web/20160904214108/https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/)
|
||||
* Android 4.3+: 谷歌的 [UiAutomator / UiAutomator2](https://developer.android.com/training/testing/ui-automator)
|
||||
* Android 2.3+: 谷歌的 [Instrumentation](http://developer.android.com/reference/android/app/Instrumentation.html). (通过绑定独立的项目—— [Selendroid](http://selendroid.io) 提供对 Instrumentation 的支持)
|
||||
* iOS 9.3 及以上:苹果的 [XCUITest](https://developer.apple.com/reference/xctest)
|
||||
* iOS 9.3 及以下:苹果的 [UIAutomation](https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/)
|
||||
* Android 4.2+: 谷歌的 [UiAutomator](http://developer.android.com/tools/help/uiautomator/index.html)
|
||||
* Android 2.3+: 谷歌的 [Instrumentation](http://developer.android.com/reference/android/app/Instrumentation.html)(通过绑定另外的项目——[ Selendroid ](http://selendroid.io)提供 Instrumentation 的支持)
|
||||
* Windows: 微软的 [WinAppDriver](http://github.com/microsoft/winappdriver)
|
||||
|
||||
为了实现理念#2,我们把这些系统本身提供的框架包装进一套 API —— [WebDriver](http://docs.seleniumhq.org/projects/webdriver/) API 中。WebDriver(也叫「Selenium WebDriver」)规定了一个客户端-服务器协议(称为 [JSON Wire Protocol](https://w3c.github.io/webdriver/webdriver-spec.html)),按照这种客户端-服务器架构,可以使用任何语言编写的客户端向服务器发送适当的 HTTP 请求。已经有为 [各个流行编程语言编写的客户端](http://appium.io/downloads) 。这也意味着你可以自由使用任何你想用的的测试运行器和测试框架;客户端程序库不过是一个简单的 HTTP 客户端,可以以任何你喜欢的方式混入你的代码。换句话说,Appium & WebDriver 客户端在技术上而言不是「测试框架」,而是「自动化程序库」。你可以以任何你喜欢的方式管理你的测试环境!
|
||||
为了实现第二点要求,我们把这些(系统本身的)供应商提供的框架包装进一套 API —— [WebDriver](http://docs.seleniumhq.org/projects/webdriver/) API 中。WebDriver(也叫 "Selenium WebDriver")规定了一个客户端-服务器协议(称为 [JSON Wire Protocol](https://w3c.github.io/webdriver/webdriver-spec.html)),按照这种客户端-服务器架构,可以使用任何语言编写的客户端向服务器发送适当的 HTTP 请求。已经有[各个流行编程语言编写的客户端](http://appium.io/downloads)了。这也意味着你可以自由使用任何你想要的测试运行器和测试框架;客户端程序库不过是 HTTP 客户端,可以以任何你喜欢的方式混入你的代码。换句话说,Appium 和 WebDriver 客户端不是严格意义上的“测试框架”,而是“自动化程序库”。你可以以任何你喜欢的方式管理你的测试环境!
|
||||
|
||||
我们以同样的方式实现理念#3:WebDriver 已经成为 Web 浏览器自动化事实上的标准,并且是一个 [W3C 工作草案](https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html)。何必在移动端做完全不同的尝试?我们通过附加额外的 API 方法 [扩展协议](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md),这些方法对移动自动化非常有用。
|
||||
我们以同样的方式实现第三点要求:WebDriver 已经成为 Web 浏览器自动化事实上的标准,并且是一个[ W3C 工作草案](https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html)。何必在移动端做完全不同的尝试?我们通过附加可用于移动端自动化的 API 方法[扩展了协议](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md)。
|
||||
|
||||
理念#4是明确已知的——你在阅读正是因为 [Appium 是开源的](https://github.com/appium/appium)。
|
||||
显然第 4 点是你在阅读的前提——[ Appium 是开源的](https://github.com/appium/appium)
|
||||
|
||||
### Appium 的概念
|
||||
### Appium 概念
|
||||
|
||||
**客户端 / 服务器架构**<br/>
|
||||
Appium 的核心一个是暴露 REST API 的 WEB 服务器。它接受来自客户端的连接,监听命令并在移动设备上执行,答复 HTTP 响应来描述执行结果。实际上客户端 / 服务器架构给予了我们许多可能性:我们可以使用任何有 http 客户端 API 的语言编写我们的测试代码,不过选一个 [Appium 客户端程序库](http://appium.io/downloads) 用起来更为容易。我们可以把服务器放在另一台机器上,而不是执行测试的机器。我们可以编写测试代码,并依靠类似 [Sauce Labs](https://saucelabs.com/products/mobile-app-testing) 的云服务接收和解释命令。
|
||||
**客户端/服务器架构**<br/>
|
||||
Appium 的核心是暴露 REST API 的网络服务器。它接受来自客户端的连接,监听命令并在移动设备上执行,答复表示执行结果的 HTTP 响应。客户端/服务器架构实际给予了许多可能性:我们可以使用任何有 http 客户端 API 的语言编写我们的测试代码,不过选一个[ Appium 客户端程序库
|
||||
](http://appium.io/downloads)用更容易。我们可以把服务器放在另一台机器上,而不是执行测试的机器。我们可以编写测试代码,并依靠类似 [Sauce Labs](https://saucelabs.com/mobile) 的云服务接收和解释命令。
|
||||
|
||||
**会话(Session)**<br/>
|
||||
自动化始终在一个会话的上下文中执行,这些客户端程序库以各自的方式发起与服务器的会话,但最终都会发给服务器一个 `POST /session` 请求,请求中包含一个被称作「预期能力(Desired Capabilities)」的 JSON 对象。这时服务器就会开启这个自动化会话,并返回一个用于发送后续命令的会话 ID。
|
||||
**会话(session)**<br/>
|
||||
自动化始终在一个会话的上下文中执行,这些客户端程序库以各自的方式发起与服务器的会话,但都以发给服务器一个 `POST /session` 请求结束,请求中包含一个被称作 'desired capabilities' 的 JSON 对象。这时服务器就会开启这个自动化会话,并返回一个用于发送后续命令的会话 ID。
|
||||
|
||||
**预期能力(Desired Capabilities)**<br/>
|
||||
预期能力(Desired Capabilities)是一些发送给 Appium 服务器的键值对集合(比如 map 或 hash),它告诉服务器我们想要启动什么类型的自动化会话。也有许多能力(Capabilities)可以修改服务器在自动化过程中行为。例如,我们可以将 `platformName` 能力设置为 `iOS`,以告诉 Appium 我们想要 iOS 会话,而不是 Android 或者 Windows 会话。或者我们也可以设置 `safariAllowPopups` 能力为 `true` ,确保我们在 Safari 自动化会话期间可以使用 JavaScript 打开新窗口。有关 Appium 能力的完整列表,请参阅 [能力文档](/docs/cn/writing-running-appium/caps.md) 。
|
||||
**Desired Capabilities**<br/>
|
||||
Desired capabilities 是一些发送给 Appium 服务器的键值对集合 (比如 map 或 hash),告诉服务器我们想要启动什么类型的自动化会话。也有各种可以在自动化运行时修改服务器行为的 capabilities。例如,我们可以把 `platformName` capability 设置为 `iOS`,告诉 Appium 我们想要 iOS 会话,而不是 Android 或者 Windows 会话。我们也可以设置 `safariAllowPopups` capability 为 `true` ,确保我们在 Safari 自动化会话中可以使用 javascript 打开新窗口。有关 Appium capabilities 的完整列表,请参阅 [capabilities doc](/docs/cn/writing-running-appium/caps.md) 。
|
||||
|
||||
**Appium 服务器**<br/>
|
||||
Appium 是一个用 Node.js 写的服务器。可以从[源码](https://github.com/appium/appium/blob/master/docs/cn/contributing-to-appium/appium-from-source.md)构建安装或者从 [NPM](https://www.npmjs.com/package/appium) 直接安装:
|
||||
|
||||
Appium 是用 Node.js 写的服务器。它可以从[源码](https://github.com/appium/appium/blob/master/docs/en/contributing-to-appium/appium-from-source.md)构建安装或者从 NPM 直接安装:
|
||||
```
|
||||
$ npm install -g appium
|
||||
$ appium
|
||||
```
|
||||
|
||||
Appium 的 `beta` 版本可以通过 NPM 使用 `npm install -g appium@beta` 指令进行安装。它是开发版本,所以可能存在破坏性的变更。在安装新版本请卸载 `appium@beta` (`npm uninstall -g appium@beta`)以获得一组干净的依赖。
|
||||
|
||||
**Appium 客户端**<br/>
|
||||
有一些客户端程序库(分别在 Java、Ruby、Python、PHP、JavaScript 和 C# 中实现),它们支持 Appium 对 WebDriver 协议的扩展。你需要用这些客户端程序库代替常规的 WebDriver 客户端。你可以在[这里](/docs/cn/about-appium/appium-clients.md)浏览所有程序库的列表。
|
||||
有多个客户端程序库(Java、Ruby、Python、PHP,、JavaScript 和 C# 的)支持 Appium 对 WebDriver 协议的扩展,你需要用这些客户端程序库代替通常的 WebDriver 客户端。在[这里](appium-clients.md)浏览所有程序库的列表。
|
||||
|
||||
**[Appium Desktop](https://github.com/appium/appium-desktop)**<br/>
|
||||
这有一个 Appium 服务器的图形界面封装可以下载,它适用于任何平台。它打包了 Appium 服务器运行需要的所有东西,所以你不需要为 Node 而烦恼。它们还提供一个 Inspector 使你可以查看应用程序的层级结构。这在写测试时可以派上用场。
|
||||
**[Appium.app](https://github.com/appium/appium-dot-app), [Appium.exe](https://github.com/appium/appium-dot-exe)**<br/>
|
||||
有 Appium 服务器的图形界面包装器可以下载。它们打包了 Appium 服务器运行需要的所有东西,所以你不需要为 Node 而烦恼。它们还提供一个 Inspector 使你可以查看你应用的层级结构,这在写测试时很方便。
|
||||
|
||||
### 入门指南
|
||||
|
||||
恭喜!你现在有足够的知识来使用 Appium 了。 为什么不前往 [入门指南](/docs/en/about-appium/getting-started.md)(English) 了解更多详细的要求和指南呢?
|
||||
恭喜!你现在有足够的知识来使用 Appium 了。 为什么不前往 [入门指南](/docs/cn/README.md) 了解更多详细的要求和指南呢?
|
||||
|
||||
---
|
||||
EOF.
|
||||
由 @黑水 翻译,TesterHome 社区 id:sanlengjingvv
|
||||
|
||||
由 @黑水 翻译,TesterHome 社区 id:sanlengjingvv</br>
|
||||
@lihuazhang 校验
|
||||
|
||||
翻译:@[Pandorym](https://github.com/Pandorym)
|
||||
|
||||
Last english version: ef7a1b17124966dbb87442d7356614791fe5e9ce, Oct 8, 2018
|
||||
@lihuazhang 校验
|
||||
@@ -1,20 +1,22 @@
|
||||
## Selenium Grid
|
||||
# Selenium Grid
|
||||
|
||||
通过服务器参数 `--nodeconfig`,可以将 appium 服务器注册到本地的 [Selenium grid](https://github.com/SeleniumHQ/selenium/wiki/Grid2)
|
||||
通过 `--nodeconfig` 这个服务端参数,可以将 appium server 注册到本地的 [Selenium grid](https://code.google.com/p/selenium/wiki/Grid2) ([Grid 的配置文档](http://docs.seleniumhq.org/docs/07_selenium_grid.jsp))
|
||||
|
||||
```center
|
||||
> appium --nodeconfig /path/to/nodeconfig.json
|
||||
> appium --nodeconfig /path/to/nodeconfig.json
|
||||
# 或者使用源文件执行
|
||||
> node . --nodeconfig /path/to/nodeconfig.json
|
||||
```
|
||||
|
||||
在 Selenium 节点(Node)的配置文件里,你需要定义 `browserName`、`version` 和 `platform`,然后 Grid 会通过这些参数将你的测试重定向到正确的设备上。你还需要配置 `host` 和 `selenium grid` 的详细信息。详细的参数列表和描述信息,请查看 这里。
|
||||
在 node 的配置文件里,你需要定义 `browserName`,`version` 和 `platform`。
|
||||
通过这些参数,selenium grid 会将你的测试定向到正确的设备上去。你还需要配置你的 `host` 详细信息和
|
||||
`selenium grid` 的详细信息。你可以在 <a href="http://code.google.com/p/selenium/source/browse/java/server/src/org/openqa/grid/common/defaults/GridParameters.properties">这里</a> 找到详细的参数列表和描述信息。
|
||||
|
||||
一旦你启动了 appium 服务器并且在 grid 里注册了信息,就可以在 grid 控制台看到你的设备:
|
||||
一旦你启动了 appium 服务器并且在 grid 里注册了信息,就可以在 grid 控制台发现你的设备:
|
||||
|
||||
"http://**\<grid-ip-adress\>**:**\<grid-port\>**/grid/console"
|
||||
|
||||
### Grid 节点的示例 JSON 配置文件
|
||||
### Grid node的配置文件例子
|
||||
|
||||
```xml
|
||||
{
|
||||
@@ -40,19 +42,14 @@
|
||||
"registerCycle": 5000,
|
||||
"hubPort": <grid_port>,
|
||||
"hubHost": "<Grid_host_name_or_grid_ip-address>"
|
||||
"hubProtocol": "<Protocol_of_Grid_defaults_to_http>"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
可以在 <a href="http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/Platform.html">这里</a>查看有效的 platform 参数。
|
||||
|
||||
如果没有给出 `url`、`host` 和 `port`,配置会自动指向 `localhost:whatever-port-Appium-started-on`。
|
||||
|
||||
如果你的 Appium Server 和 Selenium Grid 没有运行在同一台机器上,为确保 Selenium Grid 连接正常,请在你的 `host` & `url` 上使用外部域名或 IP 地址,而不是 `localhost` 和 `127.0.0.1`。
|
||||
如果你的 Appium Server 和 Selenium Grid 没有运行在同一台机器上,为确保 Selenium Grid 连接正常,请在你的 `host` & `url` 上使用外部域名或 IP 地址,而不是 localhost 和 127.0.0.1
|
||||
|
||||
---
|
||||
EOF.
|
||||
|
||||
本文由 [tobecrazy](https://github.com/tobecrazy) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
|
||||
翻译:@[Pandorym](https://github.com/Pandorym)
|
||||
Last english version: 048ca4be43d15e078f583ddb973e2dbe0212a988, Mar 29, 2018
|
||||
本文由 [tobecrazy](https://github.com/tobecrazy) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -8,12 +8,12 @@
|
||||
|
||||
在终端执行以下命令使用 Homebrew 安装最新版本的 ios-webkit-debug-proxy:
|
||||
|
||||
``` center
|
||||
``` center
|
||||
# 没有安装 brew 时才需要第一条命令。
|
||||
> ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
> brew update
|
||||
> brew install ios-webkit-debug-proxy
|
||||
```
|
||||
```
|
||||
|
||||
#### 从源码构建 ios-webkit-debug-proxy
|
||||
|
||||
@@ -70,4 +70,4 @@ $ sudo make install
|
||||
**注意:** 为了允许建立连接,设备上需要打开 **"Web 检查器"**。在 **设置 >
|
||||
safari > 高级** 中打开。Web 检查器作为 iOS6 的一部分被添加,不在之前的版本中提供,请知悉。
|
||||
|
||||
本文由 sanlengjingvv 翻译,由 lihuazhang 校验。
|
||||
本文由 [sanlengjingvv](https://testerhome.com/sanlengjingvv) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -21,7 +21,7 @@ from appium import webdriver
|
||||
```center
|
||||
from selenium import webdriver
|
||||
```
|
||||
|
||||
|
||||
### 新的 desired capabilities
|
||||
|
||||
不再使用以下的 capabilities:
|
||||
@@ -165,4 +165,4 @@ set_context "WEBVIEW"
|
||||
|
||||
就是这样!快乐的迁移!
|
||||
|
||||
本文由 高鹏 翻译,由 lihuazhang 校验。
|
||||
本文由 [高鹏](https://testerhome.com/026) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
# 从 Appium1.x 迁移到 Appium2.x
|
||||
|
||||
如果你正在使用 Appium1.x,并期望迁移至 Appium2.x,这份文档可以作为您的迁移指南。它包含了一系列我们重大变化的修改、您如何改变您的环境或测试套件来对 Appium2.0进行兼容。
|
||||
|
||||
## Appium 2.0 概述
|
||||
|
||||
Appium 2.0 是 Appium 近5年来最重要的新版本。首先,Appium2.0 最大的变化,*并不是* 对不同平台上的测试行为发生了改变。相反的,Appium 2.0 将Appium 重新定义为一个*平台*,它(Appium2.0)让驱动 (driver)(引入对给定平台自动化支持的代码项目)、插件(plugin)(允许覆盖、修改、扩展或向Appium添加行为的代码项目)变得更易创建与分享。
|
||||
|
||||
与此同时,Appium项目正在利用这个机会删除许多旧的和被弃用的功能。
|
||||
|
||||
这些都对Appium的安装方式、驱动程序和各种特性的管理方式以及协议支持等方面带来了一些重大变化。以下是详细说明。
|
||||
|
||||
## 重大变化
|
||||
|
||||
查看[Appium 2.0发布说明](https://github.com/appium/appium/releases/tag/v2.0.0-beta)以获得更全面的变更列表。这里有我们所郑重展示的重大变化,与您需要为他们做的一些事情。
|
||||
|
||||
#### :bangbang: 在准备过程中安装需要的驱动(drivers)
|
||||
|
||||
如果您使用过 Appium1.x,所有的能支持使用的驱动(driver)都会在同一时间通过Appium主服务安装好。现在已经不是这样了。简单地安装 Appium 2.0(例如,通过' npm install -g Appium '),将只会安装没有任何驱动(driver)的 Appium 的主服务。如果想要安装驱动(driver),您必须使用新的 [Appium 扩展命令行工具(Appium extension CLI)](../drivers/driver-cli.md)。例如,要安装XCUITest和UiAutomator2驱动程序的最新版本,在安装Appium之后,您将运行以下命令:
|
||||
|
||||
```
|
||||
appium driver install xcuitest
|
||||
appium driver install uiautomator2
|
||||
```
|
||||
|
||||
执行安装命令后,您的驱动程序已经安装就绪。使用这个CLI可以做的事情还有很多,所以一定要查看它的文档。
|
||||
如果您正在CI环境中运行,或期望在安装后接着安装一些驱动(driver),可以在安装时添加一些参数,如:
|
||||
|
||||
```
|
||||
npm install -g appium --drivers=xcuitest,uiautomator2
|
||||
```
|
||||
|
||||
这将为您一次性安装Appium和两个驱动程序。
|
||||
|
||||
#### :bangbang: 驱动(driver)更新
|
||||
|
||||
在过去,要更新 iOS 或 Android 驱动程序,你只需等待这些更新被整合到新发行的 Appium 中,然后更新你的 Appium 版本。在 Appium2.0,Appium 服务器和Appium 驱动(driver)的版本和发布是分开的。这意味着驱动(driver)的更新可以按照驱动本身的发布节奏进行发布,您可以在驱动程序更新发生时进行更新,而不是等待新的Appium服务器发布。检查驱动程序更新的方法是使用CLI:
|
||||
|
||||
```
|
||||
appium driver list --updates
|
||||
```
|
||||
|
||||
如果有任何驱动(driver)可以更新了,你可以对任何给定的驱动(driver)执行' update '命令:
|
||||
|
||||
```
|
||||
appium driver update xcuitest
|
||||
```
|
||||
|
||||
要更新 Appium 服务器本身,您需要执行与过去相同的操作:' npm install -g Appium '。现在,安装新版本的 Appium 服务器将不会影响您的驱动程序,因此整个过程将会更快。
|
||||
|
||||
#### :bangbang: 协议的变更
|
||||
|
||||
Appium 的 API 基于[W3C WebDriver协议](https://www.w3.org/TR/webdriver/),并且多年来一直遵循该协议。在 W3C WebDriver 协议被设计成 web 标准之前,Selenium 和 Appium 都曾使用了其他几个协议。这些协议是 "JSONWP" (JSON有线协议) 和 "MSJONWP"(移动JSON有线协议)。W3C协议与(M)JSONWP协议有几处不同。
|
||||
|
||||
在Appium 2.0之前,Appium支持这两种协议,因此较老的Selenium/Appium客户端(client)仍然可以与较新的Appium服务器通信。今后,对旧协议的支持将被移除。
|
||||
|
||||
:bangbang: *功能*
|
||||
|
||||
新旧协议之间的一个重要区别是功能的格式。以前称为“所需的功能”,现在简单地称为“功能”,现在对任何非标准功能都需要一个所谓的“供应商前缀”。标准的功能列表在[WebDriver协议规范](https://www.w3.org/TR/webdriver/#capabilities)中给出,包括一些常用的功能,如“browserName”和“platformName”。
|
||||
|
||||
这些标准功能仍可以按原来的方式使用。但是所有功能的名称中必须包含一个“供应商前缀”。vendor前缀是一个冒号后面的字符串,例如' appium: '。Appium的大多数功能都超出了标准的W3C功能,因此必须包含供应商前缀(我们建议您使用' appium: ',除非文档另有指示)。例如:
|
||||
|
||||
* `appium:app`
|
||||
* `appium:noReset`
|
||||
* `appium:deviceName`
|
||||
|
||||
针对Appium 2.0的测试套件来说,这些改变,可能是也可能不是一个重大的变化。如果你正在使用一个已经适配更新的 Appium 客户端(如:Appium-java-client等),客户端会在所有必要的功能上为你添加' appium: '前缀。新版本的Appium Inspector工具(如:Appium Desktop 或 Appium inspector)也会这样做。
|
||||
基于云的Appium提供商也可能这样做。因此,只要注意:如果您得到提示消息,说您的功能缺少供应商前缀,这就是解决问题的方法。
|
||||
|
||||
另外,使用不支持W3C协议的WebDriver客户端启动Appium会话将不再允许(请参阅下面关于WD库这种效果的注释)。
|
||||
|
||||
为了让每个人的生活更容易一些,我们还引入了一个选项,将所有与appium相关的功能打包到一个对象功能中,即 "appium:options"。你可以将任何你通常会在这个功能上添加' appium: '前缀的东西捆绑在一起。以下是一个关于如何在Safari浏览器上使用 "appium:options" 启动 iOS 会话的示例(基于原始JSON):
|
||||
|
||||
```json
|
||||
{
|
||||
"platformName": "iOS",
|
||||
"browserName": "Safari",
|
||||
"appium:options": {
|
||||
"platformVersion": "14.4",
|
||||
"deviceName": "iPhone 11",
|
||||
"automationName": "XCUITest"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
(当然,每个客户端都有不同的方式来创建结构化功能,如“appium:options”或其他你可能见过的功能,如“goog:chromeOptions”)。注意:在“appium:options”中显示的能力将覆盖在对象顶层显示的相同名称的能力。
|
||||
|
||||
:bangbang: *被删除的命令*
|
||||
|
||||
那些旧的JSON有线协议的一部分,并且不是W3C协议的一部分的命令不再可用:
|
||||
|
||||
* TODO (这些命令正在被归纳和删除,完成后将在这里进行更新)
|
||||
|
||||
如果您使用最新的 Appium 或 Selenium 客户端(client),那么无论如何您都不应该再访问这些文件,因此任何重大的改变都会首先在客户端体现。
|
||||
|
||||
#### :bangbang: 图像分析功能移至插件(plugin)
|
||||
|
||||
Appium 2.0 的设计目标之一,是将非核心特性迁移到称为[插件(plugins)](#TODO)的特殊扩展中。这会让大家选择性地、按需地花费功夫去安装并设置这些。
|
||||
Appium 的各种图像相关特性(图像比较、根据图像查找元素等)已经转移到官方支持的插件[图像插件(images)](https://github.com/appium/appium-plugins/tree/master/packages/images)中。
|
||||
|
||||
如果您使用了这些与图像相关的方法,并且需要继续使用它们,您需要做两件事。
|
||||
1. 安装插件:`appium plugin install images`
|
||||
2. 确保你启动了Appium服务器,通过在命令行指定的插件列表中包含它来运行插件,例如,`appium --plugins=images`
|
||||
|
||||
与图像相关的命令也将在客户端删除,这意味着您需要按照插件README上的说明安装客户端插件来访问这些功能。
|
||||
|
||||
#### :bangbang: 删除一些旧的驱动(driver)
|
||||
|
||||
The old iOS and Android (UiAutomator 1) drivers and related tools (e.g., `authorize-ios`) have been removed. They haven't been relevant for many years anyway.
|
||||
|
||||
旧版本的 iOS 与 Android 驱动(driver)(UiAutomator 1) 及相关联的工具(如:`authorize-ios`)已经被删除。他们已经很多年不被使用了。
|
||||
|
||||
#### :warning: 内部包重命名
|
||||
|
||||
一些 appium 内部的 NPM 包被重命名 (如:`appium-base-driver` 改为 `@appium/base-driver`)。这并不是一个突破性的变化,只是为了那些已经构建了直接合并Appium代码的软件的人来进行了解。
|
||||
|
||||
#### :warning: 不再支持“WD”JavaScript客户端库
|
||||
|
||||
多年来,Appium的一些作者维护了[WD](https://github.com/admc/wd)客户库。此库已弃用,并没有更新以与W3C WebDriver协议一起使用。因此,如果您正在使用这个库,您将需要转向一个更新的库。我们建议(WebdriverIO) (https://webdriver.io)。
|
||||
|
||||
#### :warning: 将 Appium 检查器(Appium Inspector)从 Appium Desktop 中分离出来
|
||||
|
||||
Appium Desktop 的检查器部分(查看页面元素树的功能)已经转移到它自己的app,Appium 检查器(Appium Inspector): [github.com/appium/appium-inspector](https://github.com/appium/appium-inspector)。它完全兼容Appium 2.0服务器。如果您只需要对页面元素树进行检查与操作,那么下载并运行检查器单独的app即可,不需要一定得下载GUI 版本的 Appium Desktop了。Appium Desktop 仍在原来的地方维护中,[github.com/appium/appium-desktop](https://github.com/appium/appium-desktop)。只是它不再会与检查器完全捆绑在一起了。
|
||||
|
||||
您也可以不需要下载 Appium 检查器(Appium Inspector),直接从网页访问[web version of Appium Inspector](https://inspector.appiumpro.com)。注意,要针对本地服务器进行测试,您需要使用`--allow-cors`启动服务器,以便基于浏览器的Appium Inspector可以访问您的Appium服务器来启动会话。
|
||||
|
||||
## 重要的新特性
|
||||
|
||||
除了上面提到的重大变化之外,本节列出了一些您也许会喜欢的 Appium 2.0 重要的新特性。
|
||||
|
||||
#### 插件(Plugins)
|
||||
|
||||
:tada: *服务端插件(Server Plugins)*
|
||||
|
||||
TODO
|
||||
|
||||
:tada: *客户端插件(Client Plugins)*
|
||||
|
||||
TODO
|
||||
|
||||
#### :tada: 从任何地方下载驱动(driver)与插件(plugin)
|
||||
|
||||
TODO
|
||||
|
||||
#### :tada: 驱动(driver)与插件(plugin)的命令行参数
|
||||
|
||||
TODO
|
||||
|
||||
## 云提供商的特别说明
|
||||
|
||||
本文之外的地方一般是Appium的通用部分,但Appium 2.0中的一些架构更改将对与Appium相关的服务提供商(无论是基于云的Appium主机还是内部服务)构成重大变化。最终,Appium服务器的维护者负责安装和提供终端用户可能希望使用的各种Appium驱动程序和插件。
|
||||
|
||||
有了 Appium 2.0,我们进入了一个新时代,终端用户可以使用各种独立版本的驱动(driver)和插件(plugin)。在 Appium 1.x 上,这是无法实现的。因为任何给定的 Appium 版本都会包含且仅包含每个驱动(driver)的一个版本。当然,这取决于每个服务提供商希望如何实现任何官方或第三方驱动程序或插件的发现、安装和可用性。但 Appium 团队希望就服务提供商支持的功能提出建议,以确保整个行业的一致性。这只是一个建议,而不是一个标准,但是采用它将帮助用户应对在云环境中使用 Appium 2.0 可能带来的日益增加的复杂性。
|
||||
|
||||
### 建议使用的功能
|
||||
|
||||
除了标准的`platformName`, `appium:deviceName`, `appium:automationName`, 与 `appium:platformVersion`,我们建议使用 `$cloud:appiumOptions`, 当标签为:`$cloud` 并不是要直接按这个写,而是应该被你的供应商前缀替换(举几个例子,HeadSpin应该是' HeadSpin ', Sauce Labs应该是' Sauce ', BrowserStack应该是' BrowserStack ')。`appium:platformVersion` 功能本身将是一个JSON对象,具有以下内部key:
|
||||
|
||||
|能力(Capability)|作用域(Used for)|示例(Example)|
|
||||
|----------|-------|-------|
|
||||
|`version`|指定用于托管和管理驱动程序的 Appium 服务器版本。如果不写,按提供商提供的为准,但建议提供最新的官方版本|`2.0.0`|
|
||||
|`automationVersion`|指定应该使用指定驱动程序的哪个版本。|`1.55.2`|
|
||||
|`automation`|指定要使用的自定义驱动程序(参见下面的更多信息)。将会覆盖: `appium:automationName` and `$cloud:automationVersion`|`{"name": "org/custom-driver", "source": "github", "package": "custom-driver"}`|
|
||||
|`plugins`|指定要激活的插件列表(以及可能的插件版本)(参见下面的更多信息)。|`["images", "universal-xml"]`|
|
||||
|
||||
### 基础示例
|
||||
|
||||
Appium扩展(驱动程序和插件)有一组属性,指定它们可以从哪里安装。云提供商显然没有义务为任意指定的扩展提供支持,因为这些扩展可能使得在托管环境中运行的不可信代码。在不支持任意扩展的情况下,`appium:automationName`, `$cloud:automationVersion`, 与 `$cloud:appiumPlugins`的功能应该足够了。以下JSON对象表示会话的功能:
|
||||
|
||||
```json
|
||||
{
|
||||
"platformName": "iOS",
|
||||
"appium:platformVersion": "14.4",
|
||||
"appium:deviceName": "iPhone 11",
|
||||
"appium:app": "Some-App.app.zip",
|
||||
"appium:automationName": "XCUITest",
|
||||
"$cloud:appiumOptions": {
|
||||
"appiumVersion": "2.0.0",
|
||||
"automationVersion": "3.52.0",
|
||||
"plugins": ["images"],
|
||||
}
|
||||
}
|
||||
```
|
||||
这组功能参数,指示 Appium 2.0 服务器支持 `3.52.0` 版本的 XCUITest 驱动程序,并激活`images`插件。云提供商很容易验证这个集合。显而易见,云提供商可以通过这些功能参数,做任何它想做的事情来响应这些功能,包括:动态下载Appium、驱动程序和插件包,或者如果请求的版本不在一个支持的集中,或者提示插件不支持,等等……
|
||||
|
||||
### `appium:options`的基础示例
|
||||
|
||||
前面的例子看起来仍然有点混乱,所以我们当然也建议云提供商支持 `appium:options` 参数,就像上面详细描述的那样,这可以将之前的功能集变成以下参数:
|
||||
|
||||
```json
|
||||
{
|
||||
"platformName": "iOS",
|
||||
"appium:options": {
|
||||
"platformVersion": "14.4",
|
||||
"deviceName": "iPhone 11",
|
||||
"app": "Some-App.app.zip",
|
||||
"automationName": "XCUITest",
|
||||
},
|
||||
"$cloud:appiumOptions": {
|
||||
"appiumVersion": "2.0.0",
|
||||
"automationVersion": "3.52.0",
|
||||
"plugins": ["images"],
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 扩展对象
|
||||
|
||||
一些服务提供商可能希望动态地允许访问 Appium 2.0 CLI 的所有特性,包括下载任意驱动程序和插件。为了支持使用这些扩展,我们可以定义特殊的JSON“扩展对象”,关键字如下:
|
||||
|
||||
* `name`: 扩展名。这是一个NPM包名(如果是从NPM下载),或者是一个git或GitHub规格(如果是从git服务器或GitHub下载)。
|
||||
* `version`: 扩展的版本,例如NPM包版本或Git SHA。
|
||||
* (optional) `source`: 扩展可以从哪里下载的表示。建议支持以下值: `appium`, `npm`, `git`, `github`。 这里的: `appium` 表示" Appium 自己的官方列表",如果不包含此key,`appium` 则应该是默认值。
|
||||
* (optional) `package`: 当从git或github下载扩展时,扩展的NPM包名也必须提供。对于非git源,这是可选的。
|
||||
|
||||
由于每个会话都由单个驱动程序处理,`$cloud:appiumOptions`/`$automation` 功能参数可以与扩展对象值一起使用,以表示该驱动程序,例如:
|
||||
|
||||
```json
|
||||
{
|
||||
...,
|
||||
"$cloud:appiumOptions": {
|
||||
...,
|
||||
"automation": {
|
||||
"name": "git+https://some-git-host.com/custom-driver-project.git",
|
||||
"version": "some-git-sha",
|
||||
"source": "git",
|
||||
"package": "driver-npm-package-name"
|
||||
},
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
由于会话可以处理多个插件,`$cloud:appiumPlugins` 列表中的每个值也可以是一个扩展对象,而不是字符串,这样就可以请求特定的版本:
|
||||
|
||||
```json
|
||||
{
|
||||
...,
|
||||
"$cloud:appiumOptions": {
|
||||
...,
|
||||
"plugins": [{
|
||||
"name": "images",
|
||||
"version": "1.1.0"
|
||||
}, {
|
||||
"name": "my-github-org/my-custom-plugin",
|
||||
"version": "a83f2e",
|
||||
"source": "github",
|
||||
"package": "custom-plugin"
|
||||
}],
|
||||
...,
|
||||
}
|
||||
...
|
||||
}
|
||||
```
|
||||
这些都是本文建议的说明性示例。当然,要由服务提供商在他们的前端/负载均衡器上实现对这些功能的处理,去完成任何情况下的错误检查,或运行任何一个用户请求的`appium driver` 或 `appium plugin` 。本节只是关于服务提供商如何设计他们面向用户的功能 API 的建议,如果他们自己运行 Appium,原则上支持 Appium 为最终用户提供的所有功能。
|
||||
@@ -111,16 +111,16 @@ Finally, a list of known issues with the initial 1.6 release (we'll strike throu
|
||||
|
||||
最后,列出了初始 1.6 版本的已知问题(已解决的问题会被横线划去):
|
||||
|
||||
* <del>无法以横向模式与设备上的元素进行交互(https://github.com/appium/appium/issues/6994)</del>
|
||||
* ~~无法以横向模式与设备上的元素进行交互(https://github.com/appium/appium/issues/6994)~~
|
||||
* `shake` 苹果不支持所以我们没有实现
|
||||
* `lock` 苹果不支持所以我们没有实现
|
||||
* 设置地理位置不被苹果支持,我们也不支持
|
||||
* 通过TouchAction / MultiAction API,`zoom` 手势支持,因为苹果的一个bug,`pinch` 手势不支持。
|
||||
* <del>通过TouchAction / MultiAction API,`swipe`手势目前不受支持,应该很快解决(https://github.com/appium/appium/issues/7573)</del>
|
||||
* ~~通过TouchAction / MultiAction API,`swipe`手势目前不受支持,应该很快解决(https://github.com/appium/appium/issues/7573)~~
|
||||
* `autoAcceptAlerts`, `autoDismissAlerts`目前还不能工作,而且我们是否能够在将来实施这些,存在争议。
|
||||
* iOS SDK 有一个问题,因此使用某些 API 方法构建的 PickerWheels 不能由 XCUITest 自动执行。有关解决方法,请参阅https://github.com/appium/appium/issues/6962,以确保您的 PickerWheels 正确构建。
|
||||
|
||||
我们将尽可能添加缺失的功能,并在以后的 Appium 版本中修复其他已知问题。
|
||||
|
||||
|
||||
本文由 校长 翻译,由 lihuazhang 校验。
|
||||
|
||||
本文由 [校长](https://testerhome.com/xushizhao) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -6,7 +6,10 @@ Appium 的 iOS 版本的后端用的是[Facebook's WebDriverAgent](https://githu
|
||||
* 如果使用了Appium的默认设置,则不需要如下的步骤。服务器将为您搞定一切,当然你也不能对WDA做太多控制。
|
||||
* 对连接的被测设备必须有SSH或物理访问权限。
|
||||
|
||||
### 安装WDA
|
||||
### 安装WDA
|
||||
|
||||
Appium 会自动下载 WebDriverAgent 源码。如果使用 npm 命令(`npm install -g appium`) 安装Appium的话,通常情况下会保存在/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent 目录下。
|
||||
如果是首次安装的话,还需要下载一些第三方依赖("carthage"工具就是为此准备的: `brew install carthage`):
|
||||
|
||||
```bash
|
||||
cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
|
||||
@@ -30,7 +33,7 @@ npm install -g iproxy
|
||||
|
||||
Xcode 会成功构建项目并安装到真机/模拟器上,所以您将在苹果系统的桌面上看到 WebDriverAgentRunner 应用程序的图标。
|
||||
|
||||
### 启动WDA
|
||||
### 启动WDA
|
||||
|
||||
WebDriverAgent 应用程序扮演一个 REST 服务的角色,接收外部 API 请求,然后传递给被测应用的原生 XCTest 调用。如果在模拟器上运行你的测试,REST 服务的地址将是localhost,如果在有实际的 IP 地址的真实设备上运行,REST 服务的地址将是实际的 ip 地址。我们使用 iproxy 将网络请求路由到通过 USB 连接的真实设备上,这意味着可以使用这个工具将模拟器和真实设备上的 WDA 网络地址统一。
|
||||
|
||||
@@ -279,5 +282,5 @@ public class WDAServer {
|
||||
* 模拟器ID可以从 `xcrun simctl list` 输出中解析
|
||||
* UrlChecker 类是从 org.openqa.selenium.net 包导入的
|
||||
|
||||
|
||||
本文由 simple 翻译,由 lihuazhang 校验。
|
||||
|
||||
本文由 [simple](https://testerhome.com/simple) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -0,0 +1,13 @@
|
||||
## Intel® 硬件加速执行管理器
|
||||
|
||||
如果你发现你的 android 模拟器运行速度太缓慢,而你的系统又运行在 Intel® 的 cpu 下,你可以试试 HAXM。 HAXM 可以让你利用你的硬件虚拟化技术,为你的模拟器加速。
|
||||
|
||||
* 使用 Android SDK Manager 安装 HAXM ,你会在 Extras 文件夹里找到这个包;
|
||||
* 你可以在 [Intel® 的网站][1] 找到所有相关的文档;
|
||||
* 这需要 x86 架构的模拟器镜像;
|
||||
* 使用 Intel 的安装包去安装 HAXM; 根据你已经安装过的版本不同,Android SDK Manager 可能会安装不成功(译者注:如果原来已经有一个旧版本,此时有可能会自动安装失败。建议在 [Intel® 的网站][1] 安装官方安装包手动安装)。
|
||||
|
||||
[1]: http://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager/
|
||||
|
||||
|
||||
翻译 by [thanksdanny](https://github.com/thanksdanny) ,由 [chenhengjie123](https://github.com/chenhengjie123) 校验
|
||||
@@ -0,0 +1,43 @@
|
||||
## Android 配置
|
||||
|
||||
开始配置之前,你需要安装 Node.js(v4 或更高版本)。具体请参考 [instructions for your flavor of linux](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager)。
|
||||
|
||||
在你安装完 Node.js 后,下一步就是安装 [Android SDK](http://developer.android.com/sdk/index.html).
|
||||
因为你需要运行 `android` tool(包含 SDK, 在 'tools' 目录下)。
|
||||
|
||||
|
||||
运行 `android` tool,并使用他来安装 Level 17 或更高级的 API。
|
||||
|
||||
(如果想通过源码运行 Appium,需要先用 [Apache Ant](http://ant.apache.org/) 去构建出 bootstrap jar包,Appium 会在 Android 模拟器或真机上运行该 jar 包。)
|
||||
|
||||
|
||||
最后,将环境变量 `$ANDROID_HOME` 配置为你的 Android SDK 路径。举个例子,假如你解压了 Android SDK 到 /usr/local/adt/,你应该在添加这行命令到你的 shell 环境变量中:
|
||||
|
||||
export ANDROID_HOME="/usr/local/adt/sdk"
|
||||
|
||||
|
||||
现在你已经配置好可以运行 Appium 的环境了!(如果你是通过源码运行的 Appium,应该确保你已经在 Appium 的代码目录下,运行过 `npm install` 安装所有的依赖。)
|
||||
|
||||
|
||||
### 对于 Android 老版本的一些额外配置
|
||||
|
||||
Appium 是用 [Selendroid](https://selendroid.io) 去运行Android 2.3到4.1版本。当 Appium 检测到当前正在运行旧版本,它就会自动地切换 Selendroid 去运行(这里不太对,如果要使用 Selendroid 需要指定),但假如你是使用源码去运行,你还需要一些额外的配置。
|
||||
|
||||
* 确保你已经安装 [Maven 3.1.1](http://maven.apache.org/download.cgi) 或已更新到 `mvn` 的最新版本
|
||||
|
||||
|
||||
### 运行 Appium Android 测试
|
||||
|
||||
在 Linux 环境上运行测试,你需要启动并运行一个 API 为 Level 17 或更高版本的 AVD。如果你是通过 NPM 安装的话,则直接在命令行输入 `appium` 去运行 Appium。如果是通过源码运行,在目录底下运行 `node .`。
|
||||
|
||||
阅读 [server documentation](/docs/cn/writing-running-appium/server-args.md) 你能查看所有命令行参数。
|
||||
|
||||
|
||||
### 注意
|
||||
|
||||
* 现在有一些 android 的硬件加速模拟器,他有自己的一些局限性。更多的信息你可以查看这份 [page](/docs/cn/appium-setup/android-hax-emulator.md).
|
||||
* 如果你想运行任何 Appium 的测试或使用任何电量相关的命令,需要确保在你的 AVD 的 `config.ini` 里 `hw.battery=yes` 。若为 Android 5.0, 则这是默认的
|
||||
* Selendroid 需要检测你的应用是否拥有以下权限:
|
||||
`<uses-permission android:name="android.**permission.INTERNET"/>`,假如你在使用 selendroid 或者更老的Android版本(也就是2.3到4.1)时,你应确保你的应用设置了 internet 权限。
|
||||
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -0,0 +1,51 @@
|
||||
## 在真机上部署 iOS 应用
|
||||
|
||||
准备在真机上运行 Appium 之前,你需要做好以下几件事:
|
||||
|
||||
1. 使用特定设备相关的参数去构建你的 app
|
||||
2. 使用第三方工具 [ideviceinstaller](https://github.com/libimobiledevice/ideviceinstaller) 将你构建的包部署到你的设备上
|
||||
|
||||
### Xcodebuild 的参数:
|
||||
|
||||
现在新版的 xcodebuild 允许使用的指定设置。请参考[developer.apple.com](https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html):
|
||||
|
||||
```center
|
||||
xcodebuild [-project projectname] [-target targetname ...]
|
||||
[-configuration configurationname] [-sdk [sdkfullpath | sdkname]]
|
||||
[buildaction ...] [setting=value ...] [-userdefault=value ...]
|
||||
```
|
||||
|
||||
在这资料中你会发现一些有用的 [设置](https://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-DontLinkElementID_10)
|
||||
|
||||
```center
|
||||
CODE_SIGN_IDENTITY (代码签名标识)
|
||||
描述: 指定代码签名标识的名称.
|
||||
示例值: iPhone Developer
|
||||
|
||||
```
|
||||
|
||||
PROVISIONING_PROFILE 虽然在可用的命令列表中移除了,但还是有必要设置的。
|
||||
|
||||
在 xcodebuild 命令中指定 "CODE_SIGN_IDENTITY" 与 "PROVISIONING_PROFILE" 的设置:
|
||||
|
||||
```center
|
||||
xcodebuild -sdk <iphoneos> -target <target_name> -configuration <Debug> CODE_SIGN_IDENTITY="iPhone Developer: Mister Smith" PROVISIONING_PROFILE="XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX"
|
||||
```
|
||||
|
||||
一旦成功,app 就会被构建到 `<app_dir>/build/<configuration>-iphoneos/<app_name>.app` 目录下。
|
||||
|
||||
### 使用 ideviceinstaller 部署
|
||||
|
||||
使用 Homebrew 去安装被标记为最新版本的 ideviceinstaller 工具,在终端运行以下命令:
|
||||
|
||||
``` center
|
||||
# 第一行命令只是在你没有安装好 brew 的情况下才需要执行
|
||||
> ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
> brew update
|
||||
> brew install ideviceinstaller
|
||||
> ideviceinstaller -u <UDID of device> -i <path of .app/.ipa>
|
||||
```
|
||||
|
||||
下一部分:[在真机上运行 Appium](real-devices.md)
|
||||
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -32,4 +32,4 @@ Appium 给用户提供了在一个机器上启动多个 Android sessions 的方
|
||||
如果你想运行 iOS 的并发测试,你需要使用 Sauce 上传你的 Appium 测试脚本,然后就可以运行多台 iOS 和 Android 的并发测试,只要你的账号允许。查看更多相关信息可以查看 [这里](https://docs.saucelabs.com/tutorials/appium/)。
|
||||
|
||||
|
||||
本文由 thanksdanny 翻译,由 lihuazhang 校验。
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -4,26 +4,29 @@ Appium 支持多种平台以及各种测试方式(native,hybrid,web,真
|
||||
|
||||
### iOS 平台支持
|
||||
|
||||
获取 iOS 平台下所需的必备条件和安装说明,请查阅 [XCUITest Driver](/docs/en/drivers/ios-xcuitest.md)(English)
|
||||
获取 iOS 平台下所需的必备条件和安装说明,请查阅 [Running on OS X: iOS](running-on-osx.md)
|
||||
|
||||
* 版本:9.0 及以上版本
|
||||
* 版本:7.1 及以上版本
|
||||
* 设备:iPhone 模拟器,iPad 模拟器,以及 iPhone 和 iPad 的真机
|
||||
* 是否支持 Native 应用:支持。如在模拟器执行,需要 debug 版本的 .app 包,在真机上运行则需要已签名的 .ipa 包。底层的框架是由苹果的 [XCUITest](https://developer.apple.com/reference/xctest) (或 [UIAutomation](https://web.archive.org/web/20160904214108/https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/) 支持更旧的版本) 所提供支持
|
||||
* 是否支持移动端浏览器:支持。我们通过移动端的 Safari 进行自动化测试。对于真机,`ios-webkit-remote-debugger` 工具是必须的。可惜的是对于 Safari 的 native 部分的自动化目前还不支持。更多介绍请查看 [mobile web doc](/docs/en/writing-running-appium/web/mobile-web.md)(English)。
|
||||
* 是否支持 Hybrid 应用:支持。如使用真机,ios-webkit-remote-debugger 工具也是必须的。更多介绍请查看 [hybrid doc](/docs/cn/writing-running-appium/web/hybrid.md)。
|
||||
* 是否支持 Native 应用:支持。如在模拟器执行,需要 debug 版本的 .app 包,在真机上运行则需要已签名的 .ipa 包。底层的框架是由苹果的 [XCUITest](https://developer.apple.com/reference/xctest) (或 [UIAutomation](https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/) 支持更旧的版本) 所提供支持
|
||||
* 是否支持移动端浏览器:支持。我们通过移动端的 Safari 进行自动化测试。对于真机,`ios-webkit-remote-debugger` 工具是必须的。可惜的是对于 Safari 的 native 部分的自动化目前还不支持。更多介绍请查看 [mobile web doc](/docs/cn/writing-running-appium/mobile-web.md)。
|
||||
* 是否支持 Hybrid 应用:支持。如使用真机,ios-webkit-remote-debugger 工具也是必须的。更多介绍请查看 [hybrid doc](/docs/cn/advanced-concepts/hybrid.md)。
|
||||
* 是否支持在一个 session 中多个应用的自动化:不支持
|
||||
* 是否支持多设备同时执行自动化:不支持
|
||||
* 是否支持多设备同时执行自动化:不支持
|
||||
* 是否支持第三方应用的自动化:仅支持在模拟器上仅有的第三方应用(设置,地图,等等...)。若在 iOS 10 及以上的版本,你同样可以在 home 界面做自动化。
|
||||
* 是否支持自定义的、非标准的 UI 控件的自动化:只支持小部分。你需要在控件设置可识别的信息,从而对一些元素进行一些基础的自动化操作。
|
||||
|
||||
### Android 平台支持
|
||||
|
||||
* 版本:4.3 及以上版本
|
||||
* 4.3 以及更高的版本是通过 Appium 自己的 [UiAutomator](http://developer.android.com/tools/testing-support-library/index.html#UIAutomator) 库实现。这是默认的自动化后台。
|
||||
查阅[Running on OS X: Android](running-on-osx.md),[Running on Windows](running-on-windows.md) 或者 [Running on Linux](running-on-linux.md) 查看更多的设备信息以及安装说明。
|
||||
|
||||
* 版本:2.3 及以上版本
|
||||
* 2.3 至 4.2 版本是通过 Appium 绑定的基于 [Instrumentation](http://developer.android.com/reference/android/app/Instrumentation.html)框架的 [Selendroid](http://selendroid.io)实现的自动化。Selendroid 的命令设置与默认的 Appium 有点不同, 支持的配置文件也同样不同。要获得在后台运行自动化的权限,需要环境配置中将 `automationName` 的值为 `Selendroid`。
|
||||
* 4.2 以及更高的版本是通过 Appium 自己的 [UiAutomator](http://developer.android.com/tools/testing-support-library/index.html#UIAutomator) 库实现。这是默认的自动化后台。
|
||||
* 设备:Android 模拟器以及 Android 真机
|
||||
* 是否支持 Native 应用:支持
|
||||
* 是否支持移动端浏览器:支持(除了使用 Selendroid 后台的时候)。Appium 绑定了一个 [Chromedriver](http://chromedriver.chromium.org) 服务,使用这个代理服务进行自动化测试。在 4.2 和 4.3 版本,只能在官方的 Chrome 浏览器或者 Chromium 执行自动化测试。在 4.4 及更高版本,可以在内置的 “浏览器” 应用上进行自动化了。更多介绍请查看 [mobile web doc](/docs/en/writing-running-appium/web/mobile-web.md)(English)。
|
||||
* 是否支持 Hybrid 应用:支持。更多介绍请查阅 [hybrid doc](/docs/cn/writing-running-appium/web/hybrid.md)。
|
||||
* 是否支持移动端浏览器:支持(除了使用 Selendroid 后台的时候)。Appium 绑定了一个 [Chromedriver](https://code.google.com/p/selenium/wiki/ChromeDriver) 服务,使用这个代理服务进行自动化测试。在 4.2 和 4.3 版本,只能在官方的 Chrome 浏览器或者 Chromium 执行自动化测试。在 4.4 及更高版本,可以在内置的 “浏览器” 应用上进行自动化了。更多介绍请查看 [mobile web doc](/docs/cn/writing-running-appium/mobile-web.md)。
|
||||
* 是否支持 Hybrid 应用:支持。更多介绍请查阅 [hybrid doc](/docs/cn/advanced-concepts/hybrid.md)。
|
||||
* 默认的 Appium 自动化后台:支持 4.4 以及更高版本
|
||||
* Selendroid 自动化后台:支持 2.3 以及更高版本
|
||||
* 是否支持多个 app 在同一个 session 中自动化:支持(除了使用 Selendroid 后台的时候)
|
||||
@@ -33,7 +36,10 @@ Appium 支持多种平台以及各种测试方式(native,hybrid,web,真
|
||||
|
||||
### Windows 桌面支持
|
||||
|
||||
* [Windows App Testing](/docs/en/drivers/windows.md)(English)
|
||||
查看以下文档获取更多信息:
|
||||
|
||||
* [Running on Windows](running-on-windows.md)
|
||||
* [Windows App Testing](/docs/cn/writing-running-appium/windows-app-testing.md)
|
||||
|
||||
|
||||
本文由 thanksdanny 翻译,由 lihuazhang 校验。
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -0,0 +1,7 @@
|
||||
### 在 Android 真机上运行 Appium
|
||||
|
||||
谢天谢地!在 Android 真机上运行是没有额外需要注意的地方:在模拟器上能运行的测试同样适用在真机上。确保你的设备可以连接 ADB 和开启开发者模式。在真机上测试 Chrome,你只需负责确认 Chrome 已安装上一个合适的版本。
|
||||
|
||||
同样,你需要在手机上关闭“验证应用”,否则他会阻止 Appium 的辅助应用启动和正常运行。
|
||||
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
|
Before Width: | Height: | Size: 832 KiB After Width: | Height: | Size: 832 KiB |
|
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 765 KiB After Width: | Height: | Size: 765 KiB |
|
Before Width: | Height: | Size: 928 KiB After Width: | Height: | Size: 928 KiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 650 KiB After Width: | Height: | Size: 650 KiB |
|
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 150 KiB |
|
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 147 KiB |
|
Before Width: | Height: | Size: 849 KiB After Width: | Height: | Size: 849 KiB |
@@ -0,0 +1,207 @@
|
||||
## 在 iOS 真机上运行 Appium
|
||||
|
||||
Appium 已支持真机的测试。
|
||||
|
||||
### 使用 Appium 运行你的测试
|
||||
|
||||
把设备的 udid 传给 `udid` 这个 capability。把应用的 bundle ID 传给 `app` 这个 capability,如果你的应用已经在手机上安装好了。如果应用未安装,那么需要将 `.ipa` 或者 `.app` 文件的路径传给 `app` 这个 capability。一旦你的设备和应用已经配置好,你就可以在那个设备上运行测试了。
|
||||
|
||||
### Desired Capabilities
|
||||
|
||||
通过在测试里使用以下的 capability,你可以在某个设备加载这个应用:
|
||||
|
||||
* `app` 或者 `bundleId` - 指定应用,或者如果应用已经安装到手机上了,只需简单地指定应用的 bundleID。这样 Appium 就可以加载该应用了。
|
||||
* `udid` - 被测设备的 id。如果只有一台设备连接的时候,可以设置为 `auto`,Appium 能自动识别设备 id 并使用它。
|
||||
|
||||
更多的细节参考 [Appium server capabilities](/docs/cn/writing-running-appium/caps.md)
|
||||
|
||||
### 必备的软件
|
||||
|
||||
Appium iOS 真机支持依赖一个重要的第三方软件套件 [libimobiledevice](http://www.libimobiledevice.org/),使用 [Homebrew](http://brew.sh/) 可以轻易地安装好。
|
||||
```
|
||||
brew install libimobiledevice
|
||||
```
|
||||
|
||||
## 在 Xcode 7 和 iOS 9.3 或者以下,配置 iOS 真机设备测试
|
||||
|
||||
在 iOS 9.3 或者以下,使用 Xcode 7.3 或者以下对真机进行自动化 (比如,基于 Instruments 的测试) 需要相对较少的配置。主要就是需要你的应用是使用开发者证书签名的。 不幸的是,苹果移除了所有使用老版本 Xcode 的文档,不过你可以从[这里](https://medium.com/ios-os-x-development/ios-code-signing-provisioning-in-a-nutshell-d5b247760bef#.5hirl92tn),[这里](https://engineering.nodesagency.com/articles/iOS/Understanding-code-signing-for-iOS-apps/)找到如何操作。
|
||||
|
||||
更详细地说, 在真机上开始测试, 你需要如下步骤:
|
||||
|
||||
* 一个 [Apple Developer ID](https://developer.apple.com/programs/ios/) 和一个有效的配置好开发者证书和 provisioning profile 的开发者账号。
|
||||
* 要在真机上测试,一个有效的 iOS 开发证书和 Provisioning Profile 是必须的。被测应用也必须被签名。更多信息可以在 [Apple documentation](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html) 找到。
|
||||
* 一个苹果设备: iPad 或者 iPhone 都可以。确保已经在 Xcode 里已经配置好了开发机。
|
||||
* 一个已经签名的 `.app` 或则 `.ipa` 文件,或者使用源码编一个。
|
||||
* 一台 Mac 电脑,装好了 [Xcode](https://developer.apple.com/xcode/) 和 Xcode Command
|
||||
Line Developer Tools。
|
||||
|
||||
Appium 使用 `ideviceinstaller` (`libimobiledevice` 套件的一部分)来处理应用安装问题。但是有时候使用 Xcode 提前安装好应用确保没有问题更加容易。(更多参考 [iOS deploy](ios-deploy.md))。
|
||||
|
||||
### 排障思路
|
||||
|
||||
0. 确保 UDID 是无误的,可以通过 Xcode Organizer 或者 iTunew 查看。留意 UDID 是很长的字符串(20+ 字符)。
|
||||
0. 确保你可以在模拟器运行你的测试。
|
||||
0. 重复确认通过 Instrumens 是否可以启动你的自动化。
|
||||
0. 确保 Instruments 不在运行状态中。
|
||||
0. 确保 UI Automation 在你的设备已经打开。设置 -> 开发者 -> 使用 UI Automation。
|
||||
|
||||
## 在 Xcode 8 和 iOS 9.3 以上配置 iOS 真机设备测试
|
||||
|
||||
作为对 `libimobiledevice` 依赖的补充,Appium 对 iOS 9.3 及以上和 Xcode 8 及以上的支持依赖 `ios-deploy`,
|
||||
通过 [npm](https://www.npmjs.com/package/ios-deploy) 可以方便地安装:
|
||||
```
|
||||
npm install -g ios-deploy
|
||||
```
|
||||
|
||||
不幸地是,苹果改变了以往的测试方法。新的方法需要安装一个帮助应用到设备上去,通过这个应用,自动化测试才能进行。说起来挺简单,但是代码签名和生成供开发和测试的应用,让人有一点头疼。
|
||||
|
||||
Appium 安装的应用叫 `WebDriverAgent-Runner` (可以在[这里](https://github.com/facebook/WebDriverAgent/))找到,要想安装这个应用,Appium需要能配置这个构建。
|
||||
|
||||
### 基本 (自动化) 配置
|
||||
|
||||
在 iOS 真机上设置和运行 Appium XCUItest,最方便的方法是使用自动化配置策略。有两种方式:
|
||||
|
||||
* 使用 `xcodeOrgId` 和 `xcodeSigningId` desired capabilities:
|
||||
```json
|
||||
{
|
||||
"xcodeOrgId": "<Team ID>",
|
||||
"xcodeSigningId": "iPhone Developer"
|
||||
}
|
||||
```
|
||||
* 在你的文件系统里创建一个 `.xcconfig` 文件,内容是:
|
||||
```
|
||||
DEVELOPMENT_TEAM = <Team ID>
|
||||
CODE_SIGN_IDENTITY = iPhone Developer
|
||||
```
|
||||
以上任何一个方式,Team ID 是一个 10 个字符长的字符串,苹果生成这个字符串,分配给你的团队。你可以在你的开发者账号里找到你的 Team ID。登录 [developer.apple.com/account](http://developer.apple.com/account),然后点击边栏上的 Membership。你的 Team ID 在 Membership
|
||||
Information 部分的团队名字下面。你也可以在 keychain 里的 iPhone 开发者证书里的 "Organizational Unit" 属性找到你的 Team ID。
|
||||
|
||||
注意这是互斥的策略;要么用 `xcodeConfigFile` capability, 要么用 `xcodeOrgId` and `xcodeSigningId` 的组合。
|
||||
|
||||
当以上的配置搞定后,只需再指定 `udid` capability 就可以在真机上开始测试了。
|
||||
|
||||
如果还是不工作的话,通常会在 Appium server 的日志里显示一些错误如:`info XCUITest xcodebuild exited with code '65' and signal 'null'`。这通常表示必要的代码签名没配置正确。 去看下 [Basic (manual) configuration](https://github.com/imurchie/appium-xcuitest-driver/blob/isaac-rs/docs/real-device-config.md#basic-manual-configuration)
|
||||
这个文档,参试修复下。
|
||||
|
||||
如果 `WebDriverAgentRunner` 成功的在设备上安装好,但是在 Appium server 日志里还是有如下错误信息:
|
||||
```
|
||||
2017-01-24 09:02:18.358 xcodebuild[30385:339674] Error Domain=com.apple.platform.iphoneos Code=-12 "Unable to launch com.apple.test.WebDriverAgentRunner-Runner" UserInfo={NSLocalizedDescription=Unable to launch com.apple.test.WebDriverAgentRunner-Runner, NSUnderlyingError=0x7fa839cadc60 {Error Domain=DTXMessage Code=1 "(null)" UserInfo={DTXExceptionKey=The operation couldn’t be completed. Unable to launch com.apple.test.WebDriverAgentRunner-Runner because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user. : Failed to launch process with bundle identifier 'com.apple.test.WebDriverAgentRunner-Runner'}}}
|
||||
2017-01-24 09:02:18.358 xcodebuild[30385:339674] Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}
|
||||
|
||||
Testing failed:
|
||||
Test target WebDriverAgentRunner encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted)
|
||||
```
|
||||
这个问题是因为开发者在这台设备上不被信任。如果你在设备上手动运行 `WebDriverAgentRunner`,你会看到一个错误页面弹出来:
|
||||
|
||||

|
||||
|
||||
你可以去设备中的 Settings => General => Device Management 信任这个开发者,允许 `WebDriverAgentRunner` 运行 (参考 [Apple
|
||||
documentation for more information](https://support.apple.com/en-us/HT204460)).
|
||||
|
||||
|
||||
### 基本 (手动) 配置
|
||||
|
||||
很多情况,基本的自动配置满足不了需求。这通常和真机运行上的代码签名和项目配置有关。这常常发生在免费的开发者账号上,免费的开发者账号不能创建 wildcard provisioning profile,也不能为应用创建默认的配置文件。
|
||||
|
||||
Xcode **创建 provisioning profile 失败** 的错误如下:
|
||||
|
||||

|
||||
|
||||
最容易的解决方案就是打开 [Xcode](https://developer.apple.com/xcode/)创建一个新工程:
|
||||
|
||||

|
||||
|
||||
类型不重要,只要是 "iOS"。用最简单的 "Single View Application" 即可:
|
||||
|
||||

|
||||
|
||||
重要的地方是要用唯一的 "Product Name" 和 "Organization Name". 然后,在这里,指定你的 "Team"。
|
||||
|
||||

|
||||
|
||||
你可以在 "Project" tab 确认 provisioning profile 是否创建成功。
|
||||
|
||||

|
||||
|
||||
或者去你的账号首选项里看看 provisioning profile:
|
||||
|
||||

|
||||
|
||||
现在你就有了一个有效的 provisioning profile。 记住你关联这个 profile 的 bundle id,然后放到 `updatedWDABundleId` 这个 desired capability 里。然后跟着[前面的自动配置教程](#basic-automatic-configuration)操作即可。
|
||||
|
||||
|
||||
### 全部手动配置
|
||||
|
||||
另外,可以手动把 provisioning profile 和项目关联在一起。 (记住如果使用这个方法,每次 WebDriverAgent 更新,都要做一次。所以我们不推荐这个方法):
|
||||
|
||||
* 找到你的 Appium 的安装目录
|
||||
```
|
||||
$ which appium
|
||||
/path/where/installed/bin/appium
|
||||
```
|
||||
* 假设安装目录是: `/path/where/installed/bin/appium`,那么 `WebDriverAgent`
|
||||
在 `/path/where/installed/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent`。
|
||||
打开终端到那个目录,然后按以下命令操作:
|
||||
```
|
||||
mkdir -p Resources/WebDriverAgent.bundle
|
||||
./Scripts/bootstrap.sh -d
|
||||
```
|
||||
* 在 Xcode 里打开 `WebDriverAgent.xcodeproj`。 对于 `WebDriverAgentLib`
|
||||
和 `WebDriverAgentRunner` 两个 target,都选择 "General" tab 里的 "Automatically manage signing"
|
||||
然后选择你的 `Development Team`。这也会自动选择 `Signing Ceritificate`。大概的样子如下:
|
||||
|
||||

|
||||
|
||||
* Xcode 可能会创建不了 `WebDriverAgentRunner` 的 provisioning profile:
|
||||
|
||||

|
||||
|
||||
* 这时候需要在 "Build Settings" tab 里手动改 bundle id。把 "Product Bundle Identifier"
|
||||
从 `com.facebook.WebDriverAgentRunner` 改成 Xcode 能采用的:
|
||||
|
||||

|
||||
|
||||
* 在回到 "General" tab 里的 `WebDriverAgentRunner` target,现在你可以看到一个 provisioning profile 创建成果了:
|
||||
|
||||

|
||||
|
||||
* 最后,你可以验证一切都 OK 了。 构建这个项目:
|
||||
```
|
||||
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test
|
||||
```
|
||||
如果成果了,最后的输出会像下面这样:
|
||||
```
|
||||
Test Suite 'All tests' started at 2017-01-23 15:49:12.585
|
||||
Test Suite 'WebDriverAgentRunner.xctest' started at 2017-01-23 15:49:12.586
|
||||
Test Suite 'UITestingUITests' started at 2017-01-23 15:49:12.587
|
||||
Test Case '-[UITestingUITests testRunner]' started.
|
||||
t = 0.00s Start Test at 2017-01-23 15:49:12.588
|
||||
t = 0.00s Set Up
|
||||
```
|
||||
* 要完整验证的话,你可以试试看访问 WebDriverAgent server 的状态 (**注意:** 你必须和手机设备同一个网段,你可以从 Settings => Wi-Fi => Current Network 找到手机当前的 IP。):
|
||||
```
|
||||
export DEVICE_URL='http://<device IP>:8100'
|
||||
export JSON_HEADER='-H "Content-Type: application/json;charset=UTF-8, accept: application/json"'
|
||||
curl -X GET $JSON_HEADER $DEVICE_URL/status
|
||||
```
|
||||
你会得到如下输出:
|
||||
```
|
||||
{
|
||||
"value" : {
|
||||
"state" : "success",
|
||||
"os" : {
|
||||
"name" : "iOS",
|
||||
"version" : "10.2"
|
||||
},
|
||||
"ios" : {
|
||||
"simulatorVersion" : "10.2",
|
||||
"ip" : "192.168.0.7"
|
||||
},
|
||||
"build" : {
|
||||
"time" : "Jan 23 2017 14:59:57"
|
||||
}
|
||||
},
|
||||
"sessionId" : "8951A6DD-F3AD-410E-A5DB-D042F42F68A7",
|
||||
"status" : 0
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,6 @@
|
||||
## Appium 上对真机测试的支持
|
||||
|
||||
Appium 已支持真机的测试。
|
||||
|
||||
* **Android** 测试, 参考 [android real device documentation](real-devices-android.md)
|
||||
* **iOS** 测试, 参考 [iOS real device documentation](real-devices-ios.md)
|
||||
@@ -0,0 +1,11 @@
|
||||
## 在 Linux 上运行 Appium
|
||||
|
||||
### 局限性
|
||||
|
||||
如果你要在 Linux 上运行 Appium,是不能使用 '.app' 的预构建包的,因为它只能在 OS X 上进行构建。其次,iOS 的应用测试也是无法进行,因为 Appium 也是依赖在 OS X 上特有的库才能支持 iOS 的测试。
|
||||
|
||||
### 配置(Android)
|
||||
|
||||
Android 上的一些设置,与在 linux 上运行测试的方式,都是跟 Mac OS X 上的操作方式是相同的。 请查阅 [Android 设置文档](/docs/cn/appium-setup/android-setup.md).
|
||||
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -0,0 +1,150 @@
|
||||
## 在 Mac OS Xcode 上运行 Appium
|
||||
|
||||
在 OS X 上,Appium 支持 iOS 与 Android 测试。
|
||||
|
||||
### 系统配置(iOS)
|
||||
|
||||
* Appium 要求 Mac OS X 10.10 或更高的系统版本。
|
||||
* 确保你已经安装 Xcode 与 iOS 的 SDK。推荐使用 Xcode 7.1版本,因为早期版本的 Xcode 的版本对于可测试的 iOS 版本是受限的。查看下面的章节了解更多信息。
|
||||
* 你需要给 iOS 模拟器授权使用。请查看[下面章节](#authorizing-ios-on-the-computer)。
|
||||
* 如果你使用 Xcode 7.x 及以上版本,Instruments Without Delay(IWD) 已经失效了。你通过[这个方法](/docs/cn/advanced-concepts/iwd_xcode7.md)去使用 IWD (它会使你的测试速度显著提升)。
|
||||
* 如果你使用 Xcode 6,使用 Appium 前你得提前启动模拟器。假如你想发送文本信息,你得改变他的默认设置,去开启虚拟键盘。开启键盘后,你就可以通过点击输入框,或使用快捷键(comand + K)去调出键盘。
|
||||
* 如果你使用 Xcode 6,Xcode 上有个模块叫 Devices(快捷键:comand-shift-2)。使用 Appium 的时候,你只需要在 capabilities 中的 devicesName 参数填上你的设备名字,每一个 sdk 版本都会对应一个设备。换句话说,如果你在 capabilities 里设置了 devicesName 为 "iPhone 5s" 以及 platformVersion 为 "8.0",你就得保证在设备列表里,这是唯一一个使用 8.0 sdk 且名为"iPhone 5s"的设备。否则,Appium 就不会知道你想用的哪台设备。
|
||||
* 在 iOS 8,可以在`设置`里开启或者关闭 UIAutomation。该设置就在手机的设置里一个叫"Developer"页面。在使用模拟器或者真机去做自动化前,你需要去该页面确保 UIautomation 开关已经开启。
|
||||
|
||||
### 授权 iOS 设备给你的电脑
|
||||
|
||||
你要运行 `authorize-ios` 工具进行授权,可以通过 `npm` 去安装该工具,运行以下命令进行安装
|
||||
|
||||
```
|
||||
npm install -g authorize-ios
|
||||
```
|
||||
|
||||
然后运行以下命令去调起该工具
|
||||
|
||||
```
|
||||
sudo authorize-ios
|
||||
```
|
||||
|
||||
如果你是使用 [Appium.app](https://github.com/appium/appium-dot-app),你可以在 GUI 界面进行授权。
|
||||
|
||||
每次更新 Xcode 版本的时候,你都需要重复以上步骤哦!
|
||||
|
||||
### 使用多种 iOS SDK 测试
|
||||
|
||||
Xcode 7.1 版本允许使用 iOS 7.1 以及更高级的系统版本去做自动化测试。
|
||||
|
||||
如果你使用多个 Xcode 版本,你使用以下命令去切换版本:
|
||||
|
||||
sudo xcode-select --switch <path to required xcode>
|
||||
|
||||
### 在 Xcode 8(包括 iOS 10)下使用 XCUITest 进行测试
|
||||
|
||||
为了在 Xcode 8(其中包括所有 iOS 10+ 的测试)使用 iOS 真机做自动化,你要安装 [Carthage](https://github.com/Carthage/Carthage) 去做依赖管理:
|
||||
```
|
||||
brew install carthage
|
||||
```
|
||||
|
||||
### 测试 Mac 应用
|
||||
|
||||
目前为止,Mac 对应的 appium driver 在 AppiumForMac 的二进制文件还没发布,也就是说如果你想进行 Mac 应用的自动化,你就得手动去安装 AppiumForMac 应用,并且对 OS X 授予可访问权限。
|
||||
|
||||
|
||||
如何安装 Appium for Mac:
|
||||
1. [下载该发布版本](https://github.com/appium/appium-for-mac/releases/tag/0.2.0),将他解压缩到 `/Applications` 文件夹中
|
||||
2. 查看 [简要补充安装说明](https://github.com/appium/appium-for-mac#installation),确保 appium 放访问到 OS X 的 Accessibility APIs
|
||||
|
||||
更多相关如何使用 Appium for mac 的相关信息,请查阅该[文档](https://github.com/appium/appium-for-mac#appium-for-mac)。
|
||||
|
||||
|
||||
### 系统配置(Android)
|
||||
|
||||
Android 的设置操作指南与在 Mac OS X 上的设置,大致与 Linux 上的设置相似,可以参考 [Android 设置文档](/docs/en/appium-setup/android-setup.md)。
|
||||
|
||||
### 使用 Jenkins 在 OS X 上运行 iOS 测试
|
||||
|
||||
第一步就是下载 jenkins-cli.jar,以及验证你的 Mac 是否成功的连接上 Jenkins 主机。确保已经运行了 `authorize-ios` 等相关的命令。
|
||||
|
||||
`wget https://jenkins.ci.cloudbees.com/jnlpJars/jenkins-cli.jar`
|
||||
|
||||
```
|
||||
java -jar jenkins-cli.jar \
|
||||
-s https://team-appium.ci.cloudbees.com \
|
||||
-i ~/.ssh/id_rsa \
|
||||
on-premise-executor \
|
||||
-fsroot ~/jenkins \
|
||||
-labels osx \
|
||||
-name mac_appium
|
||||
```
|
||||
|
||||
接下来为了在登录的时候可以自动启动,定义一个 Jenkins 的 LaunchAgent。LaunchDaemon 将会停止工作,因为 deamons 没有获取 GUI 的访问权限。确保 plist 文件不会包含`SessionCreate` 或 `User` 这两个键值,就防止测试在运行时启动。如果漏了配置,你会看到该报错: `Failed to authorize rights`。
|
||||
|
||||
|
||||
```
|
||||
$ sudo nano /Library/LaunchAgents/com.jenkins.ci.plist
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.jenkins.ci</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>java</string>
|
||||
<string>-Djava.awt.headless=true</string>
|
||||
<string>-jar</string>
|
||||
<string>/Users/appium/jenkins/jenkins-cli.jar</string>
|
||||
<string>-s</string>
|
||||
<string>https://instructure.ci.cloudbees.com</string>
|
||||
<string>on-premise-executor</string>
|
||||
<string>-fsroot</string>
|
||||
<string>/Users/appium/jenkins</string>
|
||||
<string>-executors</string>
|
||||
<string>1</string>
|
||||
<string>-labels</string>
|
||||
<string>mac</string>
|
||||
<string>-name</string>
|
||||
<string>mac_appium</string>
|
||||
<string>-persistent</string>
|
||||
</array>
|
||||
<key>KeepAlive</key>
|
||||
<true/>
|
||||
<key>StandardOutPath</key>
|
||||
<string>/Users/appium/jenkins/stdout.log</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/Users/appium/jenkins/error.log</string>
|
||||
</dict>
|
||||
</plist>
|
||||
```
|
||||
|
||||
最后设置 owner,权限,再开启代理。
|
||||
|
||||
```
|
||||
sudo chown root:wheel /Library/LaunchAgents/com.jenkins.ci.plist
|
||||
sudo chmod 644 /Library/LaunchAgents/com.jenkins.ci.plist
|
||||
|
||||
launchctl load /Library/LaunchAgents/com.jenkins.ci.plist
|
||||
launchctl start com.jenkins.ci
|
||||
```
|
||||
|
||||
### 运行 iOS 测试时生成的文件
|
||||
|
||||
测试 iOS 的过程中生成的文件有时可能会过大。这些文件包含日志,临时文件,还有 Xcode 运行时产生的数据。一般来说,下面的这些地址都是这些文件保存的地方,可以删除他们节省空间:
|
||||
|
||||
```
|
||||
$HOME/Library/Logs/CoreSimulator/*
|
||||
```
|
||||
|
||||
基于 Instruments 的测试 (iOS 不是使用 `XCUITest` 作为 `automationName`):
|
||||
|
||||
```
|
||||
/Library/Caches/com.apple.dt.instruments/*
|
||||
```
|
||||
|
||||
基于 XCUITest 的测试:
|
||||
|
||||
```
|
||||
$HOME/Library/Developer/Xcode/DerivedData/*
|
||||
```
|
||||
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -0,0 +1,43 @@
|
||||
#Windows 设置
|
||||
|
||||
在 Windows 上,Appium 支持 Windows 与 Android 应用的自动化测试!
|
||||
|
||||
获取更多信息请查阅 [Windows 应用测试](/docs/cn/writing-running-appium/windows-app-testing.md)。
|
||||
|
||||
## 在 Windows 上运行 Appium
|
||||
|
||||
## 配置
|
||||
|
||||
开始安装:
|
||||
|
||||
1. 下载最新版本的 [node 与 npm 工具](https://nodejs.org/download/release/v6.3.0/node-v6.3.0-x64.msi) 的 MSI (版本 >= 6.0) `npm` 和 `nodejs` 两个命令应该在你的 PATH 系统变量里。
|
||||
2. 打开你的 cmd 终端
|
||||
3. 运行 `npm install -g appium` 这条命令后,就会通过 NPM 去安装 Appium。
|
||||
4. 在命令行简单地输入 `appium` 就可以快速开启 Appium。
|
||||
5. 按照下面的只是去设置 Android 或者 Windows 应用的测试。
|
||||
6. 使用任意 Appium 客户端去运行一个测试。
|
||||
|
||||
## Android 应用测试的一些额外配置
|
||||
|
||||
1. 下载最新版的 Java JDK[这里](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)(记得先接受协议的许可)。设置 'JAVA_HOME' 为你的 JDK 路径。目录下的 `bin` 文件夹应该添加到你的 PATH 变量中。
|
||||
2. 安装 [Android SDK](http://developer.android.com/sdk/index.html)。将环境变量`ANDROID_HOME`设置为你的 Android SDK 路径,并且将 `tools` 和 `platform-tools` 这两个文件夹添加到你的 PATH 变量中去。
|
||||
3. 安装 [Apache Ant](http://ant.apache.org/bindownload.cgi) 或使用 eclipse 插件目录中的 Android Windows SDK。确保添加的文件夹包含 Ant 在你的 PATH 变量中。
|
||||
4. 安装 [Apache Maven](http://maven.apache.org/download.cgi) ,并设置 M2HOME 与 M2 的环境变量。设置 `M2_HOME` 为 maven 所在的安装路径,设置 `M2` 为 `bin` 目录的路径。将 `M2` 路径添加到你的 PATH 变量中。
|
||||
5. 在 Windows 上运行测试,你需要启动 Android 的虚拟机或者一台已经连接电脑的 Android 真机,并且 AVD 要求 API Level 17 或更高版本,才能在命令行中运行 Appium(通过 `appium` 命令)
|
||||
6. 你的测试脚本应该确保 `platformVersion` 参数是与你的模拟器或者模拟器的版本是一一对应的,以及`app`参数是你的需要测试的应用的绝对路径。
|
||||
|
||||
## Windows 应用测试的额外配置
|
||||
|
||||
1. 测试 Windows 应用,最基本的要求就是要打开 [开发者模式](https://msdn.microsoft.com/en-us/windows/uwp/get-started/enable-your-device-for-development)。
|
||||
|
||||
(查看[Windows app testing](/docs/cn/writing-running-appium/windows-app-testing.md),了解更多测试 Windows 应用测试的说明)
|
||||
|
||||
## 运行 Appium
|
||||
|
||||
查看 [server documentation](/docs/cn/writing-running-appium/server-args.md) 可以查看所有的命令参数。
|
||||
|
||||
* 在 Windows 上运行 Appium.exe 需要管理员权限,或者当你以源码方式运行,你要在 cmd 运行时有管理员权限。
|
||||
* 在 Windows 上运行 Andoid 测试时,务必记得添加上`--no-reset` 或 `--full-reset` 参数。
|
||||
* Android 有硬件加速仿真器;但他也是有限制的,更多信息请查阅该[文章](/docs/cn/appium-setup/android-hax-emulator.md).
|
||||
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -0,0 +1,150 @@
|
||||
## Appium 的故障排查
|
||||
|
||||
当你在使用过程中遇到了问题,先别急着到 github 上提交反馈,或者到 [appium-discuss discussion group](https://discuss.appium.io) 提问。可以先试试在本文中能否找到解决的办法。
|
||||
|
||||
### 常见问题
|
||||
|
||||
* 确保你是跟着 [README](/README.md) 中的每一步来做。
|
||||
* 确保你的系统已经配置好所需环境(例如. Xcode 已更至最新,Android SDK 已经安装好,而且`ANDROID_HOME`也设置无误)。
|
||||
* 确保你应用的存放路径是正确的。
|
||||
* 在 windows 上运行 appium.app 要使用管理员权限,假如你在 cmd 中运行,也得确保是在管理员权限下。
|
||||
|
||||
### 如果你是通过 Appium.app 运行
|
||||
|
||||
* 升级应用并重启。如果你被告知应用无法升级,请到 [appium.io](http://appium.io) 重新下载。
|
||||
|
||||
### 如果你是通过 Appium 的源码运行
|
||||
|
||||
* 通过 `git pull` 命令拉取代码,确保当前的代码是最新的
|
||||
* 移除旧的依赖:`rm -rf node_modules`
|
||||
* 重新安装依赖:`npm install`
|
||||
* 代码 Re-transpile: `gulp transpile`
|
||||
|
||||
* 你可以使用 [Appium Doctor](https://github.com/appium/appium-doctor) 去检测 Appium 环境是否已经配置好了。
|
||||
* 如果你升级到 Android SDK 22 后出现如下报错:
|
||||
`{ANDROID_HOME}/tools/ant/uibuild.xml:155: SDK does not have any Build Tools installed.`
|
||||
在 Android SDK 22 中,platform 与 build tools 分别被拆分到各自的 SDK 管理包中去了。你需要确保已经正确安装了 build-tools 与 platform-tools。
|
||||
|
||||
### Android
|
||||
|
||||
* 确保 Android 模拟器已经开启并在运行中。
|
||||
* 出现设备连接问题时, `adb kill-server && adb devices` 这行命令非常有用。它可以重置你的 Android 设备的连接。
|
||||
* 确保你已经设置了 ANDROID_HOME 已经指向了 Android SDK 路径
|
||||
|
||||
|
||||
### Windows
|
||||
|
||||
* 确保已经开启了开发者模式。
|
||||
* 确保 command prompt 已经是管理员权限。
|
||||
* 检查 Appium 服务器正在监听的 URL 是否与你测试脚本中的 URL 匹配的上。
|
||||
|
||||
### IOS
|
||||
|
||||
* 确保 Instruments.app 没有被开启。
|
||||
* 如果你使用模拟器时,记得不要让真机连上你的电脑。
|
||||
* 确保在手机的设置中的 accessibility 辅助功能是关闭的。
|
||||
* 确保应用是变异在当前运行的模拟器上。
|
||||
* 确保应用已编译在合适的模拟器(或真机)上(例如. 在模拟器上运行需要 debug 模式的包),否则你会出现`posix spawn`报错。
|
||||
* 如果你曾经用 sudo 运行过 Appium,你可能需要运行 `sudo rm /tmp/instruments_sock` 该命令,而且记住以后尽量别带上 sudo。
|
||||
* 如果你是第一次运行 Appium,记得对 Instruments 进行授权。 查阅 [running on OSX documentation](./running-on-osx.md#authorizing-ios-on-the-computer) 了解更多。
|
||||
* 如果在真机上运行 Instruments 出现了崩溃("exited with code 253"),确保 Xcode 已经下载了设备的符号文件。到 Window -> Devices,然后他就会自动的开始下载。每次 iOS 版本升级后都需要做这步。
|
||||
* 如果你看到 `iOS Simulator failed to install the application.` 这样的报错,并且确定路径没有设置错误的话,那你可以尝试去重启你的电脑。
|
||||
* 确保你的 macOS 上的 keychain 已经保存了用于构建你的应用的证书,并且 WebDeriverAgent 是已签名的。特别是你在使用 ssh 的情况下。通常失败的话会显示`签名`报错。
|
||||
* 如果你的应用中还有自定义的元素,他们或许不能通过默认的方式去使用 UIAutomaion(and therefore Appuim)进行自动化。你需要将 accessibility status 设置为'enabled'。在代码中设置的方式如下:
|
||||
|
||||
```center
|
||||
[myCustomView setAccessibilityEnabled:YES];
|
||||
```
|
||||
|
||||
* 在 iOS 上测试可能会出现类似内存泄露(包括性能不佳、程序挂起)的状况。如果你出现了类似的问题,这很可能是由于一个 NSLog 的已知问题所导致的。其中的一个解决办法就是将所有的 NSLog 代码移除。然而,还是有一些巧妙的处理方法,可以不重构就能解决。
|
||||
|
||||
### 解决办法 1
|
||||
NSLog 是一个宏且可以被定义的。例如:
|
||||
```objectivec
|
||||
// *You'll need to define TEST or TEST2 and then recompile.*
|
||||
|
||||
#ifdef TEST
|
||||
#define NSLog(...) _BlackHoleTestLogger(__VA_ARGS__);
|
||||
#endif // TEST
|
||||
#ifdef TEST2
|
||||
#define NSLog(...) _StdoutTestLogger(__VA_ARGS__);
|
||||
#endif // TEST2
|
||||
|
||||
void _BlackHoleTestLogger(NSString *format, ...) {
|
||||
//
|
||||
}
|
||||
|
||||
void _StdoutTestLogger(NSString *format, ...) {
|
||||
va_list argumentList;
|
||||
va_start(argumentList, format);
|
||||
NSMutableString * message = [[NSMutableString alloc] initWithFormat:format
|
||||
arguments:argumentList];
|
||||
|
||||
printf(message);
|
||||
|
||||
va_end(argumentList);
|
||||
[message release];
|
||||
}
|
||||
```
|
||||
|
||||
### 解决办法 2
|
||||
手动去替换掉 NSLog 封装的底层功能。该方法被 [Apple in a similar context.](https://support.apple.com/kb/TA45403?locale=en_US&viewlocale=en_US) 所推荐
|
||||
```objectivec
|
||||
extern void _NSSetLogCStringFunction(void(*)(const char *, unsigned, BOOL));
|
||||
|
||||
static void _GarbageFreeLogCString(const char *message, unsigned length, BOOL withSyslogBanner) {
|
||||
fprintf(stderr, "%s\\n", message);
|
||||
}
|
||||
|
||||
int main (int argc, const char *argv[]) {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
int exitCode;
|
||||
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
_NSSetLogCStringFunction(_GarbageFreeLogCString);
|
||||
exitCode = WOApplicationMain(@"Application", argc, argv);
|
||||
[pool release];
|
||||
return exitCode;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Webview/Hybrid/Safari 应用的支持
|
||||
|
||||
* 确保真机上的 'Web Inspector' 为打开状态。
|
||||
* 确保你已经打开 Safari 的开发者模式(Safari - Advance Preferences- Developer menu for simulators)。
|
||||
* 确保你客户端的库提供的 appium 命令 `context` 可以让你正确地切换 contexts。
|
||||
* 当你尝试打开代理的时候,出现了这个报错:select_port() failed,请查阅该[文档](https://groups.google.com/forum/#!topic/appium-discuss/tw2GaSN8WX0)。
|
||||
* 在 Safari session 中,如果日志记录到不能输入初始 url 的问题,先确保你的软键盘是否已被开启,详情请查阅该[文档](https://github.com/appium/appium/issues/6440)。
|
||||
|
||||
### 到社区寻求帮助
|
||||
|
||||
如果上述步骤还没解决你的问题,那你可以通过以下方式获得帮助:
|
||||
|
||||
当你在使用 Appium 的过程中有任何问题,而且 Appium 提供的报错信息不够清晰的话,欢迎加入[讨论组](https://discuss.appium.io)与大家进行讨论。提问时请附带上如下信息:
|
||||
|
||||
* 你是通过什么方式运行 Appium(Appium.app, npm, source)。
|
||||
* 你使用什么操作系统。
|
||||
* 你是针对什么设备和版本去做测试的(例如. Android 4.4, 或者 iOS 7.1)。
|
||||
* 你是使用真机还是模拟器去做测试。
|
||||
* 提供客户端和服务端给出的的错误(例如. “在运行我的 Python 测试脚本时候出现了异常,Appium 服务器的报错信息如链接中所示”)。
|
||||
* 除了上述,在提问的时候希望可以附带上 Appium 服务器输出的内容(特别是在 verbose 模式下),这样我们就可以更好地分析并跟进问题。
|
||||
|
||||
如果你确信你发现的是一个 bug,请直接到 [issue tracker](https://github.com/appium/appium/issues) 去提交一个 issue 去描述 bug 的信息以及重现步骤。
|
||||
|
||||
### 已知问题
|
||||
|
||||
* 如果你已在官网下载并安装 Node,你需要使用 sudo 去运行 `npm`。可这么做这并不理想。可以尝试通过 [nvm](https://github.com/creationix/nvm), [n](https://github.com/visionmedia/n) 或者 `brew install node` 这几种方式去安装!
|
||||
* 通过设置代理,iOS 真机可以支持 Webview 了,详情可查看[讨论](https://groups.google.com/d/msg/appium-discuss/u1ropm4OEbY/uJ3y422a5_kJ)。
|
||||
* 有时候 iOS 的 UI 元素在被定位到后的几毫秒间会失效,这会导致一个类似 `(null) cannot be tapped` 的报错。唯一的解决办法就是把 finding-and-clicking 的代码放进一个 retry block 中。
|
||||
* 如果你是通过 MacPorts 去安装 Node 与 npm,Appium 可能很难找到可执行的 `node`。你必须确保 MacoPorts 的 bin 文件夹(默认是 `/opt/local/bin`)已经添加到你的 `~/.profile`, `~/.bash_profile` 或者 `~/.bashrc` 中的 `PATH` 环境变量中。
|
||||
|
||||
### 特定的错误
|
||||
|
||||
|Action|Error|Resolution|
|
||||
|------|-----|----------|
|
||||
|Running ios test|`[INST STDERR] posix spawn failure; aborting launch`|你的应用没有分别对应模拟器或者真机去编译对应版本.|
|
||||
|Running mobile safari test|`error: Could not prepare mobile safari with version '7.1'`|你可能需要再次运行授权的脚本以确保 iOS SDK 文件是可写状态。详情请查阅 [running on OSX documentation](./running-on-osx.md#authorizing-ios-on-the-computer)|
|
||||
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -1,26 +0,0 @@
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file.)
|
||||
|
||||
## Appim API 文档
|
||||
|
||||
### /docs/en/commands/device/app
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file.)
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file.)
|
||||
<div class="api-index">
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file.)
|
||||
<ul>
|
||||
<li><a href='/docs/en/commands/device/app/install-app.md'>应用安装</a></li>
|
||||
<li><a href='/docs/en/commands/device/app/is-app-installed.md'>Is App Installed</a></li>
|
||||
<li><a href='/docs/en/commands/device/app/launch-app.md'>Launch App</a></li>
|
||||
<li><a href='/docs/en/commands/device/app/background-app.md'>Background App</a></li>
|
||||
<li><a href='/docs/en/commands/device/app/close-app.md'>Close App</a></li>
|
||||
<li><a href='/docs/en/commands/device/app/reset-app.md'>Reset App</a></li>
|
||||
<li><a href='/docs/en/commands/device/app/remove-app.md'>Remove App</a></li>
|
||||
<li><a href='/docs/en/commands/device/app/activate-app.md'>Activate App</a></li>
|
||||
<li><a href='/docs/en/commands/device/app/terminate-app.md'>Terminate App</a></li>
|
||||
<li><a href='/docs/en/commands/device/app/app-state.md'>Get App State</a></li>
|
||||
<li><a href='/docs/en/commands/device/app/get-app-strings.md'>Get App Strings</a></li>
|
||||
<li><a href='/docs/en/commands/device/app/end-test-coverage.md'>End Test Coverage</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file.)
|
||||
@@ -1,126 +0,0 @@
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
# 应用激活
|
||||
|
||||
在设备上激活指定的 app
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
## 示范用法
|
||||
|
||||
```java
|
||||
// Java
|
||||
driver.activateApp('com.apple.Preferences');
|
||||
driver.activateApp('io.appium.android.apis');
|
||||
|
||||
```
|
||||
|
||||
```python
|
||||
# Python
|
||||
driver.activate_app('com.apple.Preferences')
|
||||
driver.activate_app('io.appium.android.apis')
|
||||
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Javascript
|
||||
// webdriver.io 例子
|
||||
driver.activateApp(null, 'com.apple.Preferences')
|
||||
driver.activateApp('io.appium.android.apis')
|
||||
|
||||
// wd 例子
|
||||
// iOS 端仅在使用 XCUITEST 框架前提下支持 `mobile: queryAppState` 命令
|
||||
|
||||
```
|
||||
|
||||
```ruby
|
||||
# Ruby
|
||||
# ruby_lib 例子
|
||||
activate_app('com.apple.Preferences')
|
||||
activate_app('io.appium.android.apis')
|
||||
|
||||
# ruby_lib_core 例子
|
||||
@driver.activate_app('com.apple.Preferences')
|
||||
@driver.activate_app('io.appium.android.apis')
|
||||
|
||||
```
|
||||
|
||||
```php
|
||||
# PHP
|
||||
// iOS 端仅在使用 XCUITEST 框架前提下支持 `mobile: queryAppState` 命令
|
||||
```
|
||||
|
||||
```csharp
|
||||
// C#
|
||||
driver.activateApp('com.apple.Preferences');
|
||||
driver.activateApp('io.appium.android.apis');
|
||||
|
||||
```
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
## 说明
|
||||
|
||||
通过 XCUITest 框架,iOS 端测试同样可以使用 `mobile: activateApp` 方法。详情请查看[文档](http://appium.io/docs/cn/writing-running-appium/ios/ios-xctest-mobile-apps-management/index.html#mobile-activateapp)。
|
||||
[//]: # (译者备注:这里要替换为iOS实际的链接**)
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
## 帮助文档
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
### Appium Server
|
||||
|
||||
|平台|Driver|平台版本|Appium 版本|Driver 版本|
|
||||
|--------|----------------|------|--------------|--------------|
|
||||
| iOS | [XCUITest](/docs/cn/drivers/ios-xcuitest.md) | 9.3+ | 1.6.0+ | All |
|
||||
| | [UIAutomation](/docs/cn/drivers/ios-uiautomation.md) | None | None | None |
|
||||
| Android | [Espresso](/docs/cn/drivers/android-espresso.md) | ?+ | 1.9.0+ | All |
|
||||
| | [UiAutomator2](/docs/cn/drivers/android-uiautomator2.md) | ?+ | 1.6.0+ | All |
|
||||
| | [UiAutomator](/docs/cn/drivers/android-uiautomator.md) | 4.3+ | All | All |
|
||||
| Mac | [Mac](/docs/cn/drivers/mac.md) | None | None | None |
|
||||
| Windows | [Windows](/docs/cn/drivers/windows.md) | None | None | None |
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
### Appium 客户端
|
||||
|
||||
|语言|是否支持|文档|
|
||||
|--------|-------|-------------|
|
||||
|[Java](https://github.com/appium/java-client/releases/latest)| All | [appium.github.io](https://appium.github.io/java-client/io/appium/java_client/InteractsWithApps.html#activateApp-java.lang.String-) |
|
||||
|[Python](https://github.com/appium/python-client/releases/latest)| All | [appium.github.io](https://appium.github.io/python-client-sphinx/webdriver.extensions.html#webdriver.extensions.applications.Applications.activate_app) |
|
||||
|[Javascript (WebdriverIO)](http://webdriver.io/index.html)| All | |
|
||||
|[Javascript (WD)](https://github.com/admc/wd/releases/latest)| All | [github.com](https://github.com/admc/wd/blob/master/lib/commands.js) |
|
||||
|[Ruby](https://github.com/appium/ruby_lib/releases/latest)| All | [www.rubydoc.info](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Device#activate_app-instance_method) |
|
||||
|[PHP](https://github.com/appium/php-client/releases/latest)| All | [github.com](https://github.com/appium/php-client/) |
|
||||
|[C#](https://github.com/appium/appium-dotnet-driver/releases/latest)| All | [github.com](https://github.com/appium/appium-dotnet-driver/) |
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
## HTTP API 规范
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
### Endpoint
|
||||
|
||||
`POST /session/:session_id/appium/device/activate_app`
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
### URL 参数
|
||||
|
||||
|字段名| 说明 |
|
||||
|----|-----------|
|
||||
|session_id|通过命令去路由的session id|
|
||||
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
### JSON 参数
|
||||
|
||||
|字段名|类型|说明|
|
||||
|----|----|-----------|
|
||||
| bundleId 或 appId | `string` | iOS 端使用 BundleId, Andorid 端使用包名(package name)。 |
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
### 响应(Response)
|
||||
|
||||
无
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/activate-app.yml)
|
||||
## 另请参阅
|
||||
|
||||
* [JSONWP 说明书](https://github.com/appium/appium-base-driver/blob/master/lib/protocol/routes.js#L445)
|
||||
@@ -1,126 +0,0 @@
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
# 获取 app 的当前状态
|
||||
|
||||
在设备中获取 app 当前的状态
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
## 使用范例
|
||||
|
||||
```java
|
||||
// Java
|
||||
driver.queryAppState('com.apple.Preferences');
|
||||
driver.queryAppState('io.appium.android.apis');
|
||||
|
||||
```
|
||||
|
||||
```python
|
||||
# Python
|
||||
driver.query_app_state('com.apple.Preferences')
|
||||
driver.query_app_state('io.appium.android.apis')
|
||||
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Javascript
|
||||
// webdriver.io 例子
|
||||
driver.queryAppState(null, 'com.apple.Preferences')
|
||||
driver.queryAppState('io.appium.android.apis')
|
||||
|
||||
// wd 例子
|
||||
// iOS 端仅在使用 XCUITEST 框架前提下支持 `mobile: queryAppState` 命令
|
||||
|
||||
```
|
||||
|
||||
```ruby
|
||||
# Ruby
|
||||
# ruby_lib 例子
|
||||
app_state('com.apple.Preferences')
|
||||
query_app_state('io.appium.android.apis') # `query_` 前缀同样可用
|
||||
|
||||
# ruby_lib_core 例子
|
||||
@driver.app_state('com.apple.Preferences')
|
||||
@driver.query_app_state('io.appium.android.apis') # `query_` 前缀同样可用
|
||||
|
||||
```
|
||||
|
||||
```php
|
||||
# PHP
|
||||
// iOS 端仅在使用 XCUITEST 框架前提下支持 `mobile: queryAppState` 命令
|
||||
|
||||
```
|
||||
|
||||
```csharp
|
||||
// C#
|
||||
// iOS 端仅在使用 XCUITEST 框架前提下支持 `mobile: queryAppState` 命令
|
||||
|
||||
```
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
## 说明
|
||||
|
||||
iOS tests with XCUITest can also use the `mobile: queryAppState` method. See detailed [documentation](http://appium.io/docs/cn/writing-running-appium/ios/ios-xctest-mobile-apps-management/index.html#mobile-queryappstate).
|
||||
|
||||
通过 XCUITest 框架,iOS 端测试同样可以使用 `mobile: queryAppState` 方法。详情请查看[文档](http://appium.io/docs/writing-running-appium/ios/ios-xctest-mobile-apps-management/index.html#mobile-queryappstate)。
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
## 帮助文档
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
### Appium Server
|
||||
|
||||
|平台|Driver|平台版本|Appium 版本|Driver 版本|
|
||||
|--------|----------------|------|--------------|--------------|
|
||||
| iOS | [XCUITest](/docs/drivers/ios-xcuitest.md) | 9.3+ | 1.6.0+ | All |
|
||||
| | [UIAutomation](/docs/drivers/ios-uiautomation.md) | None | None | None |
|
||||
| Android | [Espresso](/docs/drivers/android-espresso.md) | ?+ | 1.9.0+ | All |
|
||||
| | [UiAutomator2](/docs/drivers/android-uiautomator2.md) | ?+ | 1.6.0+ | All |
|
||||
| | [UiAutomator](/docs/drivers/android-uiautomator.md) | 4.3+ | All | All |
|
||||
| Mac | [Mac](/docs/drivers/mac.md) | None | None | None |
|
||||
| Windows | [Windows](/docs/drivers/windows.md) | None | None | None |
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
### Appium 客户端
|
||||
|
||||
|语言|是否支持|文档|
|
||||
|--------|-------|-------------|
|
||||
|[Java](https://github.com/appium/java-client/releases/latest)| All | [appium.github.io](https://appium.github.io/java-client/io/appium/java_client/InteractsWithApps.html#queryAppState-java.lang.String-) |
|
||||
|[Python](https://github.com/appium/python-client/releases/latest)| All | [appium.github.io](https://appium.github.io/python-client-sphinx/webdriver.extensions.html#webdriver.extensions.applications.Applications.query_app_state) |
|
||||
|[Javascript (WebdriverIO)](http://webdriver.io/index.html)| All | |
|
||||
|[Javascript (WD)](https://github.com/admc/wd/releases/latest)| All | [github.com](https://github.com/admc/wd/blob/master/lib/commands.js) |
|
||||
|[Ruby](https://github.com/appium/ruby_lib/releases/latest)| All | [www.rubydoc.info](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Base/Driver#app_state-instance_method) |
|
||||
|[PHP](https://github.com/appium/php-client/releases/latest)| All | [github.com](https://github.com/appium/php-client/) |
|
||||
|[C#](https://github.com/appium/appium-dotnet-driver/releases/latest)| All | [github.com](https://github.com/appium/appium-dotnet-driver/) |
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
## HTTP API 规范
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
### Endpoint
|
||||
|
||||
`GET /session/:session_id/appium/device/app_state`
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
### URL 参数
|
||||
|
||||
|字段名| 说明 |
|
||||
|----|-----------|
|
||||
|session_id|通过命令去路由的session id|
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
### JSON 参数
|
||||
|
||||
|字段名|类型|说明|
|
||||
|----|----|-----------|
|
||||
| bundleId 或 appId | `string` | iOS 端使用 BundleId, Andorid 端使用包名(package name)。 |
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
### 响应(Response)
|
||||
|
||||
当前 app 的状态(通过客户端去封装响应结果)如下所示:`0` 为应用未安装,`1` 为应用未运行,`2` 为应用在后台运行或被挂起,`3` 为应用在后台运行,`4` 为应用正在前台运行。(`number` 类型)
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/app-state.yml)
|
||||
## 另请参阅
|
||||
|
||||
* [JSONWP 说明书](https://github.com/appium/appium-base-driver/blob/master/lib/protocol/routes.js#L480)
|
||||
@@ -1,126 +0,0 @@
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
# 后台应用
|
||||
|
||||
将当前正在运行应用的 session 发送给后台
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
## 使用范例
|
||||
|
||||
```java
|
||||
// Java
|
||||
driver.runAppInBackground(Duration.ofSeconds(10));
|
||||
|
||||
```
|
||||
|
||||
```python
|
||||
# Python
|
||||
self.driver.background_app(10)
|
||||
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Javascript
|
||||
// webdriver.io 例子
|
||||
driver.background(10);
|
||||
|
||||
// wd 例子
|
||||
await driver.backgroundApp(10);
|
||||
|
||||
```
|
||||
|
||||
```ruby
|
||||
# Ruby
|
||||
# ruby_lib 例子
|
||||
background_app(10)
|
||||
|
||||
# ruby_lib_core 例子
|
||||
@driver.background_app(10)
|
||||
|
||||
```
|
||||
|
||||
```php
|
||||
# PHP
|
||||
$driver->backgroundApp(10);
|
||||
|
||||
```
|
||||
|
||||
```csharp
|
||||
// C#
|
||||
driver.BackgroundApp(10)
|
||||
|
||||
```
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
## 说明
|
||||
|
||||
当需要将当前被激活的 app 退出到后台,或使 app 在后台停留一定的时长,又或者需要让 app 完全停止运行的时候,以下有三种类型的参数可以传递给这个方法:
|
||||
|
||||
1. 使用类似一个 `{"timeout": secs}` 的对象,`secs` 表示在后台运行多少秒,`secs` 的类型为整型(integer)。若 `secs` 为 -1,则说明 app 已经完全停止运行。
|
||||
2. `null` 代表完全停止 app 运行。
|
||||
3. 直接传一个整型(integer):代表在后端停留多少秒,但不建议传此参数。若为 -1,则说明 app 已经完全停止运行。
|
||||
|
||||
|
||||
|
||||
iOS 端通过 XCUITest 框架也能使用 `mobile: terminateApp` 方法去停止当前 app(详情参考[文档](/docs/cn/writing-running-appium/ios/ios-xctest-mobile-apps-management.md#mobile-terminateapp)),`mobile: activateApp` 可激活被测设备上现有的 app,并将其恢复到前台运行(详情参考[文档](/docs/cn/writing-running-appium/ios/ios-xctest-mobile-apps-management.md#mobile-activateapp))。
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
## 帮助文档
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
### Appium Server
|
||||
|
||||
|平台|Driver|平台版本|Appium 版本|Driver 版本|
|
||||
|--------|----------------|------|--------------|--------------|
|
||||
| iOS | [XCUITest](/docs/cn/drivers/ios-xcuitest.md) | 9.3+ | 1.6.0+ | All |
|
||||
| | [UIAutomation](/docs/cn/drivers/ios-uiautomation.md) | 8.0 to 9.3 | All | All |
|
||||
| Android | [Espresso](/docs/cn/drivers/android-espresso.md) | ?+ | 1.9.0+ | All |
|
||||
| | [UiAutomator2](/docs/cn/drivers/android-uiautomator2.md) | ?+ | 1.6.0+ | All |
|
||||
| | [UiAutomator](/docs/cn/drivers/android-uiautomator.md) | 4.3+ | All | All |
|
||||
| Mac | [Mac](/docs/cn/drivers/mac.md) | None | None | None |
|
||||
| Windows | [Windows](/docs/cn/drivers/windows.md) | None | None | None |
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
### Appium 客户端
|
||||
|
||||
|语言|是否支持|文档|
|
||||
|--------|-------|-------------|
|
||||
|[Java](https://github.com/appium/java-client/releases/latest)| All | [appium.github.io](https://appium.github.io/java-client/io/appium/java_client/InteractsWithApps.html#runAppInBackground-java.time.Duration-) |
|
||||
|[Python](https://github.com/appium/python-client/releases/latest)| All | [appium.github.io](https://appium.github.io/python-client-sphinx/webdriver.extensions.html#webdriver.extensions.applications.Applications.background_app) |
|
||||
|[Javascript (WebdriverIO)](http://webdriver.io/index.html)| All | |
|
||||
|[Javascript (WD)](https://github.com/admc/wd/releases/latest)| All | [github.com](https://github.com/admc/wd/blob/master/lib/commands.js#L2841) |
|
||||
|[Ruby](https://github.com/appium/ruby_lib/releases/latest)| All | [www.rubydoc.info](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Device#background_app-instance_method) |
|
||||
|[PHP](https://github.com/appium/php-client/releases/latest)| All | [github.com](https://github.com/appium/php-client/) |
|
||||
|[C#](https://github.com/appium/appium-dotnet-driver/releases/latest)| All | [github.com](https://github.com/appium/appium-dotnet-driver/) |
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
## HTTP API 规范
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
### Endpoint
|
||||
|
||||
`POST /session/:session_id/appium/app/background`
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
### URL 参数
|
||||
|
||||
|字段名| 说明 |
|
||||
|----|-----------|
|
||||
|session_id|通过命令去路由的session id|
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
### JSON 参数
|
||||
|
||||
|字段名|类型|说明|
|
||||
|----|----|-----------|
|
||||
| 秒数 | `number` | app 在后台运行时长 |
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
### 响应(Response)
|
||||
|
||||
无
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/background-app.yml)
|
||||
## 另请参阅
|
||||
|
||||
* [JSONWP 说明书](https://github.com/appium/appium-base-driver/blob/master/lib/protocol/routes.js#L556)
|
||||
@@ -1,111 +0,0 @@
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/close-app.yml)
|
||||
# 终止 App 运行
|
||||
|
||||
终止 app 在设备上运行
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/close-app.yml)
|
||||
## 示范用法
|
||||
|
||||
```java
|
||||
// Java
|
||||
driver.closeApp();
|
||||
|
||||
```
|
||||
|
||||
```python
|
||||
# Python
|
||||
self.driver.close_app()
|
||||
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Javascript
|
||||
// webdriver.io 例子
|
||||
driver.closeApp();
|
||||
|
||||
// wd 例子
|
||||
await driver.closeApp();
|
||||
|
||||
```
|
||||
|
||||
```ruby
|
||||
# Ruby
|
||||
# ruby_lib 例子
|
||||
close_app
|
||||
|
||||
# ruby_lib_core 例子
|
||||
@driver.close_app
|
||||
|
||||
```
|
||||
|
||||
```php
|
||||
# PHP
|
||||
$driver->closeApp();
|
||||
|
||||
```
|
||||
|
||||
```csharp
|
||||
// C#
|
||||
driver.CloseApp();
|
||||
|
||||
```
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/close-app.yml)
|
||||
## 帮助文档
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/close-app.yml)
|
||||
### Appium Server
|
||||
|
||||
|平台|Driver|平台版本|Appium 版本|Driver 版本|
|
||||
|--------|----------------|------|--------------|--------------|
|
||||
| iOS | [XCUITest](/docs/cn/drivers/ios-xcuitest.md) | 9.3+ | 1.6.0+ | All |
|
||||
| | [UIAutomation](/docs/cn/drivers/ios-uiautomation.md) | 8.0 to 9.3 | All | All |
|
||||
| Android | [Espresso](/docs/cn/drivers/android-espresso.md) | None | None | None |
|
||||
| | [UiAutomator2](/docs/cn/drivers/android-uiautomator2.md) | ?+ | 1.6.0+ | All |
|
||||
| | [UiAutomator](/docs/cn/drivers/android-uiautomator.md) | 4.3+ | All | All |
|
||||
| Mac | [Mac](/docs/cn/drivers/mac.md) | None | None | None |
|
||||
| Windows | [Windows](/docs/cn/drivers/windows.md) | None | None | None |
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/close-app.yml)
|
||||
### Appium 客户端
|
||||
|
||||
|语言|是否支持|文档|
|
||||
|--------|-------|-------------|
|
||||
|[Java](https://github.com/appium/java-client/releases/latest)| All | [appium.github.io](https://appium.github.io/java-client/io/appium/java_client/InteractsWithApps.html#closeApp--) |
|
||||
|[Python](https://github.com/appium/python-client/releases/latest)| All | [appium.github.io](https://appium.github.io/python-client-sphinx/webdriver.extensions.html#webdriver.extensions.applications.Applications.close_app) |
|
||||
|[Javascript (WebdriverIO)](http://webdriver.io/index.html)| All | |
|
||||
|[Javascript (WD)](https://github.com/admc/wd/releases/latest)| All | [github.com](https://github.com/admc/wd/blob/master/lib/commands.js#L2798) |
|
||||
|[Ruby](https://github.com/appium/ruby_lib/releases/latest)| All | [www.rubydoc.info](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Device#close_app-instance_method) |
|
||||
|[PHP](https://github.com/appium/php-client/releases/latest)| All | [github.com](https://github.com/appium/php-client/) |
|
||||
|[C#](https://github.com/appium/appium-dotnet-driver/releases/latest)| All | [github.com](https://github.com/appium/appium-dotnet-driver/blob/master/src/Appium.Net/Appium/AppiumDriver.cs) |
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/close-app.yml)
|
||||
## HTTP API 规范
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/close-app.yml)
|
||||
### Endpoint
|
||||
|
||||
`POST /session/:session_id/appium/app/close`
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/close-app.yml)
|
||||
### URL 参数
|
||||
|
||||
|字段名| 说明 |
|
||||
|----|-----------|
|
||||
|session_id|通过命令去路由的session id|
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/close-app.yml)
|
||||
### JSON 参数
|
||||
|
||||
无
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/close-app.yml)
|
||||
### 响应(Response)
|
||||
|
||||
无
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/close-app.yml)
|
||||
## 另请参阅
|
||||
|
||||
* [JSONWP 说明书](https://github.com/appium/appium-base-driver/blob/master/lib/protocol/routes.js#L550)
|
||||
@@ -1,114 +0,0 @@
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/end-test-coverage.yml)
|
||||
# 结束测试覆盖率
|
||||
|
||||
获取覆盖率测试数据
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/end-test-coverage.yml)
|
||||
## 使用范例
|
||||
|
||||
```java
|
||||
// Java
|
||||
driver.endTestCoverage("Intent", "/path");
|
||||
|
||||
```
|
||||
|
||||
```python
|
||||
# Python
|
||||
self.driver.end_test_coverage("Intent", "/path")
|
||||
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Javascript
|
||||
// webdriver.io 例子
|
||||
driver.endCoverage("Intent", "/path");
|
||||
|
||||
// wd 例子
|
||||
await driver.endTestCoverageForApp("Intent", "/path");
|
||||
|
||||
```
|
||||
|
||||
```ruby
|
||||
# Ruby
|
||||
# ruby_lib 例子
|
||||
end_coverage("Intent", "/path")
|
||||
|
||||
# ruby_lib_core 例子
|
||||
@driver.end_coverage("Intent", "/path")
|
||||
|
||||
```
|
||||
|
||||
```php
|
||||
# PHP
|
||||
$driver->endTestCoverage('Intent', '/path');
|
||||
|
||||
```
|
||||
|
||||
```csharp
|
||||
// C#
|
||||
driver.EndTestCoverage("Intent", "/path");
|
||||
|
||||
```
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/end-test-coverage.yml)
|
||||
## 帮助文档
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/end-test-coverage.yml)
|
||||
### Appium Server
|
||||
|
||||
|平台|Driver|平台版本|Appium 版本|Driver 版本|
|
||||
|--------|----------------|------|--------------|--------------|
|
||||
| iOS | [XCUITest](/docs/cn/drivers/ios-xcuitest.md) | None | None | None |
|
||||
| | [UIAutomation](/docs/cn/drivers/ios-uiautomation.md) | None | None | None |
|
||||
| Android | [Espresso](/docs/cn/drivers/android-espresso.md) | ?+ | 1.9.0+ | All |
|
||||
| | [UiAutomator2](/docs/cn/drivers/android-uiautomator2.md) | ?+ | 1.6.0+ | All |
|
||||
| | [UiAutomator](/docs/cn/drivers/android-uiautomator.md) | 4.3+ | All | All |
|
||||
| Mac | [Mac](/docs/cn/drivers/mac.md) | None | None | None |
|
||||
| Windows | [Windows](/docs/cn/drivers/windows.md) | None | None | None |
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/end-test-coverage.yml)
|
||||
### Appium 客户端
|
||||
|
||||
|语言|是否支持|文档|
|
||||
|--------|-------|-------------|
|
||||
|[Java](https://github.com/appium/java-client/releases/latest)| All | [appium.github.io](https://appium.github.io/java-client/io/appium/java_client/android/AndroidDriver.html#endTestCoverage-java.lang.String-java.lang.String-) |
|
||||
|[Python](https://github.com/appium/python-client/releases/latest)| All | [appium.github.io](https://appium.github.io/python-client-sphinx/webdriver.extensions.android.html#webdriver.extensions.android.common.Common.end_test_coverage) |
|
||||
|[Javascript (WebdriverIO)](http://webdriver.io/index.html)| All | |
|
||||
|[Javascript (WD)](https://github.com/admc/wd/releases/latest)| All | [github.com](https://github.com/admc/wd/blob/master/lib/commands.js#L2858) |
|
||||
|[Ruby](https://github.com/appium/ruby_lib/releases/latest)| None | [www.rubydoc.info](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Android/Device#end_coverage-instance_method) |
|
||||
|[PHP](https://github.com/appium/php-client/releases/latest)| All | [github.com](https://github.com/appium/php-client/) |
|
||||
|[C#](https://github.com/appium/appium-dotnet-driver/releases/latest)| All | [github.com](https://github.com/appium/appium-dotnet-driver/blob/master/src/Appium.Net/Appium/Android/AndroidDriver.cs) |
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/end-test-coverage.yml)
|
||||
## HTTP API 规范
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/end-test-coverage.yml)
|
||||
### Endpoint
|
||||
|
||||
`POST /session/:session_id/appium/app/end_test_coverage`
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/end-test-coverage.yml)
|
||||
### URL 参数
|
||||
|
||||
|字段名| 说明 |
|
||||
|----|-----------|
|
||||
|session_id|通过命令去路由的session id|
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/end-test-coverage.yml)
|
||||
### JSON 参数
|
||||
|
||||
|字段名|类型|说明|
|
||||
|----|----|-----------|
|
||||
| intent | `string` | Intent 的 broadcast |
|
||||
| path | `string` | .ec 文件的路径 |
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/end-test-coverage.yml)
|
||||
### 响应(Response)
|
||||
|
||||
无
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/end-test-coverage.yml)
|
||||
## 另请参阅
|
||||
|
||||
* [JSONWP 说明书](https://github.com/appium/appium-base-driver/blob/master/lib/protocol/routes.js#L559)
|
||||
@@ -1,114 +0,0 @@
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/get-app-strings.yml)
|
||||
# 获取 App 字符串
|
||||
|
||||
获取 App 字符串
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/get-app-strings.yml)
|
||||
## 使用范例
|
||||
|
||||
```java
|
||||
// Java
|
||||
Map<String, String> appStrings = driver.getAppStringMap("en", "/path/to/file");
|
||||
|
||||
```
|
||||
|
||||
```python
|
||||
# Python
|
||||
appStrings = self.driver.app_strings("en", "/path/to/file")
|
||||
|
||||
```
|
||||
|
||||
```javascript
|
||||
// Javascript
|
||||
// webdriver.io 例子
|
||||
let appStrings = driver.getStrings("en");
|
||||
|
||||
// wd 例子
|
||||
let appStrings = await driver.getAppStrings();
|
||||
|
||||
```
|
||||
|
||||
```ruby
|
||||
# Ruby
|
||||
# ruby_lib 例子
|
||||
app_strings("en")
|
||||
|
||||
# ruby_lib_core 例子
|
||||
@driver.app_strings("en")
|
||||
|
||||
```
|
||||
|
||||
```php
|
||||
# PHP
|
||||
$strings = $driver->appStrings();
|
||||
|
||||
```
|
||||
|
||||
```csharp
|
||||
// C#
|
||||
Dictionary<string, object> appStrings = driver.GetAppStringDictionary("end", "/path/to/file");
|
||||
|
||||
```
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/get-app-strings.yml)
|
||||
## 帮助文档
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/get-app-strings.yml)
|
||||
### Appium Server
|
||||
|
||||
|平台|Driver|平台版本|Appium 版本|Driver 版本|
|
||||
|--------|----------------|------|--------------|--------------|
|
||||
| iOS | [XCUITest](/docs/cn/drivers/ios-xcuitest.md) | 9.3+ | 1.6.0+ | All |
|
||||
| | [UIAutomation](/docs/cn/drivers/ios-uiautomation.md) | 8.0 to 9.3 | All | All |
|
||||
| Android | [Espresso](/docs/cn/drivers/android-espresso.md) | ?+ | 1.9.0+ | All |
|
||||
| | [UiAutomator2](/docs/cn/drivers/android-uiautomator2.md) | ?+ | 1.6.0+ | All |
|
||||
| | [UiAutomator](/docs/cn/drivers/android-uiautomator.md) | 4.3+ | All | All |
|
||||
| Mac | [Mac](/docs/cn/drivers/mac.md) | None | None | None |
|
||||
| Windows | [Windows](/docs/cn/drivers/windows.md) | None | None | None |
|
||||
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/get-app-strings.yml)
|
||||
### Appium 客户端
|
||||
|
||||
|语言|是否支持|文档|
|
||||
|--------|-------|-------------|
|
||||
|[Java](https://github.com/appium/java-client/releases/latest)| All | [appium.github.io](https://appium.github.io/java-client/io/appium/java_client/HasAppStrings.html#getAppStringMap--) |
|
||||
|[Python](https://github.com/appium/python-client/releases/latest)| All | [appium.github.io](https://appium.github.io/python-client-sphinx/webdriver.extensions.html#webdriver.extensions.applications.Applications.app_strings) |
|
||||
|[Javascript (WebdriverIO)](http://webdriver.io/index.html)| All | |
|
||||
|[Javascript (WD)](https://github.com/admc/wd/releases/latest)| All | [github.com](https://github.com/admc/wd/blob/master/lib/commands.js#L2916) |
|
||||
|[Ruby](https://github.com/appium/ruby_lib/releases/latest)| All | [www.rubydoc.info](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Device#app_strings-instance_method) |
|
||||
|[PHP](https://github.com/appium/php-client/releases/latest)| All | [github.com](https://github.com/appium/php-client/) |
|
||||
|[C#](https://github.com/appium/appium-dotnet-driver/releases/latest)| All | [github.com](https://github.com/appium/appium-dotnet-driver/blob/master/src/Appium.Net/Appium/AppiumDriver.cs) |
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/get-app-strings.yml)
|
||||
## HTTP API 规范
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/get-app-strings.yml)
|
||||
### Endpoint
|
||||
|
||||
`POST /session/:session_id/appium/app/strings`
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/get-app-strings.yml)
|
||||
### URL 参数
|
||||
|
||||
|字段名| 说明 |
|
||||
|----|-----------|
|
||||
|session_id|通过命令去路由的session id|
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/get-app-strings.yml)
|
||||
### JSON 参数
|
||||
|
||||
|字段名|类型|说明|
|
||||
|----|----|-----------|
|
||||
| language | `string` | 语言代码 (可选) |
|
||||
| stringFile | `string` | 字符文件串路径 (可选) |
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/get-app-strings.yml)
|
||||
### 响应(Response)
|
||||
|
||||
无
|
||||
|
||||
[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/device/app/get-app-strings.yml)
|
||||
## 另请参阅
|
||||
|
||||
* [JSONWP 说明书](https://github.com/appium/appium-base-driver/blob/master/lib/protocol/routes.js#L562)
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
你想从源码运行Appium并帮助修复BUG和添加功能吗?
|
||||
真棒!只需要fork工程,添加一个修改,然后发送pull请求即可!
|
||||
在开始之前请阅读我们的代码风格指南([Style Guide](style-guide.md)。
|
||||
在开始之前请阅读我们的代码风格指南([Style Guide](style-guide-2.0.md)。
|
||||
在发送pull请求前请确保通过单元和功能测试;关于如何运行测试等更多信息,请继续阅读!
|
||||
|
||||
首先,确保你阅读README文件且按照设置说明走。
|
||||
@@ -22,14 +22,18 @@ Appium 的配置涉及:
|
||||
git clone https://github.com/appium/appium.git
|
||||
cd appium
|
||||
npm install
|
||||
npm run build
|
||||
gulp transpile # requires gulp, see below
|
||||
npm install -g authorize-ios # for ios only
|
||||
authorize-ios # for ios only
|
||||
node .
|
||||
```
|
||||
```center
|
||||
git clone https://github.com/appium/appium.git
|
||||
cd appium
|
||||
npm install
|
||||
npm run build # 需要gulp,往下看
|
||||
gulp transpile # 需要gulp,往下看
|
||||
npm install -g authorize-ios # 仅iOS
|
||||
authorize-ios # 仅iOS
|
||||
node .
|
||||
```
|
||||
|
||||
@@ -45,6 +49,9 @@ to run `npm` with sudo privileges):
|
||||
确保已安装 `ant`、 `maven`、 `adb` 且已添加到 `PATH` 环境变量,还需要安装 android-16 的 sdk(Selendroid需要使用)和 android-19 的 sdk。在 Appium 本地仓库打开命令行,使用以下命令安装以下包(如果你没有使用Homebrew安装过 node,可能需要使用 sudo 运行 npm):
|
||||
|
||||
```center
|
||||
npm install -g mocha
|
||||
npm install -g gulp
|
||||
npm install -g gulp-cli
|
||||
npm install -g appium-doctor && appium-doctor --dev
|
||||
npm install
|
||||
gulp transpile
|
||||
@@ -61,7 +68,7 @@ is necessary to remove the old dependencies and re-run `npm install`:
|
||||
```center
|
||||
rm -rf node_modules
|
||||
npm install
|
||||
npm run build
|
||||
gulp transpile
|
||||
```
|
||||
|
||||
此时,您将可以启动 Appium Server:
|
||||
@@ -72,6 +79,32 @@ node .
|
||||
|
||||
完整的参数列表,请参考[the server documentation](/docs/cn/writing-running-appium/server-args.md)
|
||||
|
||||
|
||||
#### Hacking with Appium for iOS
|
||||
|
||||
#### 鼓捣 iOS 上的Appium
|
||||
|
||||
为了避免启动iOS应用程序时可能出现的安全对话框,您必须通过以下两种方式之一修改 `/etc/authorization` 文件:
|
||||
|
||||
1. 手动修改 `/etc/authorization` 文件中的 `<key>system.privilege.taskport</key>` 下的 `<allow-root>`的值为 `<true/>`。
|
||||
2. 运行以下命令,为您自动修改 `/etc/authorization` 文件:
|
||||
|
||||
```center
|
||||
npm install -g authorize-ios
|
||||
sudo authorize-ios
|
||||
```
|
||||
|
||||
|
||||
此时,运行:
|
||||
|
||||
```center
|
||||
rm -rf node-modules
|
||||
npm install
|
||||
gulp transpile
|
||||
```
|
||||
|
||||
现在你的 Appium 实例已经准备好了。运行 `node .` 以启动Appium服务器。
|
||||
|
||||
#### 鼓捣 Android 上的Appium
|
||||
|
||||
通过运行以下命令配置Appium:
|
||||
@@ -79,7 +112,7 @@ node .
|
||||
```center
|
||||
rm -rf node-modules
|
||||
npm install
|
||||
npm run build
|
||||
gulp transpile
|
||||
```
|
||||
|
||||
确保您只有一个 Android 模拟器或设备运行,例如,通过在另一个进程中运行此命令(假设 `emulator` 命令在您的路径上):
|
||||
@@ -97,7 +130,7 @@ emulator -avd <MyAvdName>
|
||||
```center
|
||||
rm -rf node-modules
|
||||
npm install
|
||||
npm run build
|
||||
gulp transpile
|
||||
```
|
||||
|
||||
### 运行测试
|
||||
@@ -108,15 +141,15 @@ general](/docs/cn/writing-running-appium/running-tests.md) 的文档,确保您
|
||||
一旦您的系统配置完毕,您的代码是最新的,您可以运行单元测试:
|
||||
|
||||
```center
|
||||
npm run test
|
||||
gulp once
|
||||
```
|
||||
|
||||
您可以对所有受支持的平台运行功能测试(确保在另一个窗口中运行Appium `node .`)与:
|
||||
|
||||
```center
|
||||
npm run e2e-test
|
||||
gulp e2e-test
|
||||
```
|
||||
|
||||
在提交代码之前,请运行 `npm run test` 一些基本测试,并根据代码质量标准检查您的更改。
|
||||
在提交代码之前,请运行 `gulp once` 一些基本测试,并根据代码质量标准检查您的更改。
|
||||
|
||||
本文由 校长 翻译,由 lihuazhang 校验。
|
||||
本文由 [校长](https://testerhome.com/xushizhao) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
- 为iOS/Android/Selendroid/Fake Driver 建立会话
|
||||
- 创建/删除Appium会话
|
||||
- 启动baseServer (appium-express)
|
||||
- 通过驱动给出的路径
|
||||
- 通过驱动给出的路径
|
||||
|
||||
## appium-express (部分appium basedriver)
|
||||
- 启动express server(允许x-domain-origin)
|
||||
@@ -93,7 +93,7 @@
|
||||
- 提供bootstrap simulator/realdevice (dynamic-bootstrap)的方法
|
||||
- 在iOS UI自动化上下文(非节点)中运行的JavaScript文件
|
||||
- 负责执行实际的iOS UI Automation命令
|
||||
- 参考 [UIAutomation docs](https://web.archive.org/web/20160904214108/https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/)
|
||||
- 参考 [UIAutomation docs](https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/)
|
||||
- 命令流程就像
|
||||
- Webdriver 命令-> iOS driver 命令 -> uiauto-命令
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
## appium-ios日志
|
||||
- 捕获iOS模拟器或实际设备的控制台,性能和崩溃日志
|
||||
- 通过调用tail来从系统路径获取日志(模拟器设备)
|
||||
- 或通过调用deviceconsole(实际设备)
|
||||
- 或通过调用deviceconsole(实际设备)
|
||||
- 使用远程调试器来抓取性能日志
|
||||
- 崩溃日志保留在系统上的“.crash”文件中
|
||||
|
||||
@@ -121,11 +121,17 @@
|
||||
- 使用simctl与模拟器通信
|
||||
- 适用于Xcode 6和7
|
||||
|
||||
## authorize-iOS
|
||||
- 程序预先授权Instruments针对iOS设备运行UIAutomation脚本
|
||||
- 通过调用“DevToolsSecurity -enable”来启用开发人员工具
|
||||
- 授权用户作为开发人员调用“authorizationdb”
|
||||
- 改变模拟器目录的所有权
|
||||
|
||||
## node-simctl
|
||||
- 封装simctl二进制(cli实用程序来控制iOS模拟器)
|
||||
- 作为xcrun的子命令执行(从命令行查找或调用开发人员工具)
|
||||
- 包含功能
|
||||
- 安装/删除应用程序
|
||||
- 安装/删除应用程序
|
||||
- 启动和关闭模拟器
|
||||
- 创建/清除/删除设备
|
||||
- 获取设备列表
|
||||
@@ -223,7 +229,7 @@
|
||||
- 具有定制插件的开发包使用交叉应用模块(仅适用于Appium开发)
|
||||
- 包含任务
|
||||
- e2e和单元测试(覆盖率报告)
|
||||
- 将ES2016 转换成 ES5
|
||||
- 将ES2016 转换成 ES5
|
||||
- 静态代码分析(jshint)
|
||||
- 开发人员的任务
|
||||
|
||||
@@ -253,4 +259,4 @@
|
||||
- 一堆fs方法
|
||||
- plist帮助解析和更新plist文件
|
||||
|
||||
本文由 校长 翻译,由 lihuazhang 校验。
|
||||
本文由 [校长](https://testerhome.com/xushizhao) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -1,24 +1,19 @@
|
||||
## 鸣谢
|
||||
|
||||
### 以下项目在Appium的开发过程中予我们以启示,或是让Appium变得更棒:
|
||||
### 以下是在Appium的开发过程中予我们以启示,或是为Appium锦上添花的项目
|
||||
|
||||
* [Apple UIAutomation](https://web.archive.org/web/20160904214108/https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/)
|
||||
* [Apple UIAutomation](https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/)
|
||||
* [GhostDriver](https://github.com/detro/ghostdriver)
|
||||
* [IOS Auto](https://github.com/penguinho/applecart)
|
||||
* [IOS Driver](https://github.com/ios-driver/ios-driver)
|
||||
* [Mechanic.js](https://github.com/jaykz52/mechanic)
|
||||
* [node-webkit](https://github.com/rogerwang/node-webkit)
|
||||
* [Remote Debug](https://github.com/leftlogic/remote-debug)
|
||||
* [Selenium Project](https://www.selenium.dev/)
|
||||
* [Selenium Project](http://code.google.com/p/selenium/)
|
||||
* [ios-webkit-debug-proxy](https://github.com/google/ios-webkit-debug-proxy)
|
||||
* [instruments-without-delay](https://github.com/facebook/instruments-without-delay)
|
||||
* [deviceconsole](https://github.com/rpetrich/deviceconsole)
|
||||
* [WinAppDriver](http://github.com/Microsoft/WinAppDriver)
|
||||
* [WebDriverAgent](https://github.com/facebook/webdriveragent)
|
||||
|
||||
--
|
||||
EOF.
|
||||
|
||||
本文由 [ZhaoC](https://github.com/ZhaoC) 翻译,由 [oscarxie](https://github.com/oscarxie) 校验。
|
||||
|
||||
Last english version: c986e4a62718b00976b26acb39e07e55f0c204d5, May 25, 2018
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## 一个开发人员对于Appium的概述
|
||||
|
||||
在阅读这个此文档之前,请确保你已经阅读并理解了关于[Appium的基本概念](/docs/cn/about-appium/intro.md),
|
||||
以及关于如何参与[Appium贡献说明](https://github.com/appium/appium/blob/master/CONTRIBUTING.md)
|
||||
以及关于如何参与[Appium贡献说明](/CONTRIBUTING.md)
|
||||
|
||||
### 技术愿景
|
||||
|
||||
@@ -36,6 +36,9 @@ Appium团队根据轻量化的scrum版本来运行开发。每两个星期我们
|
||||
|
||||
我们使用[Zoom](https://zoom.us)视讯来举行会议
|
||||
|
||||
关于项目管理,我们使用[ZenHub](http://zenhub.com) 浏览器插件,它向GitHub接口提供了例如
|
||||
Kanban boards 和 Epics 这些功能。要完全参与到Appium SCRUM,你需要安装上述的这些浏览器插件。
|
||||
|
||||
如果你有意参加sprint,你可以在Appium Slack群组里联系`@jlipps` 或者 `@isaac`,又或者直接在推特
|
||||
上联系`@jlipps`,我们将会在下一次sprint里分享如何加入视频聊天。
|
||||
|
||||
@@ -60,7 +63,7 @@ node.js的原生支持,Appium代码是_被移植_到ES5(JS更为广泛支持
|
||||
### 排查和代码风格
|
||||
|
||||
对于所有Appium的JS而言,代码外观和使用感觉同样重要。这包括样式常规,编码模式以及我们解决各种问题时使用的
|
||||
库。你应该熟悉我们新的[ES2015 风格指南](/docs/cn/contributing-to-appium/style-guide.md)。
|
||||
库。你应该熟悉我们新的[ES2015 风格指南](/docs/cn/contributing-to-appium/style-guide-2.0.md)。
|
||||
当转化时,Appium包将自动运行JSHint或其他lint工具,并在代码不符合我们规范的时候提供警告或错误反馈。
|
||||
这些工具不一定能顾全我们关心的种种风格问题,所以我们在review代码的时候也应该注意代码规范问题。这不是
|
||||
吹毛求疵,而是为了有一个整洁,一致并且可读的代码库。
|
||||
@@ -99,10 +102,10 @@ _FORCE_LOGS=1 <command> # 显示测试运行期间的模块日志输出
|
||||
任何非Appium主包的发布流程都是非常简洁明了的(请注意:如果你想要发布它,你需要成为一个NPM的所有者。
|
||||
所有权由Appium提交者管理; 如果你对所有者有任何疑问,请联系@jlipps 或者 @imurchie)。
|
||||
|
||||
0. `rm -rf node_modules && rm -rf package-lock.json && npm install` 并运行测试以确保全新安装正常工作
|
||||
0. `rm -rf node_modules && npm install` 并运行测试以确保全新安装正常工作
|
||||
0. 根据[SemVer](http://semver.org/) 规则决定我们是否需要发布一个补丁(漏洞修复),微调(功能)或者是主要(迭代)(请参考 [how SemVer works with NPM](https://docs.npmjs.com/getting-started/semantic-versioning).
|
||||
0. 通过任何适当的更改和提交来更新CHANGELOG以README文件。大多数子包没有CHANGELOG。
|
||||
0. 通过适当的版本类型运行 `npm version <version-type>`
|
||||
0. 通过适当的版本类型运行 `npm version <version-type>`
|
||||
0. 将适当的分支推送到GitHub, 不要忘记加入`--tags` 来标记刚由 `npm version`创建的标志.
|
||||
0. 运行 `npm publish` (如果不是正式版, 请使用`--tag beta`).
|
||||
|
||||
@@ -118,11 +121,11 @@ _FORCE_LOGS=1 <command> # 显示测试运行期间的模块日志输出
|
||||
因此有必要在发布过程中手动管理它。 它需要与对`package.json`的更改一起提交到GitHub。
|
||||
|
||||
0. 如果 NPM shrinkwrap JSON 文件存在,请移除.
|
||||
0. `rm -rf node_modules && rm -rf package-lock.json && npm install` 并运行测试以确保全新安装正常工作
|
||||
0. `rm -rf node_modules && rm -rf package-lock.json && npm install --production` 以获取仅production部分.
|
||||
0. `rm -rf node_modules && npm install` 并运行测试以确保全新安装正常工作
|
||||
0. `rm -rf node_modules && npm install --production` 以获取仅production部分.
|
||||
0. `npm shrinkwrap` 来编写新的 NPM shrinkwrap JSON 文件.
|
||||
0. 根据SemVer来决定我们是否需要发布一个补丁(漏洞修复),微调(功能)或者是主要(迭代)
|
||||
0. 用合适的新版本信息来更新`package.json`
|
||||
0. 用合适的新版本信息来更新`package.json`
|
||||
0. 对CHANGELOG/README进行合适的更改,同shrinkwrap 和 `package.json`的改变一起以PR的形式进行提交审核。待它被合并之后,把它`pull`进`release`分支。
|
||||
0. 在发布分支(通常是一个小分支,如`1.5`或`1.4`)上创建一个形式为`v <version>`的标签:`git tag -av <version>`,例如`git tag -a 1.5.0`。 这对测试版本不是必需的。
|
||||
0. 把标签推送到上游分支: `git push --tags <remote> <branch>`
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
## 如何编写文档
|
||||
|
||||
`##`用于写一个 h2 头。每个文档必须以 h2 开头。
|
||||
这是为了支持 appium.io 文档生成。不要使用`---`下划线方法创建标题。
|
||||
不要对标题使用 h1 `#` 或 `===`,因为目录表不支持这样(文件夹名称将用作 h1)。
|
||||
`##`用于写一个h2头。 每个文档必须以h2开头。这是为了支持appium.io文档生成。不要使用`---`下划线方法创建标题。
|
||||
不要对标题使用h1`#`或`===`,因为它不支持目录(文件夹名称用作h1)。
|
||||
|
||||
### 副标题
|
||||
|
||||
@@ -11,11 +10,11 @@
|
||||
### 常规标题
|
||||
|
||||
`####` 用于不出现在目录里的标题。
|
||||
不要使用 h5 `#####` 或是 h6 `######`。
|
||||
不要使用h5 `#####`或者h6`######`
|
||||
|
||||
### 换行符
|
||||
|
||||
不要使用 `--` 或者 `---`这样的换行符。
|
||||
不要使用 `--` 或者 `---`这样的换行符。 这样会混淆版面。
|
||||
|
||||
### 链接
|
||||
|
||||
@@ -23,33 +22,35 @@
|
||||
|
||||
`[readme](../../README.md)`
|
||||
|
||||
链接到捐赠:
|
||||
链接到贡献榜:
|
||||
|
||||
`[捐赠](../../CONTRIBUTING.md)`
|
||||
`[contributing](../../CONTRIBUTING.md)`
|
||||
|
||||
链接到另一个文件
|
||||
|
||||
`[链接文本](filename.md)`
|
||||
`[link text](filename.md)`
|
||||
|
||||
### 写指令(Commands)文档
|
||||
如果想链接文件内部,请使用`#` 作为版面URL
|
||||
|
||||
指令文档位于 `docs/en/commands`,是程序生成的文档,不需要直接编辑。该指令文档定义在`commands-yml/commands`。
|
||||
`[go direct to json](filename.md#json-wire-protocol-server-extensions)`
|
||||
|
||||
### 生成指令(Commands)文档
|
||||
运行 `npm run generate-docs` 生成指令文档。这将在 `docs/en/commands` 下生成 Markdown 文件,然后需要将生成的文件提交并推送。
|
||||
请注意,当标题改变时,哈希链接会被破坏掉。所以更好的选择是链接到文件的开头(用`other.md` 取代 `other.md#something`)
|
||||
|
||||
### 添加文档到 Appium.io
|
||||
`docs/` 目录下的 Markdown 文件不会自动添加到站点。为了添加文档到 [appium.io](https://appium.io),你需要在目录表([toc.js](https://github.com/appium/appium/blob/master/docs/toc.js))中的合适的位置添加一个入口。
|
||||
### 与appium.io的兼容性
|
||||
|
||||
### 在appium.io里中居对齐代码
|
||||
|
||||
Appium.io文档使用[slate](https://github.com/tripit/slate)获取文档。
|
||||
如果文档中的代码段不是特定的语言,或者你希望代码段保留在appium.io文档的居中部分,请使用`center`作为代码区的后缀。
|
||||
|
||||
例如:
|
||||
|
||||
```center
|
||||
代码段放置于此。
|
||||
```
|
||||
|
||||
#### 出版
|
||||
|
||||
要在 [appium.io](https://appium.io) 上发布文档,请参阅 [appium.io](https://github.com/appium/appium.io).
|
||||
|
||||
---
|
||||
EOF.
|
||||
要在appium.io上发布文档,请参阅[api-docs](https://github.com/appium/api-docs) 和 [appium.io](https://github.com/appium/appium.io).
|
||||
|
||||
本文由 [ZhaoC](https://github.com/ZhaoC) 翻译,由 [oscarxie](https://github.com/oscarxie) 校验。
|
||||
|
||||
翻译:@[Pandorym](https://github.com/Pandorym)
|
||||
Last english version: be2acb207c07503b9b1af3ba9315e7bee092a55a, Feb 12, 2018
|
||||
|
||||
@@ -42,7 +42,7 @@ Appium 使用 [Trunk Based Development](http://paulhammant.com/2013/04/05/what-i
|
||||
2. 在接下来的六个星期里,这个团队将他们的代码提交到 `master`.
|
||||
3. 7月15日,执行 RE 创建 20.1-branch。第一个节点被标记为 “20.1.0 Beta”。
|
||||
4. 一个团队成员开始修复测试版中的错误。这些修复会被提交到 `master`.
|
||||
5. 其他贡献者开始按计划提交代码到 `20.2` 中去。这些内容也会被提交到 `master`。
|
||||
5. 其他贡献者开始按计划提交代码到 `20.2` 中去。这些内容也会被提交到 `master`。
|
||||
6. RE把修复的内容cherry picks到 `20.1-branch`, 并保留 `master` 的其他变更。
|
||||
7. 该团队庆祝 8 月 1 日发布的所有测试版本都已修复。
|
||||
8. RE 标签的 HEAD 20.1-branch 为 20.1.0 发布版本。
|
||||
@@ -50,4 +50,6 @@ Appium 使用 [Trunk Based Development](http://paulhammant.com/2013/04/05/what-i
|
||||
10. 执行 RE 将主机的崩溃修复程序拉入 20.1-branch,将 HEAD 标记为 20.1.1 并发布修补程序。
|
||||
11. 一旦 20.2 发布完毕,循环就会重复。
|
||||
|
||||
本文由 大东 翻译,由 lihuazhang 校验。
|
||||
本文由 [大东](https://testerhome.com/Anikikun) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
|
||||
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
## Android 的 UiAutomator2 驱动
|
||||
|
||||
Appium 目前官方推荐使用 `UiAutomator2` 作为安卓app在自动化测试中的驱动。
|
||||
_(如果你是Appium新手? 可以参阅 [introduction to Appium drivers(TODO)](#TODO))_.
|
||||
这个驱动使用了谷歌的 [UiAutomator2](https://developer.android.com/training/testing/ui-automator.html) 技术,让自动化测试可以更方便地在安卓真机或者模拟器上运行。
|
||||
|
||||
UiAutomator2 驱动的开发过程,记录在了[appium-uiautomator2-driver](https://github.com/appium/appium-uiautomator2-driver) 代码仓库中。
|
||||
|
||||
在更早期的安卓设备驱动中,包括了以下驱动:
|
||||
* [UiAutomator 驱动](/docs/en/drivers/android-uiautomator.md)
|
||||
|
||||
|
||||
### 需求与依赖
|
||||
|
||||
在 Appium 常规依赖之外:
|
||||
|
||||
* 需要在您的设备上,安装并配置好 Java 8
|
||||
* 在 Mac,Windows 或者 Linux OS 设备上,需要安装好 Android SDK
|
||||
* Android SDK 中 Build Tools 的版本需要大于等于 24
|
||||
|
||||
此外,UiAutomator2 驱动是不支持对 Android 5.0 (Lollipop, API level 21)以下的设备进行自动化测试的,如果对这类版本的设备进行自动化测试,建议使用:[UiAutomator 驱动](/docs/en/drivers/android-uiautomator.md);
|
||||
|
||||
|
||||
### 使用方式
|
||||
|
||||
通过 UiAutomator2 驱动启动一个测试任务时,需要传递一个`automationName` [capability] 的参数在 [新会话的请求](#TODO) 中,并且 `automationName` 的值需要是:`UiAutomator2`。当然,你至少也需要再传递这些参数:`platformName` (=`Android`), `platformVersion`, `deviceName`, 与 `app`。
|
||||
|
||||
同时,强烈建议您传递:`appPackage` 与 `appActivity` 这两个参数,以便让 Appium 知道您想要拉起哪个 App 和哪个 activity。如果没有的话,Appium 将会自己从 App 的 manifest 文件中自动去查找。
|
||||
|
||||
|
||||
### 功能参数
|
||||
|
||||
UiAutomator2 驱动支持许多通用的功能参数:[Appium
|
||||
capabilities](/docs/en/writing-running-appium/caps.md),同时,有许多特有的功能参数,可以参考这篇文档查找这些功能参数:[Android
|
||||
section](/docs/en/writing-running-appium/caps.md#android-only)。
|
||||
|
||||
对于 web 测试,是测试 Chrome 而不是去测试您自己的应用程序,需要保证 `app` 参数为空,并且设置 `browserName` 为 `Chrome`。需要提醒您的是:您需要保证 Chrome 是在安卓模拟器/真机上运行,并且与 [version compatible with
|
||||
Chromedriver](/docs/en/writing-running-appium/web/chromedriver.md) 兼容。
|
||||
|
||||
|
||||
### 命令
|
||||
|
||||
如果需要查看 Appium 支持的命令,及它们是如何映射到 UiAutomator2 驱动的,可以参考:[API
|
||||
Reference](#TODO)。
|
||||
|
||||
|
||||
### 基础设置
|
||||
|
||||
1. 确保您拥有 Appium 的基础依赖(例如:Node 与 NPM)来安装和配置 Appium。
|
||||
|
||||
1. 确保 Java ( 这里指的是 JDK 而不是 JRE )已经成功安装并且在环境变量中配置好了 Java 的路径。这一步的具体操作,在 Mac/Linux 与 Windows 等不同平台上操作不同,这里为您提供一个在 Windows 平台上设置路径的方法:[点击查看](https://www.java.com/en/download/help/path.xml)。
|
||||
|
||||
1. 确保环境变量: `JAVA_HOME` 已经成功设置为 JDK 的路径。举一个 Mac/Linux 的例子(这个路径的具体地址,根据您安装的实际情况有所不同):
|
||||
```
|
||||
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home"
|
||||
```
|
||||
|
||||
在 Windows 电脑上,可以通过 「控制面板」来配置。
|
||||
[Android Studio](https://developer.android.com/studio/index.html) 同样提供了一个 JDK,像这样的一个路径: `/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home` (示例为Mac电脑版本)。您同样可以指定这个路径。
|
||||
|
||||
1. 安装 [Android SDK](http://developer.android.com/sdk/index.html)。当前最常用的方法是通过:[Android
|
||||
Studio](https://developer.android.com/studio/index.html) 来安装配置。可以在桌面应用程序中,通过GUI界面操作,选中一个路径来下载 Android SDK。
|
||||
|
||||
1. 设置 `ANDROID_HOME` 环境变量。举个例子,如果您下载 Android SDK 在 `/usr/local/adt` 这个路径下,您将在这个路径下,找到一个包含 SDK 文件的、名称为: `sdk` 的文件夹。在这种情况下,打开
|
||||
Mac 和 Linux 的配置文件(如:`~/.bashrc`, `~/.bash_profile` 及其他类型的文件),将这个环境变量与路径记录在其中。
|
||||
|
||||
```
|
||||
export ANDROID_HOME="/usr/local/adt/sdk"
|
||||
```
|
||||
|
||||
在 Windows 机器上,按照相同的步骤,将环境变量设置在「控制面板」中。
|
||||
|
||||
1. 通过 SDK manager,确保您安装了您所需要的、对应 Android API 版本的 SDK(例如:24)。
|
||||
|
||||
1. 在 Windows 电脑上,需确保您的 Appium 是通过管理员模式来运行的。
|
||||
|
||||
到此,您基础的系统配置已经完成了。接下来的步骤,需要看您是选择在模拟器运行测试还是在真机上运行测试。需要准备好待测 App (最好是Debug 版本)APK 的本地路径或下载链接,这个路径或链接,在运行测试时,需要设置为 `app` 参数的内容。
|
||||
|
||||
|
||||
### 模拟器设置
|
||||
|
||||
使用模拟器运行测试是,需要使用 Android Studio 或 SDK 提供的 AVD Manager。通过使用这个工具,来创建您所需要的模拟器。在模拟器启动时,Appium 将会自动找到并使用它进行测试。同时,如果您指定了 `avd` 这个功能参数为您所制定的设备名称时,Appium 会启动您指定的模拟器来运行测试。
|
||||
|
||||
关于模拟器的一些小提示:
|
||||
|
||||
* Android 模拟器可以设置硬件加速,尽管它有一些局限性。可以通过 Intel 网站下载,或者通过 Android SDK manager。了解更多信息,[可以点击这里查看](https://github.com/intel/haxm)。
|
||||
|
||||
* 如果您想在 Appium 测试中使用电源相关的命令,请确保在 AVD 的 `config.ini` 文件中,设置了:`hw.battery=yes` (在 Android 5.0 上,为默认设置)。
|
||||
|
||||
|
||||
### 真机设置
|
||||
|
||||
对于 Android 自动化测试,除了以下一些简单操作外,不需要其他复杂的设置:
|
||||
|
||||
* 确保打开了设备的 [开发者模式](https://developer.android.com/studio/debug/dev-options.html)。
|
||||
|
||||
* 确保设备通过 USB 连接到 Appium 服务启动的设备上,并且可以被 [ADB](https://developer.android.com/studio/command-line/adb.html) 找到
|
||||
( 执行 `adb devices` 确认 )。
|
||||
|
||||
* 确保设置中的“验证应用程序”是关闭的,以允许 Appium 安装一些辅助软件,而不用手动点击确认。
|
||||
|
||||
( 对于一些特殊的指令,设备可能需要被 root ,尽管这并不是经常会遇到的。 )
|
||||
@@ -1,77 +0,0 @@
|
||||
## Appium 2.0 驱动的命令行工具 Command Line Interface (CLI)
|
||||
|
||||
Appium 将使用某种利用自动化技术,实现某个平台自动化的软件称为"驱动程序(driver)"。包括 iOS、Android 及其他平台。在 Appium 2.0 上,将不会您下载 Appium 时,按以往那样,默认下载所有驱动(driver)。因为这样被下载的驱动太多了。取而代之的,是您可以使用一个特殊的命令行来指导 Appium 为您安装和注册驱动程序,以便能够真正用到您需要的驱动。本文档强调了该界面中可用的各种命令。
|
||||
|
||||
### 概述
|
||||
|
||||
所有这些命令都可以在输入`appium driver`后使用。例如,在本文档中,定义为`list`的命令将以以下方式使用:
|
||||
|
||||
```
|
||||
appium driver list
|
||||
```
|
||||
|
||||
*公共参数*
|
||||
|
||||
这里有些所有命令都可用的公共参数:
|
||||
|
||||
|参数|描述|默认值|
|
||||
|----|-----------|-------|
|
||||
|`-ah`, `--home`, `--appium-home`|设置 APPIUM_HOME 目录的路径,该目录将安装驱动程序和插件,并将维护驱动程序/插件清单,|如果设置了该参数,默认值为设置的地址,否则默认地址为:`$HOME/.appium`|
|
||||
|`--json`|只输出JSON格式的命令返回结果,而不输出人们可读的日志信息|默认值为false。通过包含此标志设置为true。|
|
||||
|
||||
### `list`
|
||||
|
||||
该命令无参数时,按名称列出可安装的驱动程序,以及通过任何方式安装的驱动。
|
||||
|
||||
|参数|描述|默认值|
|
||||
|----|-----------|-------|
|
||||
|`--installed`|只展示已安装的|否|
|
||||
|`--updates`|对于通过NPM安装的驱动程序,检查并显示任何更新|否|
|
||||
|
||||
|示例|描述|
|
||||
|-------|-----------|
|
||||
|`appium driver list`|列出可用的驱动程序|
|
||||
|`appium driver list --installed`|列出已安装的驱动程序|
|
||||
|`appium driver list --updates`|列出已安装且可更新的驱动程序|
|
||||
|
||||
### `install`
|
||||
|
||||
该命令使用驱动名称或规格,或来源标识(如果它不是正式驱动程序)来作为参数,
|
||||
|
||||
|参数|描述|默认值|
|
||||
|----|-----------|-------|
|
||||
|`--source`|如果不是官方驱动,可以按以下几种方式之一来表示: `npm`, `local`, `github`, `git`|None|
|
||||
|
||||
注意,对于任何通过NPM安装的驱动程序(包括官方驱动程序,以及使用`--source=npm`安装的驱动),你可以在驱动程序名称后面使用任何有效的NPM安装规范,如:`xcuitest@2.1.2` 将会安装指定版本的XCUITest驱动程序。
|
||||
|
||||
|示例|描述|
|
||||
|-------|-----------|
|
||||
|`appium driver install xcuitest`|下载安装官方 XCUITest 驱动|
|
||||
|`appium driver install xcuitest@2.1.2`|下载安装官方指定版本的 XCUITest 驱动|
|
||||
|`appium driver install --source=npm appium-fake-driver`|通过 NPM 下载安装 `appium-fake-driver` |
|
||||
|`appium driver install --source=github appium/appium-fake-driver`|从 github 下载安装 `appium-fake-driver` 驱动|
|
||||
|`appium driver install --source=local /path/to/driver/directory`|从本地文件安装|
|
||||
|
||||
### `update`
|
||||
|
||||
该命令通过添加已经安装的驱动名称,或关键词 `installed`,来自动更新一个或所有的驱动(如果用了: `installed`)。
|
||||
|
||||
注意:这将更新驱动程序到最高可用的小版本(minor version),但将*不*更新到新的大版本(major version)。因为可能包含一些重大变化。如果期望更新到大版本,使用参数:`--unsafe`
|
||||
|
||||
|参数|描述|默认值|
|
||||
|----|-----------|-------|
|
||||
|`--unsafe`|更新到一个大版本|None|
|
||||
|
||||
|示例|描述|
|
||||
|-------|-----------|
|
||||
|`appium driver update xcuitest`|更新 XCUITest 驱动到最新的安全版本|
|
||||
|`appium driver update installed`|更新所有已安装的驱动到最新的安全版本|
|
||||
|`appium driver update --unsafe xcuitest`|更新 XCUITest 驱动到最新版本 (即使是最新的大版本)|
|
||||
|
||||
### `uninstall`
|
||||
|
||||
删除一个驱动.
|
||||
|
||||
|示例|描述|
|
||||
|-------|-----------|
|
||||
|`appium driver uninstall xcuitest`|删除 XCUITest 驱动|
|
||||
@@ -1,200 +0,0 @@
|
||||
## Appium XCUITest 驱动在真机上的设置
|
||||
|
||||
### 安装依赖
|
||||
|
||||
自 Appium 1.15.0 起,Appium 与真机设备通过 [appium-ios-device](https://github.com/appium/appium-ios-device) 进行联通。您不需要再额外安装依赖项。XCUITest 驱动会安装一个名为 `WebDriverAgent-Runner` 的辅助软件在设备上,并通过这个辅助软件控制被测应用。虽然这听起来很简单,但在苹果软件的代码签名和配置应用程序上,在开发和测试中可能会有些头痛。
|
||||
应该可以从Xcode中找到待测设备。请确保被测设备连接Xcode万无一失。你可以通过打开 _Devices and Simulators_ 这个选项栏来确认这件事。
|
||||
|
||||
这篇文章也有利于解决环境依赖安装的问题 [appium-xcuitest-driver](https://github.com/appium/appium-xcuitest-driver) 。
|
||||
|
||||
|
||||
### 基础 (自动) 配置
|
||||
|
||||
在 iOS 真机上使用 XCUITest 运行自动化测试最简单的方法,就是使用自动配置来运行。这里有两条路:
|
||||
|
||||
* 使用功能参数 `xcodeOrgId` 与 `xcodeSigningId` :
|
||||
```json
|
||||
{
|
||||
"xcodeOrgId": "<Team ID>",
|
||||
"xcodeSigningId": "iPhone Developer"
|
||||
}
|
||||
```
|
||||
* 在任意路径下,创建一个 `.xcconfig` 文件,并添加如下配置:
|
||||
```
|
||||
DEVELOPMENT_TEAM = <Team ID>
|
||||
CODE_SIGN_IDENTITY = iPhone Developer
|
||||
```
|
||||
|
||||
无论哪种情况,苹果公司会生成一个 10 位字符的唯一字符串作为您的 Team ID,分配给您的开发团队。您可以您的开发者账号找到这个 Team ID,您可以登录[developer.apple.com/account](http://developer.apple.com/account) 并点击侧边栏的 「开发者资格( Membership )」。您可以在 「开发者资格( Membership )」 详细信息的团队名称下找到您的 Team ID。您也可以在您电脑「钥匙串」中的 iPhone 开发者证书中的 「组织单元("Organizational Unit")」字段中,找到您的 Team ID。
|
||||
|
||||
需要注意的是,使用 `xcodeConfigFile` 这种方式,与使用 `xcodeOrgId` 和 `xcodeSigningId` 的方式是互斥的。
|
||||
|
||||
这些配置完成后,您就只剩下将您的真机设备配置在参数 `udid` 中就可以了。
|
||||
|
||||
如果配置完无法运行,一般会在 Appium 服务日志中有对应的报错信息,比如有些会提示:`info XCUITest xcodebuild exited with code '65' and
|
||||
signal 'null'`。这通常意味着代码签名配置的有问题。继续回看上一部分[基础 (自动) 配置](#basic-manual-configuration)来解决这个问题。
|
||||
|
||||
如果 `WebDriverAgentRunner` 在真机设备上安装成功,但是 Appium 服务日志有如下报错:
|
||||
```
|
||||
2017-01-24 09:02:18.358 xcodebuild[30385:339674] Error Domain=com.apple.platform.iphoneos Code=-12 "Unable to launch com.apple.test.WebDriverAgentRunner-Runner" UserInfo={NSLocalizedDescription=Unable to launch com.apple.test.WebDriverAgentRunner-Runner, NSUnderlyingError=0x7fa839cadc60 {Error Domain=DTXMessage Code=1 "(null)" UserInfo={DTXExceptionKey=The operation couldn’t be completed. Unable to launch com.apple.test.WebDriverAgentRunner-Runner because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user. : Failed to launch process with bundle identifier 'com.apple.test.WebDriverAgentRunner-Runner'}}}
|
||||
2017-01-24 09:02:18.358 xcodebuild[30385:339674] Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}
|
||||
|
||||
Testing failed:
|
||||
Test target WebDriverAgentRunner encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted)
|
||||
```
|
||||
这个问题是由于开发者在设备上不受信任,当你手动尝试将 `WebDriverAgentRunner` 安装在您的真机设备上时,会看到如下弹窗信息:
|
||||
|
||||

|
||||
|
||||
您可以通过 设置(Settings) => 通用(General) => 设备管理(Device Management)来信任开发者,以使 `WebDriverAgentRunner` 能够成功运行 (更多详细信息见: [苹果官方支持文档](https://support.apple.com/en-us/HT204460))。
|
||||
|
||||
|
||||
|
||||
### 基础 (手动) 配置
|
||||
|
||||
在很多情况下,基本的自动配置是不满足使用需要的。通常在自动化运行时,会有代码签名和项目配置的问题。当正在使用的开发帐户是“免费”帐户时,无法创建出通用的配置文件。
|
||||
|
||||
这通常表现为 Xcode 报错为:**failed to create
|
||||
provisioning profile**:
|
||||
|
||||

|
||||
|
||||
解决此问题的最简单方法是通过打开 [Xcode](https://developer.apple.com/xcode/) 并创建一个新项目来创建配置文件 :
|
||||
|
||||

|
||||
|
||||
只要选择了 "iOS",具体的应用类型无关紧要,一般使用单页面应用 ("Single View Application")最简单也最方便:
|
||||
|
||||

|
||||
|
||||
重要的是,使用一个唯一的 产品名称("Product Name")与 组织名称("Organization Name"),并且,在这时候,请选择你的团队("Team")。
|
||||
|
||||

|
||||
|
||||
您可以通过查看 "项目" 选项,来确认配置文件是否已创建:
|
||||
|
||||

|
||||
|
||||
或者通过进入您的帐户首选项并查看配置文件:
|
||||
|
||||

|
||||
|
||||
此时,您有一个有效的配置文件。记住 bundle id 并添加到测试的 `updatedWDABundleId` 功能参数中。然后按照 [如何初始化自动配置](#basic-automatic-configuration).
|
||||
|
||||
|
||||
### 完全手工配置
|
||||
|
||||
或者,配置文件可以完全通过手工在项目中配置(需要知道的是,每次WDA更新、Appium更新时,都需要操作一次,_不推荐_ ):
|
||||
|
||||
* 找到您 Appium 的安装路径:
|
||||
```
|
||||
$ which appium
|
||||
/path/where/installed/bin/appium
|
||||
```
|
||||
* 由于路径在: `/path/where/installed/bin/appium`,那么,`WebDriverAgent` 可以在这个路径的下级路径中被找到: `/path/where/installed/lib/node_modules/appium/node_modules/appium-webdriveragent`。
|
||||
打开终端(terminal),移动到该路径下执行如下命令:
|
||||
```
|
||||
mkdir -p Resources/WebDriverAgent.bundle
|
||||
```
|
||||
* ( 如果 Appium 版本低于 1.20 ) 在终端(terminal)执行如下命令:
|
||||
```
|
||||
./Scripts/bootstrap.sh -d
|
||||
```
|
||||
* Xcode 打开 `WebDriverAgent.xcodeproj`。同时选中 `WebDriverAgentLib`
|
||||
and `WebDriverAgentRunner` ,在 通用("General")页签下,都选择为自动管理签名("Automatically manage signing"),然后选择您所在的开发组织(`Development Team`),它将自动选择开发者签名证书(`Signing Ceritificate`)。结果应如下所示:
|
||||
|
||||

|
||||
|
||||
* Xcode 可能无法为 `WebDriverAgentRunner` 创建配置文件:
|
||||
|
||||

|
||||
|
||||
* 这需要通过进入构建设置("Build Settings")页签下,手动更改目标的bundle id,并且将构建产物标识符("Product Bundle Identifier")`com.facebook.WebDriverAgentRunner` 进行一些修改,以让 Xcode 通过:
|
||||
|
||||

|
||||
|
||||
* Going back to the "General" tab for the `WebDriverAgentRunner` target, you
|
||||
should now see that it has created a provisioning profile and all is well:
|
||||
返回 `WebDriverAgentRunner` 的通用("General")页签,您将看到配置文件已经创建完成,并且所有配置都是正常的了:
|
||||
|
||||

|
||||
|
||||
* 最后,您可以验证一切是否正常。构建项目:
|
||||
```
|
||||
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test
|
||||
```
|
||||
如果一切正常,输出信息一般以此结尾:
|
||||
```
|
||||
Test Suite 'All tests' started at 2017-01-23 15:49:12.585
|
||||
Test Suite 'WebDriverAgentRunner.xctest' started at 2017-01-23 15:49:12.586
|
||||
Test Suite 'UITestingUITests' started at 2017-01-23 15:49:12.587
|
||||
Test Case '-[UITestingUITests testRunner]' started.
|
||||
t = 0.00s Start Test at 2017-01-23 15:49:12.588
|
||||
t = 0.00s Set Up
|
||||
```
|
||||
* 要完全验证,您可以尝试访问 WebDriverAgent 服务器状态
|
||||
(**提示:** 您 _必须_ 保证 WebDriverAgent 服务与设备在同一网络下,可以通过以下方式获取 IP, Settings => Wi-Fi => Current Network):
|
||||
```
|
||||
export DEVICE_URL='http://<device IP>:8100'
|
||||
export JSON_HEADER='-H "Content-Type: application/json;charset=UTF-8, accept: application/json"'
|
||||
curl -X GET $JSON_HEADER $DEVICE_URL/status
|
||||
```
|
||||
您将获得类似如下的返回信息:
|
||||
|
||||
```
|
||||
{
|
||||
"value" : {
|
||||
"state" : "success",
|
||||
"os" : {
|
||||
"name" : "iOS",
|
||||
"version" : "10.2"
|
||||
},
|
||||
"ios" : {
|
||||
"simulatorVersion" : "10.2",
|
||||
"ip" : "192.168.0.7"
|
||||
},
|
||||
"build" : {
|
||||
"time" : "Jan 23 2017 14:59:57"
|
||||
}
|
||||
},
|
||||
"sessionId" : "8951A6DD-F3AD-410E-A5DB-D042F42F68A7",
|
||||
"status" : 0
|
||||
}
|
||||
```
|
||||
|
||||
### 对被测应用的设置
|
||||
|
||||
不仅是 WDA 可以在您的设备上运行,被测应用也需要可以在您的设备上运行。它们之间的规则是相同的:一个拥有签名的被测应用( 一个 `.ipa` 文件)。 可以在 这里 [这里](https://medium.com/ios-os-x-development/ios-code-signing-provisioning-in-a-nutshell-d5b247760bef#.5hirl92tn)
|
||||
与
|
||||
[这里](https://www.nodesagency.com/understanding-code-signing-for-ios-apps) 找到更详细的描述。
|
||||
|
||||
更详细地说,要使用真机运行自动化测试,您需要以下内容:
|
||||
|
||||
* 一个 [苹果开发者ID](https://developer.apple.com/programs/ios/) 和一个有效的开发者帐户,以及一个配置好的开发证书和配置文件。(请确保配置文件具有[iOS Distribution](https://developer.apple.com/support/certificates/)类型)
|
||||
|
||||
* 如果需要在真机运行测试,一个合法的 iOS 开发者证书和配置文件是必须有的。您的 App 也需要签名。您可以在这里看到更多信息:[苹果官方文档](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html)。
|
||||
|
||||
* 一台 iPad 或 iPhone设备。请确保在 Xcode 中可以找到它们。
|
||||
|
||||
* 一个拥有签名的 `.app` 或 `.ipa` 被测 App 应用,或者是它们可以被构建的源代码。
|
||||
|
||||
* 一台拥有 [Xcode](https://developer.apple.com/xcode/) 与 Xcode 开发者命令行工具的 Mac 系统的电脑。
|
||||
|
||||
Appium 将通过 `ideviceinstaller` (`libimobiledevice` 的一部分功能) 将应用安装到设备上,但有时候,通过 Xcode 预安装会更加方便(再看看这个:[苹果官方文档](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html))
|
||||
|
||||
|
||||
### 问题排查思路
|
||||
|
||||
1. 请通过 Xcode Organizer 或 iTunes 确保设备 UDID 是正确的。 它是一个 20+ 的字符串。
|
||||
1. 请确保相同操作在模拟器上是可以运行的。
|
||||
1. 请确保在设备上 **启动** 了以下设置:
|
||||
1. 设置(Settings) -> 开发者(Developer) -> **启动 UI Automation (Enable UI Automation)**
|
||||
1. 设置(Settings) -> Safari -> 高级(Advanced) -> **Web Inspector** 与 **Remote Automation**
|
||||
1. 请阅读 [Automating mobile web apps](/writing-running-appium/web/mobile-web) 获取关于 WebView 运行的详细信息。
|
||||
1. 如果您不想为手动配置配置文件,请在自动生成时带上 `.xctrunner` 标识。`.xctrunner` 在 Xcode 11. [A reference](https://github.com/appium/appium/issues/13610) 起,将被自动配置。
|
||||
|
||||
1. 请确保设备没有越狱
|
||||
- `com.apple.mobile.installation_proxy` 服务在管理 App 上[不起作用](https://github.com/appium/appium-desktop/issues/1447)
|
||||
|
||||
1. 确保配置文件具有:[_iOS 分发证书_](https://developer.apple.com/support/certificates/)
|
||||
- 由于 Apple 的安全设计,活动 Xcode/xcodebuild 连接/会话是与 WebDriverAgentRunner 交互所必需需要的。 证书限制的影响: ([issue](https://github.com/appium/appium/issues/14577#issuecomment-660997827))
|
||||
@@ -1,118 +0,0 @@
|
||||
## iOS 的 XCUITest 驱动
|
||||
|
||||
iOS 应用的自动化测试,Appium 主要通过 `XCUITest` 驱动进行驱动。_(如果您是 Appium 新手? 可以参阅: [introduction to Appium drivers](#TODO))_。这个驱动通过苹果公司的 [XCUITest](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/09-ui_testing.html) 库,让自动化测试可以更方便地执行 App 自动化测试。它是通过 [WebDriverAgent](https://github.com/facebook/webdriveragent) 服务对 XCUITest 进行访问。WebDriverAgent(也称之为 “ WDA ”)是 Facebook 公司的一个项目,Appium 的核心团队为其做出了许多贡献。WDA 是一个 WebDriver兼容的服务,服务可以运行在 iOS 模拟器或真机上,并且调用 XCUITest API。WDA 作为 Appium 的 XCUITest 驱动管理器,对用户而言是一个黑盒进程,通过 WDA 对往来的通信进行代理,并提供许多额外的能力(举个例子:如管理模拟器等方法)。
|
||||
|
||||
XCUITest 驱动的开发过程,记录在了 [appium-xcuitest-driver](https://github.com/appium/appium-xcuitest-driver) 仓库中。
|
||||
|
||||
|
||||
### 需求与依赖
|
||||
|
||||
在 Appium 常规依赖之外:
|
||||
|
||||
* 苹果公司从的 XCUITest 库只适用于 iOS 版本大于等于 iOS 9.3 的模拟器或真机设备。
|
||||
* 需要一台 macOS 10.11 或 10.12 的 Mac 电脑。
|
||||
* Xcode 7 或更高版本的 Xcode.
|
||||
* XCUITest 驱动从 Appium 1.6 开始在 Appium 中可用。
|
||||
* 为了驱动使用正确,附加的系统库是必需的(请参阅下面的安装部分)。
|
||||
|
||||
### 迁移自 UIAutomation 驱动
|
||||
|
||||
如果您正在从 Appium 的旧驱动程序:[UIAutomation-based driver](/docs/en/drivers/ios-uiautomation.md) 迁移到XCUITest驱动,您可能想知道这个:[迁移指南](/docs/en/advanced-concepts/migrating-to-xcuitest.md)。
|
||||
|
||||
|
||||
### 使用
|
||||
|
||||
在使用 XCUITest 驱动来创建一个会话链接时,需要包含 `automationName` [capability](#TODO) 参数在您的 [创建新会话请求](#TODO)中,且其值应该是:`XCUITest`。当然,您也至少传递这些必传参数:`platformName`, `platformVersion`, `deviceName` 与 `app`。
|
||||
|
||||
在 iPhone 与 iPad 设备上,参数 `platformName` 需要是 `iOS`。在 tvOS 设备上,参数 `platformName` 需要是 `tvOS`。
|
||||
|
||||
- iOS
|
||||
```json
|
||||
{
|
||||
"automationName": "XCUITest",
|
||||
"platformName": "iOS",
|
||||
"platformVersion": "12.2",
|
||||
"deviceName": "iPhone 8",
|
||||
...
|
||||
}
|
||||
```
|
||||
- tvOS
|
||||
```json
|
||||
{
|
||||
"automationName": "XCUITest",
|
||||
"platformName": "tvOS",
|
||||
"platformVersion": "12.2",
|
||||
"deviceName": "Apple TV",
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### 功能参数
|
||||
|
||||
XCUITest 驱动支持许多通用的功能参数 [Appium
|
||||
capabilities](/docs/en/writing-running-appium/caps.md), 同时,有许多特有的功能参数,可以参考这篇文档查找这些功能参数:[appium-xcuitest-driver
|
||||
README](https://github.com/appium/appium-xcuitest-driver#desired-capabilities).
|
||||
|
||||
如果要在 Safari 上测试,而不是在您的 App 上测试的话,请设置 `app` 为空,并且设置 `browserName` 为 `Safari`。
|
||||
|
||||
|
||||
### 命令
|
||||
|
||||
如果需要查看 Appium 支持的命令,及它们是如何映射到 XCUITest 驱动的,可以参考:[API
|
||||
Reference](#TODO).
|
||||
|
||||
|
||||
### 基础设置
|
||||
|
||||
_(我们推荐使用 [Homebrew](https://brew.sh) 来安装系统依赖)_
|
||||
|
||||
1. 确保您拥有 Appium 的基础依赖(例如:Node 与 NPM)来安装和配置 Appium。
|
||||
|
||||
如果您的自动化测试不使用真机运行,那么您已经完成设置了! 使用模拟器运行一个自动化测试app, 参数 `app` 需要设置为 App 的绝对路径或下载地址,它需要是一个后缀为 `.app` 或 `.app.zip` 这样的,为模拟器构建的 App 文件。
|
||||
|
||||
### 真机设备设置
|
||||
|
||||
Automating a real device with XCUITest is considerably more complicated,
|
||||
在真机上使用 XCUITest 进行自动化要复杂得多,原因是
|
||||
苹果对在真实设备上运行应用程序的限制。请查看 [XCUITest real device setup doc](ios-xcuitest-real-devices.md) 获取介绍 。
|
||||
|
||||
一旦设置完成,在真机上运行会话可以使用这些功能:
|
||||
|
||||
* `app` 或 `bundleId` - 一个是:指定应用程序 (您使用的 `.ipa` 文件的本地路径或下载地址), 另一个是:如果您已经安装了 App, 用以标示您需要让 Appium 拉起哪一个应用。
|
||||
* `udid` - 指定要在哪个设备上运行测试。 如果只有一个设备的话,它可以设置为 `auto` , Appium 将会自动找到并使用该设备。
|
||||
|
||||
|
||||
### 可选设置
|
||||
|
||||
* 安装 idb 可以更好地处理各种iOS模拟器操作,
|
||||
例如:生物特征、地理位置设置和窗口聚焦。
|
||||
* 参考 https://github.com/appium/appium-idb#installation 以安装一些必要的库 (自 Appium 1.14.0 起 )
|
||||
|
||||
* 安装 [AppleSimulatorUtils](https://github.com/wix/AppleSimulatorUtils)
|
||||
以设置 [权限相关参数](https://github.com/appium/appium-xcuitest-driver#desired-capabilities)
|
||||
|
||||
### 运行测试生成的文件
|
||||
|
||||
在 iOS 上测试生成的文件有时会很大。 它包括:日志文件、临时文件以及Xcode运行时产生的数据。如果需要删除这些文件,一般来说,可以从以下地址找到它们:
|
||||
|
||||
```
|
||||
$HOME/Library/Logs/CoreSimulator/*
|
||||
$HOME/Library/Developer/Xcode/DerivedData/*
|
||||
```
|
||||
|
||||
### 键盘设置
|
||||
高于 Appium 1.14.0,Appium 默认配置键盘首选项以让测试运行地更加稳定。您可以通过这些 API 来设置。
|
||||
|
||||
- 可以在 _Keyboards_ 关闭 `Auto-Correction`
|
||||
- 可以在 _Keyboards_ 关闭 `Predictive`
|
||||
- Mark keyboard tutorial as complete
|
||||
- (仅模拟器生效) 打开虚拟键盘
|
||||
|
||||
### 可访问偏好设置调整
|
||||
|
||||
在某些情况下,启用以下首选项有助于使某些视图元素可访问。
|
||||
Appium不会自动修改这些设置,因为它们可能会影响被测试应用程序的执行方式。
|
||||
如果需要这些设置,需要您手动设置。
|
||||
|
||||
- 可以在 _Settings > Accessibility_ 打开 `Spoken Content`
|
||||
- 可以在 _Settings > Accessibility_ 打开 `Speak Selection`
|
||||
@@ -14,10 +14,10 @@ Appium 支持以下语言的客户端类库:
|
||||
|
||||
[rubygems]: http://rubygems.org/gems/appium_lib
|
||||
[pypi]: https://pypi.python.org/pypi/Appium-Python-Client
|
||||
[maven]: https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.appium%22%20AND%20a%3A%22java-client%22
|
||||
[maven]: https://search.maven.org/#search%7Cga%7C1%7Cg%3Aio.appium%20a%3Ajava-client
|
||||
[npm]: https://www.npmjs.org/package/wd
|
||||
[php]: https://github.com/appium/php-client
|
||||
[nuget]: https://www.nuget.org/packages/Appium.WebDriver/
|
||||
[nuget]: http://www.nuget.org/packages/Appium.WebDriver/
|
||||
[cocoapods]: https://github.com/appium/selenium-objective-c
|
||||
|
||||
|
||||
|
||||
@@ -119,16 +119,26 @@
|
||||
|`wdaLaunchTimeout`|等待 WebDriverAgent 可 ping 同的时间(以毫秒为单位)。默认设置为 60000ms。|例如 `30000`|
|
||||
|`calendarAccessAuthorized`|若设置为 `true`,则允许在 iOS 模拟器上访问日历。若设置为 `false`,则不被允许。否则,日历的 authorizationStatus 会保持不变。 | - |
|
||||
|
||||
### MacDriver 独有
|
||||
|
||||
[Appium Mac Driver repo](https://github.com/appium/appium-mac-driver#desired-capabilities)
|
||||
|
||||
### You.i 引擎独有
|
||||
|
||||
<expand_table>
|
||||
|
||||
[You.i Engine driver](https://github.com/YOU-i-Labs/appium-youiengine-driver#desired-capabilities) itself.)
|
||||
|键|描述|值|
|
||||
|----|-----------|-------|
|
||||
|`youiEngineAppAddress`| 正在运行的应用的设备的 IP 地址。使用 `localhost` 作为模拟地址。使用 `localhost` 作为模拟器地址。使用设备的 IP 地址作为真机的 IP。|例如 `localhost` 或 `192.168.1.203`|
|
||||
|
||||
|
||||
|
||||
### WinAppDriver 独有
|
||||
|
||||
[Appium Windows Driver repo](https://github.com/appium/appium-windows-driver#windowsdriver-specific-capabilities)
|
||||
<expand_table>
|
||||
|
||||
|键|描述|值|
|
||||
|----|-----------|-------|
|
||||
|`platformName`| 运行测试时所在的平台 |例如 `Windows`|
|
||||
|`deviceName`| 运行测试时所使用设备的名字 | 例如 `WindowsPC`|
|
||||
|`app`| 被测 windows 应用的 appID 或被测的 .exe 文件的路径。 查阅[该文档](/docs/cn/writing-running-appium/windows-app-testing.md)可了解更多查找 appID 的详细方法。 | 例如 `c24c8163-548e-4b84-a466-530178fc0580_scyf5npe3hv32!App`|
|
||||
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译。由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -1,6 +1,7 @@
|
||||
## --default-capabilities 标识
|
||||
|
||||
Appium 1.5 移除了大部分旧版本遗留的 CLI 标识;其余部分可转换成 JSON 并成为 `--default-capabilities` 标识的一部分。举个例子:
|
||||
Appium 1.5 移除了大部分旧版本遗留的 CLI 标识;其余部分可转换成 JSON 并成为 `--default-capabilities` 标识的一部分。
|
||||
举个例子:
|
||||
|
||||
```
|
||||
# 未处理的 JSON 作为一个参数
|
||||
@@ -53,9 +54,4 @@ Appium 1.5 移除了大部分旧版本遗留的 CLI 标识;其余部分可转
|
||||
| --show-ios-log | showIOSLog |
|
||||
| --reboot | reboot |
|
||||
|
||||
---
|
||||
EOF.
|
||||
|
||||
本文由 thanksdanny 翻译
|
||||
|
||||
Last english version: a4dd79b8144864cbc034eb97a8f0b5d744e3435c, Oct 24, 2017
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译
|
||||
@@ -2,53 +2,25 @@
|
||||
|
||||
Appium 支持 WebDriver 定位策略的子集:
|
||||
|
||||
* 通过 "class" 查找 (例如, UI 组件的类型)
|
||||
* 通过 "xpath" 查找 (例如, 一个元素的路径以抽象的方式去表达,具有一定的约束)
|
||||
* 通过 "class" 查找 (例如: UI 组件的类型)
|
||||
* 通过 "xpath" 查找 (例如: 一个元素的路径以抽象的方式去表达,具有一定的约束)
|
||||
|
||||
你可以查看关于以上的列表,[选择器策略](/docs/en/commands/element/find-elements.md#selector-strategies) (English)。
|
||||
|
||||
Appium 还额外支持部分 [Mobile JSON Wire Protocol](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md) 的定位策略。
|
||||
Appium 还额外支持部分 [Mobile JSON Wire Protocol](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md) 的定位策略
|
||||
|
||||
* `-ios predicate string`:相当于使用 [iOS Predicate](/docs/cn/writing-running-appium/ios/ios-predicate.md) 去递归地搜索元素(iOS 10.0 及以上版本)
|
||||
* `-ios uiautomation` 用于 iOS 9.3 及以下版本
|
||||
* `-android uiautomator`:相当于使用 [UiAutomator Api](/docs/cn/writing-running-appium/android/uiautomator-uiselector.md) 去递归地搜索元素(Android 专属)
|
||||
* `-android datamatcher`:相当于一个 [Espresso DataMatcher json](/docs/en/writing-running-appium/android/espresso-datamatcher-selector.md) (Android 专属)
|
||||
* `accessibility id`:该字符串相当于利用原生的可访问性(Accessibility)选项,使用 Id / Name 去递归地搜索元素。
|
||||
|
||||
最后,Appium 支持几个额外的实验性定位策略:
|
||||
|
||||
* `-image`: 字符串对应图像的 base64 编码版本,Appium 将使用该字符串作为模板来查找匹配的屏幕区域,然后将其视为元素点击。关于该定位器策略的更多信息,请参见文档 [定位图像中的元素](/docs/en/advanced-concepts/image-elements.md) (English)。
|
||||
* `-custom`: 该字符串将被发送到一个通过 `customFindModules` 功能注册的元素定位插件。关于该定位器策略的更多信息,请参见文档 [用于定位元素的插件](/docs/en/advanced-concepts/element-finding-plugins.md) (English)。
|
||||
* `-ios uiautomation`: 该字符串相当于使用 [UIAutomation 库](ios_predicate.md) 去递归地搜索元素(仅支持iOS 9.3 及以下的版本)
|
||||
* `-android uiautomator`: 该字符串相当于使用 [UiAutomator Api](uiautomator_uiselector.md) 去递归地搜索元素(仅支持 Android)
|
||||
* `accessibility id`: 该字符串相当于利用原生的可访问性(Accessibility)选项,使用 Id/Name 去递归地搜索元素。
|
||||
|
||||
### 已知问题
|
||||
|
||||
在我们要与表格 cell 元素进行交互之前,元素便已失效,这是已知的问题。我们正在修复它。
|
||||
在我们要与 table cell 元素进行交互之前,元素会变成无效。这是已知的问题,我们会尽快修复。
|
||||
|
||||
### 使用 Appium Desktop 去找出元素的位置
|
||||
|
||||
Appium 提供了一个简洁的工具,供你查找要定位的元素。使用 [Appium Desktop](https://github.com/appium/appium-desktop),你可以通过单击屏幕截图上的元素或在源代码树进行定位,找到任何元素及其定位器。
|
||||
### 使用 Appium Inspector 去定位元素
|
||||
|
||||
### 概述
|
||||
这里之前的文档都已经 deprecated 了。最新的请参见:[The Inspector](https://github.com/appium/appium-desktop#the-inspector)
|
||||
|
||||
Appium Desktop 有一个简洁的布局,由源代码树、屏幕截图、记录和刷新按钮、交互工具构成。
|
||||
|
||||

|
||||
|
||||
### 示例
|
||||
|
||||
启动 Appium Desktop 并开始会话后,可以定位任何元素。在这个测试中,我正在寻找「Compute Sum」按钮的 accessibility id。
|
||||
|
||||
为了寻找「Compute Sum」按钮的 accessibility id,我在屏幕截图中单击「Compute Sum」按钮。该元素会在源代码树中高亮突出显示。我可以在右边的面板中看到 accessibility id。
|
||||
|
||||

|
||||
|
||||
### REPL
|
||||
[REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) 是一个简单的交互式语言外壳。你可以交互式地调用各种命令。它将帮助你确保场景与 Appium 服务器交互。
|
||||
|
||||
---
|
||||
EOF.
|
||||
|
||||
本文由 thanksdanny 翻译。由 lihuazhang 校验。
|
||||
|
||||
翻译:@[Pandorym](https://github.com/Pandorym)
|
||||
Last english version: 438d6c3b38e785edc701354cf660aa9f76baceaf, Apr 11, 2019
|
||||
本文由 [thanksdanny](https://testerhome.com/thanksdanny) 翻译。由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -94,7 +94,7 @@ driver.execute('mobile: doubleTap', {element: element.value.ELEMENT});
|
||||
* _duration_: 长按的持续时间(秒),浮点型。强制性参数
|
||||
* _x_: 屏幕x轴坐标点,浮点型. 仅当`element`未设置时才是强制参数
|
||||
* _y_: 屏幕y轴坐标点,浮点型. 仅当`element`未设置时才是强制参数
|
||||
|
||||
|
||||
#### 用法示例
|
||||
|
||||
```csharp
|
||||
@@ -217,4 +217,4 @@ driver.execute_script('mobile: alert', {'action': 'accept', 'buttonLabel': 'My C
|
||||
查看 [WDA Element Commands API](https://github.com/facebook/WebDriverAgent/blob/master/WebDriverAgentLib/Commands/FBElementCommands.m)
|
||||
以获取有关在Facebook WebDriverAgent中实现的手势的信息。
|
||||
|
||||
本文由 大东 翻译,由 lihuazhang 校验。
|
||||
本文由 [大东](https://testerhome.com/Anikikun) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -1,6 +1,6 @@
|
||||
## iOS 谓词(Predicate)
|
||||
|
||||
在查看 *'-ios uiautomation'* 搜索策略时了解 **谓词(Predicate)** 十分必要。 [UIAutomation JavaScript API](https://web.archive.org/web/20160904214108/https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/)有下列几种非常有用的方法:
|
||||
在查看 *'-ios uiautomation'* 搜索策略时了解 **谓词(Predicate)** 十分必要。 [UIAutomation JavaScript API](https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/)有下列几种非常有用的方法:
|
||||
|
||||
```center
|
||||
(UIAElement) UIAElementArray.firstWithPredicate(PredicateString predicateString)
|
||||
@@ -60,14 +60,15 @@ capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator")
|
||||
这是因为Safari是苹果公司的应用,Instruments 不能在真机上拉起 Safari。SafariLuncher 可以帮助打开 Safari 浏览器,浏览器一旦打开,Remote Debugger 会通过 [ios-webkit-debug-proxy](https://github.com/google/ios-webkit-debug-proxy) 自动连接。在 `ios-webkit-debug-proxy` 运行时,
|
||||
必须在你的iOS设备测试前,信任这台设备
|
||||
|
||||
指导如何安装和运行 ios-webkit-debugger-proxy ,可以查阅 [iOS WebKit debug proxy](/docs/cn/writing-running-appium/web/ios-webkit-debug-proxy.md)
|
||||
指导如何安装和运行 ios-webkit-debugger-proxy ,可以查阅 [iOS WebKit debug proxy](/docs/cn/advanced-concepts/ios-webkit-debug-proxy.md)
|
||||
|
||||
### 安装
|
||||
|
||||
在真实上运行测试前,你需要:
|
||||
|
||||
* 安装好 **ios-webkit-debug-proxy**,运行并在 27753 接口开启监听。(查阅 [hybrid 文档](/docs/cn/writing-running-appium/web/hybrid.md#execution-against-a-real-ios-device) 作为指导)
|
||||
* 安装好 **ios-webkit-debug-proxy**,运行并在 27753 接口开启监听。(查阅 [hybrid 文档](/docs/cn/advanced-concepts/hybrid.md#execution-against-a-real-ios-device) 作为指导)
|
||||
* 在 iOS 设备上开启 **web inspector**(设置>safari>高级)
|
||||
* 确保 `SafariLauncher` 正常工作 (参考 [SafariLauncher docs](safari-launcher.md))
|
||||
|
||||
|
||||
### 运行你的测试
|
||||
@@ -147,7 +148,7 @@ class ContextTests extends PHPUnit_Extensions_AppiumTestCase
|
||||
前提设置:
|
||||
|
||||
* 确保 Chrome (应用包名 `com.android.chrome`) 在设备或者模拟器上安装好了。不编译 Chromium,在 x86 版本的模拟器上安装 Chrome 已经不可能了。所以你需要运行一个 ARM 版本的模拟器,然后从真机上复制一个 Chrome APK 到模拟器上。
|
||||
* 在特定版本的 Chrome 上进行自动化,需要安装和配置不同版本的 Chromedriver,更多信息参考[文档](chromedriver.md)
|
||||
* 在特定版本的 Chrome 上进行自动化,需要安装和配置不同版本的 Chromedriver,更多信息参考[文档](/docs/cn/advanced-concepts/chromedriver.md)
|
||||
|
||||
然后,使用如下设置,在你的Chrome下运行你的测试:
|
||||
|
||||
@@ -2,33 +2,33 @@
|
||||
|
||||
### 准备你要测试的应用(iOS)
|
||||
|
||||
被测应用要在模拟器上运行,就必须针对该模拟器进行专门的编译,例如在 Xcode 项目下执行如下命令(你可以使用 `xcodebuild -showsdks` 查看可用的 SDK 列表):
|
||||
被测应用要在模拟器上运行,就必须针对该模拟器进行专门的编译,例如在 Xcode 项目下执行如下命令(你可以使用 `xcodebuild -showsdks` 来看看你电脑上提供了多少 SDK):
|
||||
|
||||
> xcodebuild -sdk iphonesimulator6.0
|
||||
|
||||
这会在 Xcode 项目下创建一个 `build/Release-iphonesimulator` 目录,目录中包含 `.app` 包。你将使用这个包和 Appium server 沟通。
|
||||
这会在你的 Xcode 项目下创建一个 `build/Release-iphonesimulator` 目录。这个目录包含 `.app` 应用包。你就是用这个包和 Appium server 沟通。
|
||||
|
||||
如果需要,可以将应用程序目录压缩到 `.zip` 文件中!Appium 会帮你解压(如果你使用的不是局部的 Appium)。
|
||||
如果需要,可以将应用程序目录压缩到ZIP文件中!Appium 会帮你解压。
|
||||
|
||||
### 准备你要测试的应用(Android)
|
||||
|
||||
什么都不用做就可以使用 Appium 运行你的 .apk。如果你想,可以压缩它。
|
||||
你什么都不用做就可以在 Appium 上运行 apk。如果你想打包,随你。
|
||||
|
||||
### 准备你要测试的应用(Windows)
|
||||
什么都不用做就可以运行你的测试。
|
||||
你什么都不用做就可以在 Appium 上运行 Windows 应用。
|
||||
|
||||
|
||||
### 在 Appium 上运行你的测试应用(IOS)
|
||||
|
||||
想知道当前要做什么,最好的方法就是是查看示例代码:
|
||||
|
||||
[Node.js](https://github.com/appium/appium/tree/master/sample-code/javascript-webdriverio) | [Python](https://github.com/appium/appium/tree/master/sample-code/python) | [PHP](https://github.com/appium/appium/tree/master/sample-code/php) | [Ruby](https://github.com/appium/appium/tree/master/sample-code/ruby) | [Java](https://github.com/appium/appium/tree/master/sample-code/java)
|
||||
[Node.js](https://github.com/appium/sample-code/tree/master/sample-code/examples/node) | [Python](https://github.com/appium/sample-code/tree/master/sample-code/examples/python) | [PHP](https://github.com/appium/sample-code/tree/master/sample-code/examples/php) | [Ruby](https://github.com/appium/sample-code/tree/master/sample-code/examples/ruby) | [Java](https://github.com/appium/sample-code/tree/master/sample-code/examples/java)
|
||||
|
||||
基本上,首先确认 Appium 正在运行:
|
||||
基本上,首先确保 Appium 运行:
|
||||
|
||||
node .
|
||||
|
||||
然后编写你的 WebDriver 测试脚本, 用如下的预期能力(Desired capabilities):
|
||||
然后编写你的 WebDriver 测试脚本, 用如下的 desired capabilities:
|
||||
|
||||
```javascript
|
||||
// javascript
|
||||
@@ -74,53 +74,57 @@ capabilities.setCapability(MobileCapabilityType.APP, myApp);
|
||||
```
|
||||
|
||||
|
||||
在这组功能(capabilities)中,`myApp` 必须是以下的任意一个:
|
||||
在上面这一组 capabilities 里,`myApp` 必须是以下的任意一个:
|
||||
|
||||
* 基于对应模拟器编译的 .app 目录或者 zip 文件的绝对路径
|
||||
* app 应用包的 zip 文件的 URL
|
||||
* 基于 Appium 安装根目录的示例应用程序的相对路径
|
||||
|
||||
用你选择的 WebDriver 库,将远程会话(session)设置为使用以上功能,并连接到服务器所监听的 localhost 4723 (或任何在启动 Appium 时指定的主机和端口)。现在你应该全都设置好了!
|
||||
用你选择的 WebDriver (客户端)库,使用这些 capabilities 和本地的4723端口建立远程会话(或任何启动 Appium 时候指定的主机和端口)。现在你应该都设置好了!
|
||||
|
||||
### 使用 Appium 测试你的应用(Android)
|
||||
|
||||
首先,确保你有且只有一个 Android 模拟器或设备连接。例如,如果你运行 `adb devices`,你应该只看到一个设备连接。Appium 将使用这个设备进行测试。当然,要连接上一个设备,你需要配置一个 Android AVD。如果你的系统变量 `PATH` 里有 Android SDK 的工具,你可以简单运行如下命令:
|
||||
### 使用 Appium 测试你的应用 (Android)
|
||||
|
||||
首先,确保你有一个且只有一个 Android 模拟器或设备连接。例如,如果你运行 `adb devices`,
|
||||
你应该只看到一个设备连接。这个设备就是 Appium 用来测试的。当然, 要连接上一个设备,你需要配置一个 Android AVD (更多信息参考[Windows](https://github.com/appium/appium/blob/master/docs/en/appium-setup/running-on-windows.md),
|
||||
[Mac](https://github.com/appium/appium/blob/master/docs/en/appium-setup/running-on-osx.md),
|
||||
或者 [Linux](https://github.com/appium/appium/blob/master/docs/en/appium-setup/running-on-linux.md)))。如果你的系统变量 PATH 里有 Android SDK 的工具路径,你可以简单运行如下命令:
|
||||
|
||||
emulator -avd <MyAvdName>
|
||||
|
||||
等待 android 模拟器完成启动。有时,由于各种原因,`adb` 会卡住。如果它没有显示任何已连接的设备或其他故障,你可以重新启动它:
|
||||
等待 android 模拟器完成启动(可以去喝个咖啡)。有时,各种原因,`adb` 会卡住。如果不显示任何连接设备或否则失败,你可以通过运行以下命令重启它:
|
||||
|
||||
adb kill-server && adb devices
|
||||
|
||||
现在,确认 Appium 已在运行:
|
||||
现在,确认 Appium 运行起来:
|
||||
|
||||
node .
|
||||
|
||||
有几种方法可以启动一个 Appium 应用程序(工作原理与使用 adb 启动应用程序完全相同):
|
||||
有几种方法可以启动一个 Appium 应用程序(和使用 adb 启动一样):
|
||||
|
||||
- 仅用 apk 或 zip,将启动默认 activity('app' capability)
|
||||
- apk + activity ('app' + 'appActivity' capabilities)
|
||||
- apk + activity + intent ('app' + 'appActivity' + 'appIntent' capabilities)
|
||||
- 仅仅使用 apk 或者 zip,默认 activity 会被加载 ('app' capability)
|
||||
- apk + activity ('app' + 'appActivity' capabilities)
|
||||
- apk + activity + intent ('app' + 'appActivity' + 'appIntent' capabilities)
|
||||
- ...
|
||||
|
||||
Activity 可以通过以下方式指定:
|
||||
|
||||
- 绝对路径(例如 appActivity: 'com.helloworld.SayHello')。
|
||||
- 相对于应用包名(例如 appPackage: 'com.helloworld', appActivity='.SayHello')
|
||||
- absolute (比如 appActivity: 'com.helloworld.SayHello').
|
||||
- 相对于应用包名 (e.g. appPackage: 'com.helloworld', appActivity='.SayHello')
|
||||
|
||||
如果指定了 `appWaitPackage` 和 `appWaitActivity`,Appium 将自动等待,直到这些 Activity 启动。你可以指定等待多个Activity:
|
||||
如果指定 'appWaitPackage' 和 'appWaitActivity',Appium 会转菊花等待,直到这些 Activity 启动。您可以指定等待多个Activity。例如:
|
||||
|
||||
- appActivity: 'com.splash.SplashScreen'
|
||||
- appPackage: 'com.splash' appActivity: '.SplashScreen'
|
||||
- appPackage: 'com.splash' appActivity: '.SplashScreen,.LandingPage,com.why.GoThere'
|
||||
|
||||
如果你不确定你的 apk 中配置了哪些 Activity,你可以在下列方法中选一个进行查看:
|
||||
如果你不确定你的 apk 中配置的是哪个 Activity,你可以用下列方法:
|
||||
|
||||
- Mac / Linux:'adb shell dumpsys window windows | grep mFocusedApp'
|
||||
- 在 Ruby 控制台中:'adb shell dumpsys window windows\`.each_line.grep(/mFocusedApp/).first.strip'
|
||||
- 在 Windows 终端运行 'adb shell dumpsys window windows' 然后找到 mFocusedApp
|
||||
- Mac/Linux: 'adb shell dumpsys window windows | grep mFocusedApp'
|
||||
- 在Ruby控制台: 'adb shell dumpsys window windows\`.each_line.grep(/mFocusedApp/).first.strip'
|
||||
- 在Windows终端运行 'adb shell dumpsys window windows' 然后手动找到 mFocusedApp(坑爹,windows shell 下面不是有 findStr 么?)
|
||||
|
||||
然后编写 WebDriver 测试脚本,使用下面的预期功能:
|
||||
然后开始写 WebDriver 的测试脚本,使用下面的 desired capabilities:
|
||||
|
||||
```javascript
|
||||
// javascript
|
||||
@@ -165,19 +169,21 @@ capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator")
|
||||
capabilities.setCapability(MobileCapabilityType.APP, myApp);
|
||||
```
|
||||
|
||||
在这组功能(capabilities)中,`myApp` 必须是以下任意一个:
|
||||
在这组 capabilities 里,`myApp` 必须是以下任意一个:
|
||||
|
||||
* apk 或者 zip 文件的本地绝对路径
|
||||
* 包含 apk 的 zip 文件的 url 链接
|
||||
* 示例应用相对于 appium 安装根目录的路径
|
||||
* apk 或者 zip 文件的绝对路径
|
||||
* apk 的 zip 文件的 url 链接
|
||||
* 基于 appium 安装根目录的示例应用的相对路径
|
||||
|
||||
用你选择的 WebDriver 库,将远程会话(session)设置为使用以上功能,并连接到服务器所监听的 localhost 4723 (或任何在启动 Appium 时指定的主机和端口)。现在你应该全都设置好了!
|
||||
用你选择的 WebDriver (客户端)库,使用这些 capabilities 和本地的4723端口建立远程会话(或任何启动 Appium 时候指定的主机和端口)。现在你应该都设置好了!
|
||||
|
||||
### 使用 Appium 运行你的测试程序(Android 设备 < 4.3,和混合测试)
|
||||
### 使用 Appium 运行你的测试程序(Android设备& lt;4.2,混合应用)
|
||||
|
||||
Android 设备在 4.3 版本(API 级别 17)之前没有安装谷歌的 [UiAutomator 框架](http://developer.android.com/tools/testing-support-library/index.html#UIAutomator)。UiAutomator 是 Appium 用于在设备上执行自动化的部分。对于早期的设备或混合(基于 webview)应用程序,Appium 与另一个名为 [Selendroid](http://selendroid.io/) 自动化后端进行绑定。
|
||||
4.2版本之前的(API级别17)Android 没有集成谷歌的[UiAutomator framework](http://developer.android.com/tools/testing-support-library/index.html#UIAutomator)。
|
||||
Appium 使用 UiAutomator 来执行自动化。那么在早期的设备或混合(webview-based)应用程序,
|
||||
Appium 是与另一个自动化后台绑定 [Selendroid](http://selendroid.io/)。
|
||||
|
||||
要使用 Selendroid,只需稍微改动上述提到的预期功能(Desired capabilities),添加 `automationName` 并指定 Selendroid 为自动化后端。通常,你还需要在 activity 名前加一个 `.`(例如,对于 `appActivity` 这个功能需要使用 `.MainActivity` 替代 `MainActivity`)。
|
||||
要使用 Selendroid,只需稍微改动 desired capabilities,添加 `automationName` 并指定 Selendroid 为自动化后台。通常,你还需要在你的 activity 名字前加一个 `.`(如,`appActivity` 这个 capability 需要使用 `.MainActivity` 而不是 `MainActivity`)。
|
||||
|
||||
```javascript
|
||||
// javascript
|
||||
@@ -234,18 +240,14 @@ capabilities.setCapability(MobileCapabilityType.APP_PACKAGE: "com.mycompany.pack
|
||||
capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY: ".MainActivity");
|
||||
```
|
||||
|
||||
现在 Appium 将启动一个 Selendroid 测试会话,而不是默认的测试会话。使用 Selendroid 的缺点之一是,它的某些 API 和 Appium 有显著差异。因此,我们建议你在为旧设备或混合应用程序编写脚本前,彻读 [Selendroid文档](http://selendroid.io/native.html)
|
||||
现在 Appium 将启动一个 Selendroid 测试会话而不是默认的测试会话。
|
||||
使用 Selendroid 的缺点之一是,它的一些 API 和Appium 有着显著的差别。
|
||||
因此,我们建议你在为旧设备或混合应用程序编写脚本时,彻读(Selendroid文档)(http://selendroid.io/native.html)
|
||||
|
||||
### 使用 Appium 运行你的测试程序(Windows)
|
||||
###运行你的测试程序与Appium(Windows)
|
||||
|
||||
只需确保 Appium 正在监听,并使用你选择的测试运行器运行您的测试。
|
||||
只需确保 Appium 在监听,然后运行你的测试。
|
||||
|
||||
查看我们的 [示例](https://github.com/Microsoft/WinAppDriver/tree/master/Samples) 以获取细节。
|
||||
有关详细信息,请参阅我们的[samples](https://github.com/Microsoft/WinAppDriver/tree/master/Samples)。
|
||||
|
||||
---
|
||||
EOF.
|
||||
|
||||
本文由 [testly](https://github.com/testly) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
|
||||
翻译:@[Pandorym](https://github.com/Pandorym)
|
||||
Last english version: 04f65435618931f2d40977eec2f400d0bbec27d7, Jun 15, 2018
|
||||
本文由 [testly](https://github.com/testly) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -91,4 +91,4 @@ git clone https://github.com/snevesbarros/SafariLauncher.git
|
||||
}
|
||||
```
|
||||
|
||||
本文由 高鹏 翻译,由 lihuazhang 校验。
|
||||
本文由 [高鹏](https://testerhome.com/026) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -1,6 +1,6 @@
|
||||
# Appium 服务器参数
|
||||
# Appium服务器参数
|
||||
|
||||
许多 Appium 1.5 中的服务器参数已被弃用,取而代之使用的是 [-default-capabilities 标识](/docs/en/writing-running-appium/default-capabilities-arg.md) 。
|
||||
Appium v1.5里某些服务器参数已被弃用,取而代之使用的-default-capabilities 标志。
|
||||
|
||||
用法:node . [标志]
|
||||
|
||||
@@ -11,93 +11,86 @@
|
||||
|
||||
<expand_table>
|
||||
|
||||
|标志|默认|描述|示例|
|
||||
|----|----|----|----|
|
||||
|`--shell`|null| 进入 REPL 模式 ||
|
||||
|`--allow-cors`|false|打开 CORS 兼容模式,这将允许从托管在任何域中的网站内连接到 Appium 服务器。启用此功能时要小心,因为如果您访问的网站使用跨域请求,在 Appium 服务器上启动或运行内省会话,则可能存在安全风险。||
|
||||
|`--ipa`|null| (仅 iOS).ipa 文件的绝对路径 | `--ipa /abs/path/to/my.ipa` |
|
||||
|`-a`, `--address`|0.0.0.0| 监听的 ip 地址 | `--address 0.0.0.0` |
|
||||
|`-p`, `--port`|4723| 监听的端口 | `--port 4723` |
|
||||
|`-ca`, `--callback-address`|null| 回调 ip 地址 (默认:与 --address 相同) | `--callback-address 127.0.0.1` |
|
||||
|`-cp`, `--callback-port`|null| 回调端口(默认:与 --port 相同) | `--callback-port 4723` |
|
||||
|`-bp`, `--bootstrap-port`|4724| (仅 Android)设备跟 Appium 通信的端口 | `--bootstrap-port 4724` |
|
||||
|`-r`, `--backend-retries`|3| (仅 iOS)遇到 crash 或者超时,尝试重启Instruments的次数 | `--backend-retries 3` |
|
||||
|`--session-override`|false| 允许 session 覆盖(如有冲突)||
|
||||
|`-l`, `--pre-launch`|false| 首次建立session时预启动应用(iOS 需要 –app 参数,Android 需要 –app-pkg 和 –app-activity 参数)||
|
||||
|`-g`, `--log`|null| 将日志输出到指定文件 | `--log /path/to/appium.log` |
|
||||
|`--log-level`|debug| 为控制台和日志文件设置服务器日志等级(值为 `console-level:logfile-level`,如果只提供一个值,则两者相同)。可选的值为 `debug`、`info`、`warn`、`error`,并且越往后,日志越少。| `--log-level error:debug` |
|
||||
|`--log-timestamp`|false| 在终端输出中显示时间戳 ||
|
||||
|`--local-timezone`|false| 时间戳使用本地时区 ||
|
||||
|`--log-no-colors`|false| 终端输出不为彩色 ||
|
||||
|`-G`, `--webhook`|null| 同时发送日志输出到 HTTP 监听器 | `--webhook localhost:9876` |
|
||||
|`--safari`|false| (仅iOS)使用 safari 应用程序 ||
|
||||
|`--default-device`, `-dd`|false| (仅iOS模拟器)使用默认模拟器启动 Instruments ||
|
||||
|`--force-iphone`|false| (仅 iOS)不管应用程序指定什么设备,都强制使用 iPhone 模拟器||
|
||||
|`--force-ipad`|false| (仅 iOS)不管应用程序指定什么设备,都强制使用 iPad 模拟器||
|
||||
|`--tracetemplate`|null|(仅 iOS) 指定 Instruments 所使用的 .tracetemplate 文件 | `--tracetemplate /Users/me/Automation.tracetemplate` |
|
||||
|`--instruments`|null| (仅 iOS)Instruments 二进制文件的路径 | `--instruments /path/to/instruments` |
|
||||
|`--nodeconfig`|null| 指定 JSON 格式的配置文件,用于在 selenium grid 中注册 appium | `--nodeconfig /abs/path/to/nodeconfig.json` |
|
||||
|`-ra`, `--robot-address`|0.0.0.0| robot 的 IP 地址 | `--robot-address 0.0.0.0` |
|
||||
|`-rp`, `--robot-port`|-1| robot 的端口号 | `--robot-port 4242` |
|
||||
|`--selendroid-port`|8080| 用于和 Selendroid 通信的本地端口 | `--selendroid-port 8080` |
|
||||
|`--chromedriver-port`|9515| ChromeDriver 运行使用的端口 | `--chromedriver-port 9515` |
|
||||
|`--chromedriver-executable`|null| ChromeDriver 可执行文件的完整路径 ||
|
||||
|`--show-config`|false| 打印 appium 服务器的配置信息,然后退出 ||
|
||||
|`--no-perms-check`|false| 绕过Appium检查,确保我们可以读 / 写必要的文件||
|
||||
|`--strict-caps`|false| 如果所选设备不能被 appium 有效识别,则导致会话失败 ||
|
||||
|`--isolate-sim-device`|false| Xcode 6 在某些平台上存在存在一个 bug,想要正确启动某个模拟器,只能去删除掉所有其他模拟器。这个选项将导致了 Appium 删除除了正在使用的设备以外其他所有设备。请注意,这是永久性删除,你可以使用 simctl 或 xcode 管理被 Appium 使用的设备类别。 ||
|
||||
|`--tmp`|null| 目录的绝对路径将被 Appium 用于管理临时文件,比如存放需要移动的内置 iOS 应用程序。在 *nix / Mac 上默认为 /tmp,在 Windows 上默认为 C:\Windows\Temp ||
|
||||
|`--trace-dir`|null| appium 用于保存iOS instruments 轨迹的目录,是绝对路径,默认为 <tmp dir>/appium-instruments ||
|
||||
|`--debug-log-spacing`|false| 在日志中加大间距,帮助进行视觉检查||
|
||||
|`--suppress-adb-kill-server`|false| (仅 Android) 如果设置了,可以阻止 Appium 杀掉 adb 实例||
|
||||
|`--async-trace`|false| 向日志条目添加长堆栈追踪。建议仅在调试时使用 ||
|
||||
|`--webkit-debug-proxy-port`|27753|(仅 iOS)用于 ios-webkit-debug-proxy 通信的本地端口 | `--webkit-debug-proxy-port 27753` |
|
||||
|`-dc`, `--default-capabilities`|{}| 设置默认预期功能(Desired capabilities),每个会话都将使用默认预期功能,除非被新的功能覆盖 | `--default-capabilities [ '{"app": "myapp.app", "deviceName": "iPhone Simulator"}' | /path/to/caps.json ]` |
|
||||
|`--reboot`|false| - (仅 Android)每次建立会话都重启模拟器,会话结束后杀掉模拟器 ||
|
||||
|`--command-timeout`|60| 【弃用】- 没有效果。这曾是服务器用于所有会话接收命令的默认超时时间(单位是秒,但不超过 2147483)。预期能力(Desired capabilities)中的 newCommandTimeout 替代 ||
|
||||
|`-k`, `--keep-artifacts`|false| 【弃用】 - 没有效果。trace 现在默认位于 tmp 目录下,每次运行前都会清除。请查考 --trace-dir 标识 ||
|
||||
|`--platform-name`|null| 【弃用】 - 移动平台名称:iOS、Android 或 FirefoxOS | `--platform-name iOS`|
|
||||
|`--platform-version`|null| 【弃用】 - 移动平台的版本号 | `--platform-version 7.1` |
|
||||
|`--automation-name`|null| 【弃用】 - 自动化工具的名称: Appium 或 Selendroid | `--automation-name Appium` |
|
||||
|`--device-name`|null| 【弃用】 - 将使用的移动设备的名称 | `--device-name iPhone Retina (4-inch), Android Emulator` |
|
||||
|`--browser-name`|null| 【弃用】 - 移动浏览器的名称: Safari 或者 Chrome | `--browser-name Safari` |
|
||||
|`--app`|nul| 【弃用】 - IOS:基于模拟器编译的 .app 文件的绝对路径或者设备上目标的 BundleId; Android:.apk 文件的绝对路径 | `--app /abs/path/to/my.app` |
|
||||
|`-lt`, `--launch-timeout`|90000| 【弃用】 - (仅iOS) Instruments启动等待时间(单位:ms) ||
|
||||
|`--language`|null| 【弃用】 - iOS 模拟器 / Android 模拟器的语言 | `--language en` |
|
||||
|`--locale`|null| 【弃用】 - iOS 模拟器 / Android 模拟器的区域 | `--locale en_US` |
|
||||
|`-U`, `--udid`|null| 【弃用】 - 连接的物理设备的 udid | `--udid 1adsf-sdfas-asdf-123sdf` |
|
||||
|`--orientation`|null| 【弃用】 - (仅 iOS) 初始化请求时,使用 LANDSCAPE 或者 PORTRAIT | `--orientation LANDSCAPE` |
|
||||
|`--no-reset`|false| 【弃用】 - 会话(session)之间不重置应用状态(IOS: 不删除应用的 plist 文件;Android:在创建一个新的session前不删除应用) ||
|
||||
|`--full-reset`|false| 【弃用】 - (iOS)删除整个模拟器目录。(Android)通过卸载应用(而不是清除数据)重置应用状态。在 Android 中会话(session)完成后也会删除应用。 ||
|
||||
|`--app-pkg`|null| 【弃用】 - (仅 Android)想要运行的 apk 的 java 包(例如, com.example.android.myApp) | `--app-pkg com.example.android.myApp`|
|
||||
|`--app-activity`|null| 【弃用】 - (仅 Android)打开应用时,想要启动的 Activity 的名称(例如 MainActivity) | `--app-activity MainActivity` |
|
||||
|`--app-wait-package`|false| 【弃用】 - (仅 Andorid)想要等待的 activity 的包名(例如 com.example.android.myApp) | `--app-wait-package com.example.android.myApp` |
|
||||
|`--app-wait-activity`|false| 【弃用】 - (仅 Andorid)想要等待的 activity 名(例如 SplashActivity) | `--app-wait-activity SplashActivity` |
|
||||
|`--device-ready-timeout`|5| 【弃用】 - (仅 Andorid)等待设备准备就绪的超时时间(单位:秒)| `--device-ready-timeout 5` |
|
||||
|`--android-coverage`|false| 【弃用】 - (仅 Andorid)完全符合条件的 instrumentation 类,作为命令 adb shell am instrument -e coverage true -w 中的 -w 的参数 | `--android-coverage com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation` |
|
||||
|`--avd`|null| 【弃用】 - (仅 Andorid)要启动的安卓虚拟设备的名称 | `--avd @default` |
|
||||
|`--avd-args`|null| 【弃用】 - (仅 Andorid)启动安装虚拟设备时额外的模拟器参数 | `--avd-args -no-snapshot-load` |
|
||||
|`--use-keystore`|false| 【弃用】 - (仅 Andorid)设置 apk 签名的 keystore||
|
||||
|`--keystore-path`|<user>/.android/debug.keystore| 【弃用】 - (仅 Andorid)keystore 的路径 ||
|
||||
|`--keystore-password`|android| 【弃用】 - (仅 Andorid)keystore 的密码||
|
||||
|`--key-alias`|androiddebugkey| 【弃用】 - (仅 Andorid)key 的别名||
|
||||
|`--key-password`|android| 【弃用】 - (仅 Andorid)key 的密码 ||
|
||||
|`--intent-action`|android.intent.action.MAIN| 【弃用】 - (仅 Andorid)用于启动 activity 的 Intent action | `--intent-action android.intent.action.MAIN` |
|
||||
|`--intent-category`|android.intent.category.LAUNCHER| 【弃用】 - (仅 Andorid)用于启动 activity 的 Intent category | `--intent-category android.intent.category.APP_CONTACTS` |
|
||||
|`--intent-flags`| 0x10200000| 【弃用】 - (仅 Andorid)启动 activity 的标识 | `--intent-flags 0x10200000` |
|
||||
|`--intent-args`|null| 【弃用】 - (仅 Andorid)启动 activity 时附带额外的 intent 参数 | `--intent-args 0x10200000` |
|
||||
|`--dont-stop-app-on-reset`|false| 【弃用】 - (仅 Andorid)用于设置 appium 重启时是否先杀掉 app ||
|
||||
|`--calendar-format`|null| 【弃用】 - (仅 iOS)iOS 模拟器的日历格式 | `--calendar-format gregorian` |
|
||||
|`--native-instruments-lib`|false| 【弃用】 - (仅 iOS)iOS 内建了一个怪异的不可能避免的延迟,我们在Appium里修复了它,如果你想用原来的,你可以使用这个参数 ||
|
||||
|`--keep-keychains`|false| 【弃用】 - (仅 iOS) 当 Appium 启动或者关闭的时候,是否保留keychains(Library / Keychains) ||
|
||||
|`--localizable-strings-dir`|en.lproj| 【弃用】 - (仅 iOS)Localizable.strings 与目录的相对路径 | `--localizable-strings-dir en.lproj` |
|
||||
|`--show-ios-log`|false| 【弃用】 - (仅 iOS)如果设置了,iOS 系统日志将会输出到终端 ||
|
||||
|`--relaxed-security`|false|禁用额外的安全检查,因此可以使用支持此选项的驱动程序提供的某些高级功能。只有当所有客户端都位于可信任网络中,才启用它;如果客户端可能会突破会话沙箱,则不应该启用它。||
|
||||
| 标志 | 默认值 | 描述 | 示例 |
|
||||
| ------------------------------- | :------------------------------- | ---------------------------------------- | ---------------------------------------- |
|
||||
| `--shell` | 无 | 进入 REPL 模式 | |
|
||||
| `--ipa` | 无 | (仅iOS) .ipa 文件的绝对路径 | `--ipa /abs/path/to/my.ipa` |
|
||||
| `-a`, `--address` | 0.0.0.0 | 监听的 ip 地址 | `--address 0.0.0.0` |
|
||||
| `-p`, `--port` | 4723 | 监听的端口 | `--port 4723` |
|
||||
| `-ca`, `--callback-address` | 无 | 回调ip地址 (默认: 同 --address) | `--callback-address 127.0.0.1` |
|
||||
| `-cp`, `--callback-port` | 无 | 回调端口 (默认: 同 --port) | `--callback-port 4723` |
|
||||
| `-bp`, `--bootstrap-port` | 4724 | (仅安卓) 设备上跟 Appium通信的端口号 | `--bootstrap-port 4724` |
|
||||
| `-r`, `--backend-retries` | 3 | (仅iOS) 遇到crash或者超时,尝试重启Instruments的次数 | `--backend-retries 3` |
|
||||
| `--session-override` | false | 允许session覆盖 (如有冲突) | |
|
||||
| `-l`, `--pre-launch` | false | 首次建立session时预启动应用 (iOS 需要 –app参数,Android需要 –app-pkg和 –app-activity参数) | |
|
||||
| `-g`, `--log` | 无 | 将日志输出到指定文件 | `--log /path/to/appium.log` |
|
||||
| `--log-level` | debug | 日志等级;默认 (控制台[:file]): 调试[:debug] | `--log-level debug` |
|
||||
| `--log-timestamp` | false | 在终端输出里显示时间戳 | |
|
||||
| `--local-timezone` | false | 时间戳使用本地时区 | |
|
||||
| `--log-no-colors` | false | 终端输出不显示颜色 | |
|
||||
| `-G`, `--webhook` | 无 | 同时发送日志到 HTTP 监听器 | `--webhook localhost:9876` |
|
||||
| `--safari` | false | (仅iOS) 使用safari应用程序 | |
|
||||
| `--default-device`, `-dd` | false | (仅iOS模拟器) Instruments启动时使用的默认模拟器 | |
|
||||
| `--force-iphone` | false | (仅iOS) 不管应用程序指定什么设备,强制使用iPhone模拟器 | |
|
||||
| `--force-ipad` | false | (仅iOS) 不管应用程序指定什么设备,强制使用iPad模拟器 | |
|
||||
| `--tracetemplate` | 无 | (仅iOS) 指定Instruments所使用的.tracetemplate文件 | `--tracetemplate /Users/me/Automation.tracetemplate` |
|
||||
| `--instruments` | 无 | (仅iOS) Instruments二进制文件路径 | `--instruments /path/to/instruments` |
|
||||
| `--nodeconfig` | 无 | 指定 JSON格式的配置文件,用来在selenium grid里注册appium | `--nodeconfig /abs/path/to/nodeconfig.json` |
|
||||
| `-ra`, `--robot-address` | 0.0.0.0 | robot使用的IP地址 | `--robot-address 0.0.0.0` |
|
||||
| `-rp`, `--robot-port` | -1 | robot使用的端口号 | `--robot-port 4242` |
|
||||
| `--selendroid-port` | 8080 | 用于和Selendroid通信的本地端口 | `--selendroid-port 8080` |
|
||||
| `--chromedriver-port` | 9515 | ChromeDriver 运行使用的端口 | `--chromedriver-port 9515` |
|
||||
| `--chromedriver-executable` | 无 | ChromeDriver可执行文件的路径 | |
|
||||
| `--show-config` | false | 打印appium服务器的配置信息,然后退出 | |
|
||||
| `--no-perms-check` | false | 绕过Appium检查,确保用户可读/写必要的文件 | |
|
||||
| `--strict-caps` | false | 如果所选设备是appium不承认的有效设备,会导致会话失败 | |
|
||||
| `--isolate-sim-device` | false | Xcode 6存在一个bug,那就是一些平台上如果其他模拟器设备先被删除时某个特定的模拟器只能在没有任何错误的情况下被建立。这个选项导致了Appium不得不删除除了正在使用设备以外其他所有的设备。请注意这是永久性删除,你可以使用simctl或xcode管理被Appium使用的设备类别。 | |
|
||||
| `--tmp` | 无 | 可以被Appium用来管理临时文件的目录(绝对路径),比如存放需要移动的内置iOS应用程序。在*nix/Mac上默认为 /tmp,在Windows上默认为 C:\Windows\Temp | |
|
||||
| `--trace-dir` | 无 | 用于保存iOS instruments trace的 appium 目录,是绝对路径, 默认为/appium-instruments | |
|
||||
| `--debug-log-spacing` | false | 在日志中加大间距来帮助进行视觉检查 | |
|
||||
| `--suppress-adb-kill-server` | false | (仅安卓) 如果设置了,可以阻止Appium杀掉adb实例 | |
|
||||
| `--async-trace` | false | 添加长堆栈追踪到日志实体,建议仅调试时选用 | |
|
||||
| `--webkit-debug-proxy-port` | 27753 | (仅iOS) 用于ios-webkit-debug-proxy通信的本地端口 | `--webkit-debug-proxy-port 27753` |
|
||||
| `-dc`, `--default-capabilities` | {} | 设置默认desired capabilities,每个会话都将使用默认desired capabilities,除非被新的capabilities覆盖 | `--default-capabilities [ '{"app": "myapp.app", "deviceName": "iPhone Simulator"}' | /path/to/caps.json ]` |
|
||||
| `--reboot` | false | - (仅安卓) 每次建立会话重启模拟器,会话结束后杀掉模拟器 | |
|
||||
| `--command-timeout` | 60 | [弃用] 默认所有会话接收命令的超时时间 (单位是秒,但不超过2147483秒)。已被newCommandTimeout关键字替代 | |
|
||||
| `-k`, `--keep-artifacts` | false | [弃用] - 保留Instruments trace目录,请参考--trace-dir标志 | |
|
||||
| `--platform-name` | 无 | [弃用] -移动平台名称: iOS,Android或 FirefoxOS | `--platform-name iOS` |
|
||||
| `--platform-version` | 无 | [弃用] - 移动平台的版本号 | `--platform-version 7.1` |
|
||||
| `--automation-name` | 无 | [弃用] - 自动化工具的名称: Appium 或 Selendroid | `--automation-name Appium` |
|
||||
| `--device-name` | 无 | [弃用] - 要使用的移动设备的名称 | `--device-name iPhone Retina (4-inch), Android Emulator` |
|
||||
| `--browser-name` | 无 | [弃用] - 移动浏览器的名称: Safari 或者 Chrome | `--browser-name Safari` |
|
||||
| `--app` | 无 | [弃用] - IOS: 基于模拟器编译的.app文件的绝对路径或者设备上目标的BundleId; Android: .apk文件的绝对路径 | `--app /abs/path/to/my.app` |
|
||||
| `-lt`, `--launch-timeout` | 90000 | [弃用] - (仅iOS) Instruments启动等待时间(单位: ms) | |
|
||||
| `--language` | 无 | [弃用] -iOS模拟器/Android模拟器的语言 | `--language en` |
|
||||
| `--locale` | 无 | [弃用] -iOS模拟器/Android模拟器的区域 | `--locale en_US` |
|
||||
| `-U`, `--udid` | 无 | [弃用] - 连接的物理设备的udid | `--udid 1adsf-sdfas-asdf-123sdf` |
|
||||
| `--orientation` | 无 | [弃用] - (仅iOS) 初始化请求时,使用LANDSCAPE或者PORTRAIT | `--orientation LANDSCAPE` |
|
||||
| `--no-reset` | false | [弃用] - session之间不充值应用状态 (IOS: 不删除应用的 plist 文件;Android: 在创建一个新的session前不删除应用。) | |
|
||||
| `--full-reset` | false | [弃用] - (iOS) 删除整个模拟器目录。 (Android) 通过卸载应用(而不是清楚数据)重置应用状态。在Android上session完成后也会删除应用。 | |
|
||||
| `--app-pkg` | 无 | [弃用] - (仅安卓) 想要运行的apk的java包 (例如, com.example.android.myApp) | `--app-pkg com.example.android.myApp` |
|
||||
| `--app-activity` | 无 | [弃用] - (仅安卓) 打开应用时,想要启动的Activity的名称(例如 MainActivity) | `--app-activity MainActivity` |
|
||||
| `--app-wait-package` | false | [弃用] - (仅安卓) 想要等待的activity的包名 (例如 com.example.android.myApp) | `--app-wait-package com.example.android.myApp` |
|
||||
| `--app-wait-activity` | false | [弃用] - (仅安卓) 想要等待的activity名(例如 SplashActivity) | `--app-wait-activity SplashActivity` |
|
||||
| `--device-ready-timeout` | 5 | [弃用] - (仅安卓) 等待设备准备就绪的时间(单位: 秒) | `--device-ready-timeout 5` |
|
||||
| `--android-coverage` | false | [弃用] - (仅安卓) 完全符合条件的instrumentation类,作为命令 adb shell am instrument -e coverage true -w 的 -w 的参数 | `--android-coverage com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation` |
|
||||
| `--avd` | 无 | [弃用] - (仅安卓) 要启动的avd的名称 | `--avd @default` |
|
||||
| `--avd-args` | 无 | [弃用] - (仅安卓) 启动avd时额外的模拟器参数 | `--avd-args -no-snapshot-load` |
|
||||
| `--use-keystore` | false | [弃用] - (仅安卓) 设置签名apk的keystore | |
|
||||
| `--keystore-path` | <user>/.android/debug.keystore | [弃用] - (仅安卓) keystore 的路径 | |
|
||||
| `--keystore-password` | android | [弃用] - (仅安卓) keystore的密码 | |
|
||||
| `--key-alias` | androiddebugkey | [弃用] - (仅安卓) Key的别名 | |
|
||||
| `--key-password` | android | [弃用] - (仅安卓) Key 的密码 | |
|
||||
| `--intent-action` | android.intent.action.MAIN | [弃用] - (仅安卓) 用于启动activity的Intent action | `--intent-action android.intent.action.MAIN` |
|
||||
| `--intent-category` | android.intent.category.LAUNCHER | [弃用] - (仅安卓) 用于启动activity的Intent category | `--intent-category android.intent.category.APP_CONTACTS` |
|
||||
| `--intent-flags` | 0x10200000 | [弃用] - (仅安卓) 启动activity的标志 | `--intent-flags 0x10200000` |
|
||||
| `--intent-args` | 无 | [弃用] - (仅安卓)启动activity时附带额外的intent参数 | `--intent-args 0x10200000` |
|
||||
| `--dont-stop-app-on-reset` | false | [弃用] - (仅安卓) 用于设置appium重启时是否先杀掉app | |
|
||||
| `--calendar-format` | 无 | [弃用] - (仅iOS) iOS模拟器的日历格式 | `--calendar-format gregorian` |
|
||||
| `--native-instruments-lib` | false | [弃用] - (仅iOS) iOS 内建了一个怪异的不可能避免的延迟,我们在Appium里修复了它,如果你想用原来的,你可以使用这个参数 | |
|
||||
| `--keep-keychains` | false | [弃用] - (仅iOS) 当Appium启动或者关闭的时候,是否保留keychains(Library/Keychains) | |
|
||||
| `--localizable-strings-dir` | en.lproj | [弃用] - (仅iOS)定位.strings所在目录的相对路径 | `--localizable-strings-dir en.lproj` |
|
||||
| `--show-ios-log` | false | [弃用] - (仅iOS) 如果设置了,iOS系统日志会输出到终端 | |
|
||||
|`--enable-heapdump`|false|激活 NodeJS 内存 dumps 收集功能。这个功能对找到内存泄露非常有用。用 'kill -SIGUSR2 <PID>' 命令来创建 node 进程的内存堆栈dump,只有在 *nix 系统有效。dump 文件会被创建在 appium 运行的目录,文件使用 *.heapsnapshot 做后缀。如果后续想要深入研究,这个快照可以被加载到 Chrome Inspector 里去。参加 [Rising Stack article](https://blog.risingstack.com/finding-a-memory-leak-in-node-js/) for more details.||
|
||||
|
||||
---
|
||||
EOF.
|
||||
|
||||
本文由 [testly](https://github.com/testly) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
|
||||
翻译:@[Pandorym](https://github.com/Pandorym)
|
||||
Last english version: 1d2f4d62ac83cc37eae848c0067722d5727863da, May 10, 2019
|
||||
本文由 [testly](https://github.com/testly) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -1,19 +1,17 @@
|
||||
## 移动手势的自动化
|
||||
|
||||
尽管 Selenium WebDriver 的规范已经支持了一些移动交互,但它的参数并不总是能轻易映射到底层设备的自动化框架所提供的方法上(比如 iOS 上的 UIAutomation)。为此,Appium 在最新的规范([https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html#multiactions-1](https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html#multiactions-1))
|
||||
中实现了新的触摸操作和多点触控 API。注意,这与早期版本中原始的 JSON Wire 协议里的触摸操作 API 不同。
|
||||
尽管 Selenium WebDriver 的规范已经支持了一些移动交互,但它的参数并不总是那么容易地
|
||||
映射到底层设备的自动化框架所提供的方法上(比如 iOS 上的 UIAutomation)。为此,Appium 在最新的规范([https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html#multiactions-1](https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html#multiactions-1))
|
||||
中实现了新的触摸操作和多重操作 API。
|
||||
|
||||
这些 API 允许你使用多个执行器去建立任意的手势。请查看对应语言的 Appium 客户端文档来查看使用这些 API 的示例。
|
||||
注意,这与早期版本中原始的 JSON Wire 协议里的触摸操作 API 不同。
|
||||
|
||||
**W3C 操作的注意事项**
|
||||
这些 API 允许你使用多个执行器去建立任意的手势。
|
||||
请查看对应语言的 Appium 客户端文档来查看使用这些 API 的示例。
|
||||
|
||||
某些驱动也可以使用[W3C 操作](https://www.w3.org/TR/webdriver1/#actions),例如 XCUITest、UIA2、Espresso 和 Windows。W3C 操作是在操作系统测试框架的最大限制下实现的。例如 WDA 无法处理零等待 [PR](https://github.com/appium/appium-xcuitest-driver/pull/753)。
|
||||
### 触摸操作(TouchAction)/多重操作(MultiAction) API 概述
|
||||
|
||||
[API 文档](http://appium.io/docs/en/commands/interactions/actions/)(English),及每个客户端的 API文档可以帮助理解如何调用它们。
|
||||
|
||||
### 触摸操作(TouchAction) / 多点触控(MultiAction) API 概述
|
||||
|
||||
### 触摸操作(TouchAction)
|
||||
### 触摸操作(TouchAction)
|
||||
|
||||
*TouchAction* 对象包含一连串的事件。
|
||||
|
||||
@@ -37,25 +35,36 @@ TouchAction().press(el0).moveTo(el1).release()
|
||||
|
||||
上述模拟了一个用户按下一个元素,滑动他的手指到另一个位置,然后将他的手指从屏幕上移开。
|
||||
|
||||
Appium按顺序执行这一些列事件。你可以添加 `wait` 事件来控制事件的时长。
|
||||
|
||||
`moveTo` 的坐标现在与当前位置是 *绝对关系* 。例如,从 100,100 拖拽到 200,200 可以这样实现:
|
||||
Appium按顺序执行这些事件。你可以添加`wait`事件来控制事件的时长。
|
||||
|
||||
`moveTo` 的坐标与当前的位置*相关*。举例来说,从 100,100 拖拽到 200,200 可以这样实现:
|
||||
```
|
||||
.press(100,100) // 从 100,100 开始
|
||||
.moveTo(200,200) // 通过绝对值 200,200,在 200,200 结束
|
||||
.moveTo(100,100) // 分别给X和Y坐标增加100,在 200,200 结束
|
||||
|
||||
```
|
||||
|
||||
Appium 客户端库有不同的实现方式,例如:你可以传递坐标或一个元素给 `moveTo` 事件。当坐标 _和_ 元素一起传递时,该坐标被理解为是相对于元素位置的相对坐标,而不是绝对位置。
|
||||
Appium 客户端库有不同的实现方式,举例来说:你可以传递坐标或元素给 `moveTo` 事件。当坐标
|
||||
和元素一起传递时,该坐标是相对于元素位置的相对坐标,而不是相对于当前位置。
|
||||
|
||||
调用 `perform` 事件发送全部的事件序列给 appium,触摸手势将在你的设备上执行。
|
||||
调用 `perform` 事件发送全部的事件序列给 appium,触摸手势就会在你的设备上执行。
|
||||
|
||||
### 多点触控(MultiTouch)
|
||||
Appium客户端也允许通过 driver 对象直接执行触摸操作,而不是在触摸操作对象上调用 `perform`
|
||||
事件。
|
||||
|
||||
*MultiTouch* 对象是触摸操作的集合。
|
||||
在伪代码里,以下两者是相等的:
|
||||
|
||||
多点触控手势只有两个方法,`add` 和 `perform`。
|
||||
```center
|
||||
TouchAction().tap(el).perform()
|
||||
|
||||
driver.perform(TouchAction().tap(el))
|
||||
```
|
||||
|
||||
### 多点触控(MultiTouch)
|
||||
|
||||
*MultiTouch*对象是触摸操作的集合。
|
||||
|
||||
多点触控手势只有两个方法,`add`和`perform`。
|
||||
|
||||
`add` 用于将不同的触摸操作添加到当前的多点触控中。
|
||||
|
||||
@@ -72,13 +81,14 @@ MultiAction().add(action0).add(action1).perform()
|
||||
|
||||
### 缺陷与解决方法
|
||||
|
||||
不幸的是,在iOS 7.0 - 8.x 的模拟器上存在着一个缺陷,ScrollViews、CollectionViews 和 TableViews 不能识别由 UIAutomation( Appium 在 iOS 底层所使用的框架)所创建的手势。为了解决这个问题,我们提供了一个不同的入口函数 `scroll`,在大多数情况下,它能让你对 view 执行你想要执行的操作,即滚动它!
|
||||
不幸的是,在iOS 7.0 - 8.x 的模拟器上存在着一个缺陷,ScrollViews、CollectionViews和TableViews不能识别 UIAutomation(Appium在iOS底层所使用的框架)所创建的手势。为了避免这些,我们已经提供了一个可用的新函数 `scroll`,它在大多数情况下能让你完成你想在这些 view 中的任意一个上去做的事,也就是,滚动它!
|
||||
|
||||
|
||||
**滚动**
|
||||
|
||||
|
||||
为了允许使用这个特殊的手势,我们重写了驱动程序的 `execute` 和 `executeScript` 方法,并且给命令加上了 `mobile: ` 前缀。
|
||||
为了允许使用这个特殊的手势,我们重写了 driver 的 `execute` 和 `executeScript` 方法,并且给命令
|
||||
加上 `mobile: ` 前缀。
|
||||
看下面的示例:
|
||||
|
||||
为了进行滚动,将你想滚动的方向作为参数传入。
|
||||
@@ -160,9 +170,10 @@ $driver->executeScript("mobile: scroll", $params);
|
||||
|
||||
**Swiping**
|
||||
|
||||
在 XCUITest 驱动上有一个特别的方法,它和 scrolling 类似。(见 https://developer.apple.com/reference/xctest/xcuielement)。
|
||||
在 XCUITest 驱动上有一个特别的方法,和 scrolling 类似。(见
|
||||
https://developer.apple.com/reference/xctest/xcuielement)。
|
||||
|
||||
这个方法和 [Scrolling](#scrolling) 的 API 一致,只需用 "mobile: swipe" 替换 "mobile: scroll"。
|
||||
这个方法的名字和 [Scrolling](#scrolling)的 API 一样,只要用 "mobile: swipe" 替换 "mobile: scroll"。
|
||||
|
||||
**滑块的自动化**
|
||||
|
||||
@@ -181,12 +192,6 @@ slider.sendKeys("0.1");
|
||||
|
||||
**Android**
|
||||
|
||||
在Android上与滑块交互的最佳方式是使用触摸操作(TouchActions)。
|
||||
在Android上与滑块交互的最佳方式是使用触摸操作。
|
||||
|
||||
---
|
||||
EOF.
|
||||
|
||||
本文由 [NativeZhang](https://github.com/NativeZhang) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
|
||||
翻译:@[Pandorym](https://github.com/Pandorym)
|
||||
Last english version: 8c15ac66f18659974c31019ba1cdcd09cb25a275, Mar 12, 2019
|
||||
本文由 [NativeZhang](https://github.com/NativeZhang) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||
@@ -1,164 +0,0 @@
|
||||
## 自动化混合应用
|
||||
|
||||
Appium 的核心理念之一是,你不应该为了测试而改变被测的应用程序。在这种理念中,可以使用像 Selenium 测试 Web 应用的方式去测试混合应用。Appium 需要知道你是想自动化应用的原生部分还是 Web 视图,这在技术上有一点复杂。但值得庆幸的是,我们可以继续使用 Selenium WebDriver 做所有的事。
|
||||
|
||||
一旦测试处于 Web 视图上下文之中,所有 [Selenium](http://www.seleniumhq.org/) [WebDriver API](http://www.seleniumhq.org/docs/03_webdriver.jsp) 指令集都是可用的。
|
||||
|
||||
|
||||
### 进入 Web 视图上下文(context)
|
||||
|
||||
在你的 Appium 测试中,以下是与 Web 视图通信所必须的几个步骤:
|
||||
|
||||
1. 导航到你的应用程序中的 Web 视图的部分
|
||||
1. [取得当前可用的上下文](/docs/en/commands/context/get-contexts.md)(English)
|
||||
* 这将返回一个包含我们可以访问的上下文的列表,例如 `'NATIVE_APP'` 或 `'WEBVIEW_1'`
|
||||
1. 使用想要访问的上下文的 id [设置上下文](/docs/en/commands/context/set-context.md)(English)
|
||||
* 这会使你的 Appium 会话进入一个模式,处于该模式时所有命令被解释为意图自动化 Web 视图,而不是应用程序的原生部分。例如,如果你运行 `getElementByTagName`,它将操作 Web 视图中的 DOM,而不是返回原生元素。当然,某些 WebDriver 方法只在一个或另一个上下文中有效,所以在错误的上下文中执行时你会收到一个报错信息。
|
||||
1. 想要停止对 Web 视图的上下文中自动化,并返回到应用程序的原生部分,简单的 [设置上下文](/docs/en/commands/context/set-context.md) (English)即可。将上下文赋值为原生上下文的 id(通常是 `'NATIVE_APP'`)便可离开 Web 上下文,重新使用原生指令。
|
||||
|
||||
### 在会话(session)开启时自动进入 Web 视图上下文(context)
|
||||
如果你的应用程序在 web 视图中开始,并且你不想在自动化应用程序的原生部分后,再进入 Web 视图,你可以通过设置「[预期功能(desired capability)](/docs/en/writing-running-appium/caps.md)」中的 `autoWebview` 为 `true` 使得 Appium 在会话初始化时自动进入 Web 视图上下文。
|
||||
|
||||
|
||||
### 示例
|
||||
|
||||
```javascript
|
||||
// javascript
|
||||
// 假定我们已经为这个应用程序初始化了 `driver` 对象
|
||||
driver
|
||||
.contexts().then(function (contexts) { // get list of available views. Returns array: ["NATIVE_APP","WEBVIEW_1"]
|
||||
return driver.context(contexts[1]); // choose the webview context
|
||||
})
|
||||
|
||||
// 执行一些 web 测试
|
||||
.elementsByCss('.green_button').click()
|
||||
|
||||
.context('NATIVE_APP') // leave webview context
|
||||
|
||||
// 如果你想,可以在这做一些原生操作
|
||||
|
||||
.quit() // stop webdrivage
|
||||
```
|
||||
|
||||
```java
|
||||
// java
|
||||
// 假定我们设置了 capabilities
|
||||
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
|
||||
|
||||
Set<String> contextNames = driver.getContextHandles();
|
||||
for (String contextName : contextNames) {
|
||||
System.out.println(contextName); //prints out something like NATIVE_APP \n WEBVIEW_1
|
||||
}
|
||||
driver.context(contextNames.toArray()[1]); // set context to WEBVIEW_1
|
||||
|
||||
// 执行一些 web 测试
|
||||
String myText = driver.findElement(By.cssSelector(".green_button")).click();
|
||||
|
||||
driver.context("NATIVE_APP");
|
||||
|
||||
// 如果你想,可以在这做一些原生操作
|
||||
|
||||
driver.quit();
|
||||
```
|
||||
|
||||
```ruby
|
||||
# ruby_lib_core
|
||||
# 假定我们设置了 capabilities
|
||||
@driver = Appium::Core.for(url: SERVER_URL, desired_capabilities: capabilities).start_driver
|
||||
# ruby_lib
|
||||
# opts = { caps: capabilities, appium_lib: { custom_url: SERVER_URL }}
|
||||
# @driver = Appium::Driver.new(opts, true).start_driver
|
||||
|
||||
# 我切换到了最后一个上下文,因为在我们的示例中它总是 webview,在其他情况下,您可能需要明确指定一个上下文
|
||||
# 在运行 @driver.contexts 期间,查看 appium 日志确定想要的上下文,并找到关联的 ID
|
||||
# 使用 @driver.switch_to.context("WEBVIEW_6") 切换到想要的上下文
|
||||
|
||||
Given(/^I switch to webview$/) do
|
||||
webview = @driver.available_contexts.last
|
||||
@driver.switch_to.context(webview)
|
||||
end
|
||||
|
||||
Given(/^I switch out of webview$/) do
|
||||
@driver.switch_to.context(@driver.contexts.first)
|
||||
end
|
||||
|
||||
# 现在使用 CSS 选择器在你的 webview 中选择一个元素
|
||||
|
||||
And(/^I click a webview button $/) do
|
||||
@driver.find_element(:css, ".green_button").click
|
||||
end
|
||||
```
|
||||
|
||||
```python
|
||||
# python
|
||||
# 假定我们已经为这个应用程序初始化了 `driver` 对象
|
||||
|
||||
# 切换到 webview
|
||||
webview = driver.contexts.last
|
||||
driver.switch_to.context(webview)
|
||||
|
||||
# 执行一些 web 测试
|
||||
driver.find_element(:css, ".green_button").click
|
||||
|
||||
# 切换回原生视图
|
||||
driver.switch_to.context(driver.contexts.first)
|
||||
|
||||
# 如果你想,可以在这做一些原生操作
|
||||
|
||||
driver.quit()
|
||||
```
|
||||
|
||||
```php
|
||||
// php
|
||||
// 假定我们已经在这个AppiumTestCase中初始化了 `driver` 对象
|
||||
public function testThings()
|
||||
{
|
||||
$expected_contexts = array(
|
||||
0 => 'NATIVE_APP',
|
||||
1 => 'WEBVIEW_1'
|
||||
);
|
||||
|
||||
$contexts = $this->contexts();
|
||||
$this->assertEquals($expected_contexts, $contexts);
|
||||
|
||||
$this->context($contexts[1]);
|
||||
$context = $this->context();
|
||||
$this->assertEquals('WEBVIEW_1', $context);
|
||||
|
||||
// 做一些关于 web 的事
|
||||
|
||||
$this->context('NATIVE_APP');
|
||||
|
||||
// 做一些关于原生的事
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 自动化 Android 的混合应用
|
||||
|
||||
Appium [通过 Chromedriver 内建的混合应用支持](/docs/en/writing-running-appium/web/chromedriver.md),使得任何 Chrome 支持的 Android Web 视图都可以自动化。在设备版本旧于 4.4 的设备上 Appium 仍然可以使用 [Selendroid](http://selendroid.io/) 提供对 webview 的支持(在这种情况下,需要在预期功能中指定 `"automationName": "selendroid"`)。
|
||||
|
||||
不幸的是,你必须在构建应用程序时做额外的一步。正如 Android [远程调试文档](https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews) 中所述,必须设置 [android.webkit.WebView](http://developer.android.com/reference/android/webkit/WebView.html) 元素的 [setWebContentsDebuggingEnabled](http://developer.android.com/reference/android/webkit/WebView.html#setWebContentsDebuggingEnabled(boolean)) 属性设置为 `true`。
|
||||
|
||||
一旦你设置了 [「预期功能(desired capabilities)」](/docs/en/writing-running-appium/caps.md)并开启了 Appium 会话,请遵循上面的通用说明。
|
||||
|
||||
### 自动化 iOS 的混合应用
|
||||
|
||||
Appium 使用自定义的远程调试器建立连接去与 web 视图交互。当 Appium 和模拟器和在同一台机器且对模拟器执行时,此链接直接建立到模拟器。Appium 可以自动化 [WkWebView](https://developer.apple.com/documentation/webkit/wkwebview) 和 [UIWebView](https://developer.apple.com/documentation/uikit/uiwebview) 元素。不幸的是,目前还不能处理 [SafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) 元素。
|
||||
|
||||
一旦你设置了 [「预期功能(desired capabilities)」](/docs/en/writing-running-appium/caps.md)并开启了 Appium 会话,请遵循上面的通用说明。
|
||||
|
||||
#### 对真实的 iOS 设备执行
|
||||
|
||||
当对真实的 iOS 设备执行时,Appium 不能直接访问 web 试图。所以必须通过 USB 线缆连接设备。我们使用 [ios-webkit-debugger-proxy](https://github.com/google/ios-webkit-debug-proxy) 建立连接。
|
||||
|
||||
关于如何安装并运行 `ios-webkit-debugger-proxy` 的教学,请查看 [iOS webkit 调试代理](/writing-running-appium/web/ios-webkit-debug-proxy.md) 文档
|
||||
|
||||
现在你可以开启 Appium 测试会话,并遵循上面的通用说明。
|
||||
|
||||
---
|
||||
EOF.
|
||||
|
||||
翻译:@[Pandorym](https://github.com/Pandorym)
|
||||
Last english version: 465efb481ddda084e068bc7a314e0edeaeb5f123, Apr 9, 2019
|
||||
@@ -0,0 +1,67 @@
|
||||
# Windows 应用的 UI 测试
|
||||
|
||||
在 Appium 中,Windows 应用的 UI 测试是由 [WinAppDriver](https://github.com/Microsoft/WinAppDriver) 支持的,Appium 在下载安装的时候已经带了这部分。
|
||||
|
||||
## Java 示例
|
||||
1. 在 Java IDE (比如 IntelliJ)中打开包含示例项目工程的目录,如:[CalculatorTest](https://github.com/Microsoft/WinAppDriver/tree/master/Samples/Java/CalculatorTest)
|
||||
2. 在 Java IDE 中 build 并运行这个测试脚本
|
||||
|
||||
## C# 示例
|
||||
1. 拉取并打开 [CalculatorTest](https://github.com/Microsoft/WinAppDriver/tree/master/Samples/C%23/CalculatorTest) 目录下的文件 `CalculatorTest.sln`
|
||||
2. 在 Visual Studio 2015 中打开 test solution,然后 build 这个测试脚本并选择 **Test > Run > All Tests**
|
||||
|
||||
## 特性
|
||||
Windows Application Driver 支持测试 **Windows 10 PC** 上的**Universal Windows Platform (UWP)** 及 **Classic Windows (Win32)** 应用。
|
||||
|
||||
## 创建你的测试脚本
|
||||
你可以使用任意一个 Appium 或 Selenium 支持的编程语言来编写测试脚本,在下面的例子中,我们会使用 C# 在 **Microsoft Visual Studio 2015** 编写测试脚本。
|
||||
|
||||
## 创建测试项目工程
|
||||
1. 打开 **Microsoft Visual Studio 2015**
|
||||
2. 创建 test project 和 solution。选择 **New Project > Templates > Visual C# > Test > Unit Test Project**
|
||||
3. 创建好之后,打开 **Project > Manage NuGet Packages... > Browse** ,并搜索 **Appium.WebDriver**
|
||||
4. 为当前的 test project 安装 **Appium.WebDriver**
|
||||
5. 接下来就可以编写测试脚本了(可参考 [samples](https://github.com/appium/sample-code/tree/master/sample-code/examples/C%23/CalculatorTest) 目录下的示例代码)。
|
||||
|
||||
## Universal Windows Platform 应用的测试
|
||||
你可以使用 Selenium 支持的编程语言来编写脚本来测试 UWP 应用,通过 **app capabilities entry**,可以对测试的 app 找到它的 **Application Id**。下面是一个用 C# 编写的例子,主要是为 Windows 上的 **Alarms & Clock app** 创建一个测试 session:
|
||||
|
||||
```c#
|
||||
// Launch the AlarmClock app
|
||||
DesiredCapabilities appCapabilities = new DesiredCapabilities();
|
||||
appCapabilities.SetCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App");
|
||||
AlarmClockSession = new IOSDriver<IOSElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);
|
||||
// Control the AlarmClock app
|
||||
AlarmClockSession.FindElementByAccessibilityId("AddAlarmButton").Click();
|
||||
AlarmClockSession.FindElementByAccessibilityId("AlarmNameTextBox").Clear();
|
||||
```
|
||||
在测试自己的应用时,你可以在项目工程下生成的文件 `AppX\vs.appxrecipe` 中找到该应用的 **Application id**,如:```c24c8163-548e-4b84-a466-530178fc0580_scyf5npe3hv32!App```,这个文件位于 RegisteredUserNmodeAppID 节点下。
|
||||
|
||||
### Classic Windows 应用的测试
|
||||
同样的,你可以使用任意一门 Selenium 支持的编程语言来编写对 Classic Windows 应用的测试脚本,并在 app capabilities entry 中指定该应用的**绝对路径**。下面的例子是对 Windows 系统下的应用 **Notepad** 创建一个测试 session:
|
||||
|
||||
```c#
|
||||
// Launch Notepad
|
||||
DesiredCapabilities appCapabilities = new DesiredCapabilities();
|
||||
appCapabilities.SetCapability("app", @"C:\Windows\System32\notepad.exe");
|
||||
NotepadSession = new IOSDriver<IOSElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);
|
||||
// Control the AlarmClock app
|
||||
NotepadSession.FindElementByClassName("Edit").SendKeys("This is some text");
|
||||
```
|
||||
|
||||
### 启动 Session
|
||||
注意你需要额外使用下面的这些 capabilities 来确保可以获得 Windows App automation session:
|
||||
|
||||
`platformName`: `Windows`
|
||||
`deviceName`: `WindowsPC`
|
||||
|
||||
### 定位 UI 元素
|
||||
**Microsoft Visual Studio 2015** 已经默认包含了 Windows SDK,这些 SDK 提供了足够好的用于对你测试的应用进行分析的工具。这类工具能够让你利用 Windows Application Driver 来查看那些你可以找到的 UI 元素或节点。你可以在 Windows SDK 目录(如`C:\Program Files (x86)\Windows Kits\10\bin\x86`)下找到 **inspect.exe** 这个工具。
|
||||
|
||||
| 定位方法 | 匹配属性 |
|
||||
|------------------|-------------------|
|
||||
| accessibility id | AutomationId |
|
||||
| class name | ClassName |
|
||||
| name | Name |
|
||||
|
||||
本文由 [fishky2](https://github.com/fishky2) 翻译,由 [lihuazhang](https://github.com/lihuazhang) 校验。
|
||||