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"));
  • use findElements() method when you're trying to find a list of elements or more than one elements. It may be due to this. – demouser123 Aug 17 '15 at 2:34
  • Glad it worked after imorting the library . – shrey Aug 17 '15 at 2:48
  • Voting to leave open. This is a type of question that I would have come to SQA looking for an answer for when I first started with automation. – Lyndon Vrooman Jan 27 '16 at 18:08

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"));


| improve this answer | |

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"));
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.