How to get the elements into a list in appium

413 views Asked by At
List<WebElement> count=  driver.findElements(by.xpath("abc"));

I am getting an error if I use the above line:

"Type safety: The expression of type List needs unchecked conversion to conform to List<WebElement>"

I am doing a TestProject coded android test

1

There are 1 answers

0
dmle On

If you check findElements method in source code:

    @Override public List<T> findElements(By by) {
        return super.findElements(by);
    }

The T is a type parameter passed to the generic interface List. In order to use it, you must define the type in your code:

List<MobileElement> count = driver.findElements(by.xpath("abc"));