title: Appium driver cannot find any elements in the UI of the app. Tried find element by id,xpath,name.Nothing seems to work
body: <p>This is my Eclipse test code</p>
  
  <hr>
  
  <pre><code>package com.example;
  
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.Set;
  import java.util.concurrent.TimeUnit;
  
  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.SessionId;
  import org.testng.annotations.BeforeClass;
  import org.testng.annotations.BeforeMethod;
  import org.testng.annotations.BeforeTest;
  import org.testng.annotations.Test;
  import io.appium.java_client.AppiumDriver;
  import io.appium.java_client.MobileBy;
  import io.appium.java_client.android.AndroidDriver;
  import io.appium.java_client.android.AndroidElement;
  import io.appium.java_client.remote.AndroidMobileCapabilityType;
  import io.appium.java_client.remote.MobileCapabilityType;
  
  public class FirstAppiumTest {
      //protected AndroidDriver&lt;AndroidElement&gt; driver = null;
      public AppiumDriver driver;
      @BeforeTest
      public void Setup() throws MalformedURLException
      {String url = "http://127.0.0.1:4723/wd/hub";
  
          DesiredCapabilities cap=new DesiredCapabilities();
  
      cap.setCapability("noReset","true");
      cap.setCapability("deviceName","Redmi 4");
      cap.setCapability("platformVersion","7.1.2");
      cap.setCapability("platformName","Android");
      cap.setCapability("app","C:\\Appium\\selendroid-test-app.apk");
  
  
  
       driver=new AndroidDriver(new URL(url),cap);
      }
      @Test
      public void Simpletest() throws InterruptedException
      {  
          driver.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);
          //driver.findElement(By.className("android.widget.Button")).click();
          WebElement e1=driver.findElement(By.id("showToastButton"));
          e1.click();
           System.out.print(e1);
   String text=driver.findElement(By.className("android.widget.EditText")).getText();
       System.out.print(text);
       String src = driver.getPageSource();
         System.out.println(src);         
        driver.quit();
  
  
      }
  }
  </code></pre>
  
  <hr>
  
  <p>Here when i try to print e1 it shows me the object value.But when i try to click or getText it shows an exception.Also driver.quit and driver.getPageSource() seems to work.
  The log in the console is as follows</p>
  
  <hr>
  
  <blockquote>
    <p>[RemoteTestNG] detected TestNG version 6.14.2
    Apr 27, 2018 11:16:16 AM org.openqa.selenium.remote.ProtocolHandshake createSession
    INFO: Detected dialect: OSS
    FAILED: Simpletest
    java.lang.NullPointerException
        at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
        at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83)
        at com.example.FirstAppiumTest.Simpletest(FirstAppiumTest.java:56)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:580)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
        at org.testng.TestRunner.privateRun(TestRunner.java:648)
        at org.testng.TestRunner.run(TestRunner.java:505)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
        at org.testng.SuiteRunner.run(SuiteRunner.java:364)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
        at org.testng.TestNG.runSuites(TestNG.java:1049)
        at org.testng.TestNG.run(TestNG.java:1017)
        at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)</p>
  </blockquote>
  
  <p>===============================================</p>
  
  <p>Default test
  Tests run: 1, Failures: 1, Skips: 0</p>
  
  <p>Default suite
  Total tests run: 1, Failures: 1, Skips: 0</p>