Whenever I am trying to use a list element, this error is showing
Type mismatch: cannot convert from WebElement to List<WebElement>
in appium. Please help!
List <WebElement>a=driver.findElement(By.className("android.widget.EditText"));
Whenever I am trying to use a list element, this error is showing
Type mismatch: cannot convert from WebElement to List<WebElement>
in appium. Please help!
List <WebElement>a=driver.findElement(By.className("android.widget.EditText"));
Just replace the findElement ()
method with findElement**s**(plural)
.
Since the findElement
method always returns a WebElement
instead of a List of WebElements. The findElements
method will return the list of webelements, which can be referred by a variable of type List<Webelement>
.
So the line of code will looks like,..
List<WebElement> a=driver.findElements(By.className("android.widget.EditText"));
Done.
You are using findElement
method which will return single element but you are try to save it in the list.
Your code should be
WebElement a=driver.findElement(By.className("android.widget.EditText"));