Appium,Android - 在另一个元素中查找元素 [英] Appium, Android - Finding element inside another element
问题描述
我正在尝试检查元素是否存在,但是当我们指定它应该在另一个元素内时,appium 似乎忽略了搜索元素.例如:
I am trying to check if element exist, but appium seems to ignore searching an element when we specified that it should be inside another element. For example:
driver.findElementByAccessibilityId("First element").findElementByAccessibilityId("Second element");
它应该以某种方式工作,因为 Appium 检查器中有一个名为 Locator 的选项,在选择策略并从所选元素选项中选择搜索后,它会找到我期望的内容.
It should work somehow since there is option in Appium inspector called Locator where after selecting strategy and choosing search from selected element option it finds what I expect.
找到这些元素的正确方法是什么?
What is the proper way of finding such elements ?
推荐答案
简单的解决方案,但不是最干净的:
Simple solution but not the cleanest below:
我正在使用 TestNG 框架,我认为它不允许声明,例如
I am using TestNG framework which I suppose do not allow declarations such as
private WebElement element= driver.findElementByAccessibilityId("First element").findElementByAccessibilityId("Second element");
简单但不是最好的解决方案是仅将父项声明为:
Simple solution but not the best is to declare only parents as:
@FindBy(name="Parent")
private WebElement ParentElement;
然后以测试用例为例:
ParentElement.findElement(By.name("childElement")).isDisplayed())
这篇关于Appium,Android - 在另一个元素中查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!