title: Appium - How to Validate if an object exists
body: <p>I'm new to this forum and appium/android automation, I need help on verifying if an object exists on my app before I take the next action.</p>
  <p>I tried using the following code below but is not even reaching my second print statement.</p>
  <pre><code>@Test
  public void addContact() {
      System.out.println( &quot;Checking if Contact exists.... 111111 &quot;);
     
      WebElement e = driver.findElement(By.name(&quot;John Doe&quot;));
             
      System.out.println( &quot;Checking if Contact exists.... 222222&quot;);
     
      boolean contactExists = e.isDisplayed();
     
      System.out.println( contactExists );
     
     
      if (contactExists == true) {          
          System.out.println( &quot;Contact exists.... &quot;);           
      } else {           
          System.out.println( &quot;Contact DOES NOT exists.... &quot;);
      }
   }
  </code></pre>
  <p>Running this code here's appium console output... it just keeps looping through this and script fails.</p>
  <blockquote>
  <p>info: [BOOTSTRAP] [info] Got command of type ACTION</p>
  <p>info: [BOOTSTRAP] [debug] Got command action: find</p>
  <p>info: [BOOTSTRAP] [debug] Finding John Doe using NAME with the contextId:</p>
  <p>info: [BOOTSTRAP] [info] Returning result: {&quot;value&quot;:&quot;No element found&quot;,&quot;status&quot;:7}</p>
  <p>info: Pushing command to appium work queue: [&quot;find&quot;,{&quot;strategy&quot;:&quot;name&quot;,&quot;selector&quot;:&quot;John Doe&quot;,&quot;context&quot;:&quot;&quot;,&quot;multiple&quot;:false}]</p>
  <p>info: [BOOTSTRAP] [info] Got data from client: {&quot;cmd&quot;:&quot;action&quot;,&quot;action&quot;:&quot;find&quot;,&quot;params&quot;:{&quot;strategy&quot;:&quot;name&quot;,&quot;selector&quot;:&quot;John Doe&quot;,&quot;context&quot;:&quot;&quot;,&quot;multiple&quot;:false}}</p>
  </blockquote>
  <p>is isDisplayed the right approach here or is there a better alternative to do this?</p>
  <p>Cheers.... TIA</p>