title: receiving a webElement List - casting error
body: <p>I have a method like this</p>
  
  <pre><code>  public List&lt;WebElement&gt; AgreeAllow(){
  
            WebElement ButtonAgree = (WebElement) driver.findElementsByAndroidUIAutomator(SelectorRepo.AgreeButton);
            WebElement ButtonAllow = (WebElement) driver.findElementsByAndroidUIAutomator(SelectorRepo.AllowButton);
  
            List&lt;WebElement&gt; AgreeAllowFunction = new ArrayList&lt;WebElement&gt;();
  
           // ArrayList AgreeAllowFunction = new ArrayList&lt;WebElement&gt;(); 
            AgreeAllowFunction.add(ButtonAgree);
            AgreeAllowFunction.add(ButtonAllow);
  
            return AgreeAllowFunction;
  
        }
  </code></pre>
  
  <p>and I am calling <code>AgreeAllow()</code> like this in a different file</p>
  
  <pre><code>List&lt;WebElement&gt;  AgreeAllowHandler =  PageObjectOneInst.AgreeAllow();
  
  
        tAction.tap((WebElement) AgreeAllowHandler.get(0));
        tAction.tap((WebElement) AgreeAllowHandler.get(1));
        ...
        ...
  </code></pre>
  
  <p>Its giving me this error
  <code>java.util.ArrayList cannot be cast to org.openqa.selenium.WebElement</code></p>
  
  <p>I tried this also, but couldn't resolve</p>
  
  <pre><code> List&lt;WebElement&gt;  AgreeAllowHandler =   List&lt;WebElement&gt;  PageObjectOneInst.AgreeAllow();
  </code></pre>
  
  <p>I have looked at several SO questions. I tried below also from <a href="https://stackoverflow.com/questions/17840483/how-to-have-java-method-return-generic-list-of-any-type">here</a></p>
  
  <pre><code>List&lt;WebElement&gt;  AgreeAllowHandler = new ArrayList&lt;&gt;();      
        for (WebElement wElement : PageObjectOneInst.AgreeAllow()){
            Class &lt;WebElement&gt; c = null;
            WebElement we =  c.cast(wElement);
            AgreeAllowHandler.add(we);
          }
  </code></pre>
  
  <p>how do I receive/cast it correctly?</p>