I am facing one issue that appium is not running program or not by passing element when element not present/not found.
My Scenario :
I am doing automation for one android app. In that I am working for profile picture. Now I have 2 options to get profile picture :
1 - Take picture from gallery
2 - Take profile using camera
So I am trying like :
1 - Get profile picture from gallery and do submit.
2 - Then I have put condition that if it do not get picture from gallery then take via CAMERA.
But here appium getting stuck and says element could not found when it do not get image from gallery.
My code :
driver.findElement(By.id("com.test.free:id/iv_add_child")).click();
driver.findElement(By.id("com.test.free:id/tvSelectFromGallery")).click();
driver.findElement(By.xpath("//android.widget.TextView[@text='Recent']")).click();
//THIS IS GETTING PICTURE FROM GALLARY
WebElement gallaryphoto = driver.findElement(By.xpath("//android.widget.GridView//android.widget.ImageView[3]"));
gallaryphoto.click();
//HERE I AM CHECKING THAT IF PICTURE IS NOT IN GALLARY THEN CHECK HERE AND TAKE PICTURE USING CAMERA
if(gallaryphoto.isDisplayed())
{
driver.findElement(By.id("com.test.free:id/tvSubmit")).click();
}
else
{
driver.findElement(By.id("com.test.free:id/iv_add_child")).click();
driver.findElement(By.id("com.test.free:id/tvCapFromCam")).click();
Thread.sleep(1000);
driver.findElement(By.id("com.android.camera2:id/shutter_button")).click();
driver.findElement(By.id("com.android.camera2:id/done_button")).click();
Thread.sleep(1000);
driver.findElement(By.id("com.test.free:id/tvSubmit")).click();
}
So finally as per above code it should take picture using CAMERA if not found any picture in gallary BUT appium stuck just before that condition because it is not getting picture from gallery.
Please help