Unable to click on element?

I am trying to click on an element which appears only a few mill seconds and then disappear.
Code is like this

public void AddNotations()
{
try{
Thread.sleep(2000);
driver.findElement(By.id(“com.hannainst.hannalab:id/btnProbe”)).click();
driver.findElement(By.id(“android:id/btnAddNote”)).click();
Thread.sleep(2000);
driver.findElement(By.id(“com.hannainst.hannalab:id/et_note”)).sendKeys(“WWWWWWWWWWW”);
driver.findElement(By.id(“android:id/button1”)).click();

		 System.out.println(Annotations Added");
		 } catch(Throwable e)
			{
				System.out.println("Annotations does not Added");
				
			}
}

Refer attached screenshots, I want access green color box which appeared while clicking on probe image button

I have one similar problem with parallel execution (I have to see the is typing text on one device when the other is writing). I propose you use Threads.

You launch one thread tapping on the “probe image button” and the normal execution will access the “green color box”

public class ThreadHelper extends Thread{

private AppiumDriver localDriver;

public ThreadHelper(AppiumDriver driver) {
    localDriver = driver;
}

@Override
public void run() {
    try {
        yourMethod();
    } catch (Exception e) {
        //Throw Exception in Thread is a pain, on todo list
    }
}

private void yourMethod() throws Exception {
    //Do whatever. Use localdriver
}
}

Call it:

ThreadHelper worker1 = new ThreadHelper(driver);
worker1.start();

Thanks for quick response. I am trying to implement your suggestion but couldn’t succeed. If possible plz write code for me. I am stuck in it. Thanks InAdvace

My Code like this

import io.appium.java_client.android.AndroidDriver;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import java.util.Date;
public class HannaTest_AddNotation {
AndroidDriver driver;

@BeforeTest(enabled = true)
public void setUp() throws MalformedURLException 
{
		  try{
		  DesiredCapabilities capabilities = new DesiredCapabilities();
		  capabilities.setCapability("deviceName", "ZX1B32FFXF");
		  capabilities.setCapability("browserName", "Android");
		  capabilities.setCapability("platformVersion", "4.4.2");
		  capabilities.setCapability("platformName", "Android");
		  capabilities.setCapability("rotatable", true);
		  capabilities.setCapability("appPackage", "com.hannainst.hannalab");
		  capabilities.setCapability("appActivity","com.hannainst.hannalab.ManagerActivity");
		  driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
		  driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
		  WebDriverWait wait = new WebDriverWait(driver, 300);
		  wait.until(ExpectedConditions.elementToBeClickable(By.className("android.widget.RelativeLayout")));
		  System.out.println("TC0 :-App Launched Successfully");
		  } catch(Throwable e)
			{
				System.out.println("TC0:-Test Case Failed");
				
			}
}

@Test(priority = 1)
public void run() 
{
    try {
    	AddNotations();
    } catch (Exception e) {
    	System.out.println("Annotations does not Added");
    }
}

private void AddNotations() throws Exception {
    //Thread.sleep(2000);
	try{
	driver.findElement(By.id("com.hannainst.hannalab:id/btnProbe")).click();
	driver.findElement(By.id("android:id/btnAddNote")).click();
	Thread.sleep(2000);
	driver.findElement(By.id("com.hannainst.hannalab:id/et_note")).sendKeys("WWWWWWWWWWW");
	driver.findElement(By.id("android:id/button1")).click();
	System.out.println("Annotations Added");
	}catch(Throwable e)
			{
				System.out.println("Annotations does not Added");

			}

}

@AfterTest
public void End() throws IOException 
{
	
	
	driver.resetApp();
	driver.quit();  

}

}