简体   繁体   中英

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. 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

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

there placement is not null, but the correct webelement handled well. 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. 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.

However, you can use @FindBy for list of elements too. 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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