Appium,机器人 - 另一个元素中寻找元素 [英] 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检查选项,其中选择策略,并选择从选择的元素选项搜索找到我的期望之后调用定位。
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;
然后在测试案例,例如:
Then in test case for example:
ParentElement.findElement(By.name("childElement")).isDisplayed())
这篇关于Appium,机器人 - 另一个元素中寻找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!