Appium-Using Chromedriver(使用谷歌设备)


Appium supports automating Android web pages (in Chrome and the built-in Browser) and hybrid apps that are Chrome-backed, by managing a Chromedriver instance and proxying commands to it when necessary. It comes bundled with the latest version of Chromedriver, installed through the npm package appium-chromedriver (Github: appium-chromedriver).

Appium支持Android web pags自动化
(在Chrome和built-in Browser中)和Chrome支持的混合apps,
通过管理Chromedriver实例化并代理它必要的命令.
它来免费提供与最新版本的Chromedriver,
通过npm包'appium-chromedriver'安装(Github: appium-chromedriver)

With each update to Chromedriver there is an increase in the minimum supported version of Chrome, such that older devices are often unable to be automated with the bundled version. In the Appium server logs there will be an error like:

每次去更新Chromedriver都会增加最低版本支持的Chrome,
例如旧设备不经常与捆绑版本自动化.
在Appium服务器日志错误如下:
An unknown server-side error occurred while processing the command.
Original error: unknown error: Chrome version must be >= 55.0.2883.0

To get around this it is necessary to provide Appium with a proper Chromedriver binary, that matches to the Chrome engine version running on the device under test. Read the Chromedriver/Chrome compatibility topic below to know more about finding a matching Chromedriver executable.

为解决必须为Appium提供一个适当Chromedriver二进制,
去匹配Chrome引擎版本运行在设备上测试.
阅读 `Chromedriver/Chrome compatibility`主题下
关于更多信息查找匹配Chromedriver可执行.

There are several ways to provide a customized Chromedriver to Appium:

有些方法为Appium来提供定制的Chromedriver:
When installing the server

Provide --chromedriver_version command line argument containing the actual version number

提供'--chromedriver_version'包含实际版本的命令行参数
npm install appium --chromedriver_version="2.16"

Or specify the Chromedriver version in the CHROMEDRIVER_VERSION environment variable, e.g,

或具体说明Chromedriver版本在`CHROMEDRIVER_VERSION`环境变量,
例如:
CHROMEDRIVER_VERSION=2.20 npm install appium

This can also be set to LATEST to get the most recent version.

也可以设置为最新去获取最新版本.
When starting the server

Chromedriver version can be specified at runtime, by specifying the --chromedriver-executable server flag, along with the full path to the Chromedriver executable which was manually downloaded and put to the server file system, e.g.,

Chromedriver 版本可以指定运行时间,
通过指定`--chromedriver-executable`服务标记,
手动下载并放入服务文件系统中与完整路径一起,
例如:
appium --chromedriver-executable /path/to/my/chromedriver
When starting a session (manual discovery)
启动对话(手动查找)

Chromedriver version can be specified in session capabilities, by providing the chromedriverExecutable cap, containing the full path to a matching Chromedriver executable, which must be manually downloaded and put to the server file system. See http://appium.io/docs/en/writing-running-appium/caps/ for more details

在会话功能中可以指定Chromedriver 版本,
通过提供`chromedriverExecutable`覆盖,
包含完整的路径匹配'Chromedriver executable',
必须手动下载并访问服务文件系统中.
更多相关参阅链接'http://appium.io/docs/en/writing-running-appium/caps/'
When starting a session (automated discovery)

Appium could also try to detect the version of the target Chrome engine and download matching chromedriver for it automatically if it does not exist on the local file system. Read the Automatic discovery of compatible Chromedriver topic below for more details.

Appium还可以尝试检测Chrome引擎的版本
并且如果不是存在于本地文件系统
为它自动的下载Chromedriver
Chromedriver/Chrome compatibility

The list of Chromedriver versions and their matching minimum Chrome versions could be found at https://raw.githubusercontent.com/appium/appium-chromedriver/master/config/mapping.json

Chromedriver版本列表和匹配的最低Chrome版本
可以在 'https://raw.githubusercontent.com/appium/appium-chromedriver/master/config/mapping.json'
中建立.

Since version 2.46 Google has changed the rules for Chromedriver versioning, so now the major Chromedriver version corresponds to the major web view/browser version, that it can automate. Follow the Version Selection document in order to manually find the Chromedriver, that supports your current browser/web view if its major version is equal or above 73.

从2.46版本开始Chrome开似乎改变了Chromedriver版本控制的规则,
所以现在主要的Chromedriver版本
与'web view/browser'版本一致,它可以自动化.
按照版本选择文档为手动查找Chromedriver,
如果主版本是73更高的版本
它支持你当前browser/web view.

To find the minimum supported browsers for older Chromedriver versions (below 73), get the Chromium source code, check out the release commit, and check the variable kMinimumSupportedChromeVersion in the file src/chrome/test/chromedriver/chrome/version.cc. (To find the release commits, you can use git log --pretty=format:'%h | %s%d' | grep -i "Release Chromedriver version".)

为旧的Chromedriver版本(73以下)要找到最低支持浏览器,
获取Chromium源码,
查看发布提交,
并检查变量`kMinimumSupportedChromeVersion`
在文件`src/chrome/test/chromedriver/chrome/version.cc.`中
(要寻找提交发布,你可以用`git log --pretty=format:'%h | %s%d' | grep -i "Release Chromedriver version"`.)

