使用文档中的 appium 自定义助手,无法访问 appium 函数,大多数函数都会出现 "is not a function" 错误
Using appium custom helper from docs, does not give access to appium functions, "is not a function" error occurs for most functions
我错过了什么?
我正在尝试编写一个自定义帮助程序来检查 4 个元素,然后根据存在的元素发送不同的命令。
为此,根据 codeceptjs 文档,我们需要一个自定义助手 https://codecept.io/helpers/Appium。
所以我们调用:
让浏览器=this.helpers['Appium'].browser
但不幸的是,它无法像记录的那样工作,它无法访问其网站上记录的几乎所有 Appium 功能 http://appium.io/docs/en/about-appium/api/
所以当我们尝试时:
async checkElement(locator) {
let client = this.helpers['Appium'].browser;
let elementResult = await client.$$(locator).isEnabled();
}
所有这些命令都会抛出一个类似这样的错误:
browser.$(...).isEnabled 不是函数
根据 codeceptjs 文档...应该是包含所有这些功能的 appium 客户端...
client.$$(locator)
returns 找到一个元素数组。
javascript 中的数组没有 isEnabled()
函数。
您可以使用 $(locator)
查找第一个元素或 $$(locator)[0]
。
$
如果未找到元素则抛出异常,如果未找到元素(长度为 0 的数组),$$(...)[0]
将抛出绑定异常的索引。
首先使用,如果元素在页面上应该是单个元素。
Appium 助手是 webdriverio Appium
包装器的包装器。它可能不同于原始的 Appium。看到是APIhere.
我错过了什么?
我正在尝试编写一个自定义帮助程序来检查 4 个元素,然后根据存在的元素发送不同的命令。
为此,根据 codeceptjs 文档,我们需要一个自定义助手 https://codecept.io/helpers/Appium。
所以我们调用:
让浏览器=this.helpers['Appium'].browser
但不幸的是,它无法像记录的那样工作,它无法访问其网站上记录的几乎所有 Appium 功能 http://appium.io/docs/en/about-appium/api/
所以当我们尝试时:
async checkElement(locator) {
let client = this.helpers['Appium'].browser;
let elementResult = await client.$$(locator).isEnabled();
}
所有这些命令都会抛出一个类似这样的错误:
browser.$(...).isEnabled 不是函数
根据 codeceptjs 文档...应该是包含所有这些功能的 appium 客户端...
client.$$(locator)
returns 找到一个元素数组。 javascript 中的数组没有isEnabled()
函数。 您可以使用$(locator)
查找第一个元素或$$(locator)[0]
。$
如果未找到元素则抛出异常,如果未找到元素(长度为 0 的数组),$$(...)[0]
将抛出绑定异常的索引。 首先使用,如果元素在页面上应该是单个元素。Appium 助手是 webdriverio
Appium
包装器的包装器。它可能不同于原始的 Appium。看到是APIhere.