[英]NativeScript-Dev-Appium : UIElement.text() / UIElement.getAttribute(“value”) returns the automationText instead of the text displayed
I am using NativeScript-Dev-Appium@5.0.0 and wish to check for the text displayed on a label. 我正在使用NativeScript-Dev-Appium@5.0.0,并希望检查标签上显示的文本。 I have automationText property assigned to the and use Driver.findElementByAccessibilityId(automationTextValue) to get the element.
我已将AutomationText属性分配给,并使用Driver.findElementByAccessibilityId(automationTextValue)来获取元素。 The element is found, but when I try to use the UIElement.text() / UIElement.getAttribute("value") on it, it returns the value of the automationText attribute instead of the actual displayed text.
找到该元素,但是当我尝试在其上使用UIElement.text()/ UIElement.getAttribute(“ value”)时,它将返回automationText属性的值,而不是实际显示的文本。 Is there any other method to do it because I can't find any.
还有其他方法可以执行,因为我找不到任何方法。
Unfortunately, this is a limitation of NativeScript itself since when the automationText property is used, it will set all properties of the element like value, name, label etc. I would suggest you set the same text to automationText property and then you can access or test the element using something like this: 不幸的是,这是NativeScript本身的局限性,因为当使用automationText属性时,它将设置元素的所有属性,例如值,名称,标签等。我建议您将相同的文本设置为automationText属性,然后可以访问或使用如下所示测试元素:
const el = await driver.findElementByXPath("//*[@name=\"My automation text\"]");
const el = await driver.findElementByText("My automation text");
const text = await el.getAttribute("text");
await driver.compareRectangle
await driver.compareElement
await driver.compareScreen
Which is very convenient but the cons here is that this will require higher maintenance at some point. 这非常方便,但是这里的缺点是,这有时需要更高的维护。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.