The complete list of available Chromedriver releases and release notes is here.

完整的列表可用Chromedriver发行和发行说明.
Automatic discovery of compatible Chromedriver

Beginning with Appium 1.8.0, Appium is able to pick the correct Chromedriver for the version of Chrome under test. While Appium only comes bundled with the Chromedriver most recently released at the time of the Appium version’s release, more Chromedriver versions can be downloaded and either placed inside the Appium installation (not recommended since upgrading Appium will remove them) or in a custom location, which can be indicated to Appium with the chromedriverExecutableDir desired capability. This capability is the absolute path to the directory in which you have placed one or more Chromedriver executables.

从Appium1.8.0开始,
appium是可以点击正确版本的Chromedriver为了在Chrome下测试.
尽管Appium仅与Chromedriver捆绑最新发布时的Appium版本,
更多Chromedriver版本可以下载并将其放置在任意Appium安装中
(不推荐升级Appium将载删除他们)
或自定义位置,
可以表示的为Appium带有的`hromedriverExecutableDir`所需功能.
此功能是绝对路径在你的某一个位置一个或多个Chromedriver执行.

As well, since new versions of Chromedriver may be available that were not when an Appium version was released, a custom mapping of Chromedrivers to the minimum Chrome version they support can be given to Appium through the chromedriverChromeMappingFile desired capability. This should be the absolute path to a file with the mapping in it. The contents of the file need to be parsable as a JSON object, like:

另外,自从Chromedriver新的版本可能在Appium发布时没有出现.
通过'chromedriverChromeMappingFile'所需的功能,
可以将Chromedrivers自定义映射到它们支持的最低Chrome版本.
这应该是包含映射文件绝对路径.
文件的内容需要作为JSON对象进行分析,如:
{
  "2.42": "63.0.3239",
  "2.41": "62.0.3202"
}

Since Appium 1.15.0 there is a possibility to automatically download the necessary chromedriver(s) into chromedriverExecutableDir from the official Google storage. The script will automatically search for the newest chromedriver version that supports the given browser/web view, download it (the hash sum is verified as well for the downloaded archive) and add to the chromedriverChromeMappingFile mapping. Everything, which is needed to be done from your side is to execute the server withchromedriver_autodownload feature enabled (like appium --allow-insecure chromedriver_autodownload). You can also check the Security document for more details on how to control potentially insecure server features.

自Appium1.15.0版本开始
可选择去谷歌官方存储中自动下载必要的必要的'chromedriver(s)''chromedriverExecutableDir'中.
脚本将自动搜索支持指定browser/web view最新的chromedriver版本.
下载它(得到验证的哈希和以及下载的文档)
并添加到'chromedriverChromeMappingFile'信息中.
一切,需要的是从你执行的服务'chromedriver_autodownload'功能已启用
(例如'appium --allow-insecure chromedriver_autodownload').
你也可以查看安全文档为了解更多详细情况关于怎样控制可能不安全的服务器功能.
Troubleshooting network issues
网络问题疑难解答

When Appium is installed it needs to download Chromedriver, so there is the possibility that there could be network problems that make the install fail.

当Appium安装后它需要去下载Chromedriver,
因此这里可能是网络问题导致安装失败.

By default Chromedriver is retrieved from https://chromedriver.storage.googleapis.com/. To use a mirror of the ChromeDriver binaries use npm config property chromedriver_cdnurl.

通过默认恢复Chromedriver从
`https://chromedriver.storage.googleapis.com/`中.
要使用一个镜像ChromeDriver二进制文件
使用npm config的`chromedriver_cdnurl`属性.
npm install appium-chromedriver --chromedriver_cdnurl=http://npm.taobao.org/mirrors/chromedriver

Or add the property into your .npmrc file.

或者添加这个属性从你的`.npmrc`文件中.
chromedriver_cdnurl=http://npm.taobao.org/mirrors/chromedriver

Another option is to use PATH variable CHROMEDRIVER_CDNURL.

另一个选择是使用路径变量`CHROMEDRIVER_CDNURL`.
CHROMEDRIVER_CDNURL=http://npm.taobao.org/mirrors/chromedriver npm install appium-chromedriver

It may also be necessary to adjust network proxy and firewall settings to allow the download to occur.

它还可能需要调整网络代理和防火墙设置去允许下载的进行.
W3C support

Chromedriver didn’t follow the W3C standard until version 75. If you encounter proxy command error like this issue, please update your Chromedriver version. Old Android devices can’t use newer chrome drivers. You can avoid the error if you run tests with the Mobile JSON Wire Protocol. Since major version 75 W3C mode is the default one for Chromedriver, although it could be still switched to JSONWP one depending on the passed session capabilities. You can read the history of W3C support in Chromedriver from downloads.

Chromedriver直到75版本开始遵循W3C标准.
如果你遇到代理命令错误类似问题,
请更新你的Chromedriver版本.
旧的Android设备不能使用新的chrome drivers.
如果你运行测试从Mobile JSON Wire Potocol你可以避免错误,
从主版本75开始W3C是默认模式Chromedriver,
尽管它仍然可以根据传递的会话功能切换到JSONWP-one.
可以从文档中W3C支持的Chromedriver下载.
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Aniona

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值