简体   繁体   English

为什么选择WebElement和列表 <WebElement> 通过xpath以不同的方式处理,并且List始终为null?

[英]Why WebElement and List<WebElement> are processed not in the similar way via xpath and List is always null?

I'm using Thucydides 0.9.229 with Selenium shipped with it. 我将Thucydides 0.9.229与Selenium一起使用。 To obtain some webelements I try to get them via List 为了获得一些网络元素,我尝试通过列表获取它们

@FindAll({@FindBy(xpath = "//div[text()='Расположение']/../../td[2]//input[@type='text']")})
private List<WebElement> placement;

with no result, the placement is returned null, while here 没有结果,则展示位置返回null,而此处

@FindBy(xpath = "//div[text()='Расположение']/../../td[2]//input[@type='text']")})
private WebElement placement;

there placement is not null, but the correct webelement handled well. 该位置不为null,但正确的网络元素处理得很好。 As far as I understand, the firs example should return the 1-value list anyway, but even more values if there were some additional elements fitting the criteria. 据我了解,firs示例无论如何都应该返回1值列表,但是如果有一些其他符合条件的元素,则返回更多值。 So, what is wrong, why I can't get the list of webelements there? 那么,怎么了,为什么我不能在那里找到网络元素列表?

I have the same issue with @FindAll, and it also returns null. 我对@FindAll有相同的问题,它也返回null。

However, you can use @FindBy for list of elements too. 但是,您也可以将@FindBy用于元素列表。 It may be used to mark a field on a Page Object to indicate an element or a list of elements. 它可用于标记页面对象上的字段以指示一个元素或元素列表。

@FindBy(xpath = "//div[text()='Расположение']/../../td[2]//input[@type='text']")})
private List<WebElement> placement;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM