首页 > 解决方案 > 如何在 appium 中启用 chromedriver_autodownload 功能?

问题描述

我正在尝试在 android 真实设备中进行自动化测试,但出现以下错误:

Encountered internal error running command: Error: No Chromedriver found that can automate Chrome '83.0.4103'. You could also try to enable automated chromedrivers download server feature. See https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/web/chromedriver.md for more details

如您所见,这是一个 Chromedriver 兼容性问题,所以我开始寻找解决方案,发现我可以在 appium 中允许chromedriver_autodownload来解决这个问题。所以我关闭了 appium,打开命令提示符,在命令提示符中移动到我拥有 appium 应用程序的文件夹,然后输入appium --allow-insecure chromedriver_autodownload. 换句话说,我的 cmd (命令提示符)看起来像这样:C:\Program Files\Appium>appium --allow-insecure chromedriver_autodownload,这引发了以下警告并随后打开了 appium:

 (node:14992) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, rename 'C:\Users\isaac\AppData\Roaming\appium-desktop\Settings-tmp' -> 'C:\Users\isaac\AppData\Roaming\appium-desktop\Settings'
(node:14992) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, rename 'C:\Users\isaac\AppData\Roaming\appium-desktop\Settings-tmp' -> 'C:\Users\isaac\AppData\Roaming\appium-desktop\Settings'
(node:14992) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14992) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14992) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:14992) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

如果您看到,前两个实际上是错误,但是我去了那些错误中提到的路径,发现 Settings 文件没有像错误所说的那样命名为Settings-tmp而是Settings,所以我不明白这个错误。正如预期的那样,由于这个错误,我的测试无法执行,我得到了开头提到的相同的 Chromedriver 兼容性错误。

有人可以告诉我我在使用时是否做错了什么appium --allow-insecure chromedriver_autodownload?或解决设置文件名错误的方法?或者也许是另一种解决 Chromedriver 兼容性错误的方法,而不是我尝试过的方法?

在此先感谢,任何帮助将不胜感激

标签: androidseleniumselenium-chromedriverappium

解决方案


您需要添加两个所需的功能:

chromedriverExecutableDir :Appium 服务器主机上可写目录的路径,可以从chromedriverChromeMappingFile下载和执行新的 Chromedriver 二进制文件 :Appium 服务器主机上 JSON 文件的路径,其中将存储 Chrome 驱动程序版本到 Chrome 支持的映射.

之后,命令行应该可以工作。

或者,您可以将 AppiumDriverLocalService 类实例化为一个新对象,然后像这样指定两个参数:

AppiumDriverLocalService service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().usingAnyFreePort().withArgument(() -> "--allow-insecure","chromedriver_autodownload"));

推荐阅读