title: Mobile element do not exist in DOM anymore - selenium
body: <p>Using appium + selenium + java. Trying to wait for mobile element with specific text. </p>
  
  <p>In mobile application I am login to page, and during login have android.widget.TextView(0) with text, so I am checking this text and if new element android.widget.TextView(0) with different text show up then I can go with other steps. When new element show up old one does not exists</p>
  
  <p>For that using following code but then I can see </p>
  
  <pre><code>Cached elements 'By.clazz: android.widget.TextView' do not exist in DOM anymore 
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>public static MobileElement waitForElementText(AndroidDriver driver, int index, String text, int timeout) {
  
          List&lt;MobileElement&gt; mobileElement = null;
  
          do {
  
              mobileElement = new WebDriverWait(driver, timeout)
                      .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className("android.widget.TextView")))
                      .stream().map(element -&gt; (MobileElement) element).collect(Collectors.toList());
              System.out.println("waiting for: " + text + " found: " + mobileElement.get(index).getText());
              try {
                  Thread.sleep(5000);
              } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          } while (mobileElement.get(index).getText() != text);
  
          System.out.println(mobileElement.get(index).getText());
  
          return mobileElement.get(index);
      }
  </code></pre>
  
  <p>any ideas what am I doing wrong? </p>