title: Read HTML content from a WebView using WebDriver and Appium
body: <p>I am trying to automate Gmail App on android using Selenium WebDriver and Appium. I need to read an email content and then validate it. But the complete element is displayed as a single webview and I am I am unable to read any text from the email. Please suggest a way so that I can read the email content</p>
  
  <p>Code Used:</p>
  
  <pre><code>package com.example.appium;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.List;
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.remote.DesiredCapabilities;
  import org.openqa.selenium.remote.RemoteWebDriver;
  
  public class GmailInvoke {
      /**
       * @param args
       * @throws MalformedURLException 
       * @throws InterruptedException 
       */
      public static void main(String[] args) throws MalformedURLException, InterruptedException {
          DesiredCapabilities capabilities=new DesiredCapabilities();
          capabilities.setCapability("platformName", "Android");
          capabilities.setCapability("deviceName", "Android");
  
        //Gmail
          capabilities.setCapability("appPackage","com.google.android.gm");        
          capabilities.setCapability("appActivity", ".ui.MailActivityGmail");
  
          WebDriver driver=new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
          List &lt;WebElement&gt; emails = driver.findElements(By.className("android.widget.FrameLayout"));
          emails.get(5).click();
  System.out.println(driver.findElement(By.id("com.google.android.gm:id/webview")).getText());
          Thread.sleep(5000);
          driver.quit();
      }
  }
  </code></pre>