我正在尝试在安卓真实设备中进行自动测试,但出现以下错误:
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
如您所见,这是一个Chrome驱动程序兼容性问题,因此我开始寻找解决方案,并发现我可以允许appium中的chromedriver_autodownload来解决此问题。所以我关闭了appium,打开命令提示符,在命令提示符下移动到我有appium应用程序的文件夹,然后键入appium --allow-insecure chromedriver_autodownload
。换句话说,我的cmd(命令提示符(看起来像这样:C:Program FilesAppium>appium --allow-insecure chromedriver_autodownload
,这引发了以下警告,然后打开了appium:
(node:14992) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, rename 'C:UsersisaacAppDataRoamingappium-desktopSettings-tmp' -> 'C:UsersisaacAppDataRoamingappium-desktopSettings'
(node:14992) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, rename 'C:UsersisaacAppDataRoamingappium-desktopSettings-tmp' -> 'C:UsersisaacAppDataRoamingappium-desktopSettings'
(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-tmp,而是设置,所以我不明白此错误。正如预期的那样,由于此错误,我的测试无法执行,我遇到了开头提到的相同的Chrome驱动程序兼容性错误。
有人可以告诉我我在使用appium --allow-insecure chromedriver_autodownload
时是否做错了什么吗? 或者解决设置文件名错误的方法? 或者也许是另一种解决Chrome驱动程序兼容性错误的方法,而不是我尝试过的方法?
提前感谢,任何帮助将不胜感激
您需要添加两个所需功能:
chromedriverExecutableDir:Appium 服务器主机上可写目录的路径,可以从中下载和执行新的 Chromedriver 二进制文件chromedriverChromeMappingFile:Appium 服务器主机上 JSON 文件的路径,其中将存储 Chromedriver 版本到 Chrome 支持的映射。
之后,命令行应该可以工作。
或者,您可以将 AppiumDriverLocalService 类实例化为新对象,然后指定两个参数,如下所示:
AppiumDriverLocalService service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().usingAnyFreePort().withArgument(() -> "--allow-insecure","chromedriver_autodownload"));