WaitforElement not showing as fail in the report if the element not found


#1

Hi,
I am using Appium Studio 11.7.103 and executed the scripts using eclipse.I had created my own framework for the android automation using pageobject model.
Problem: I am using below code.I am using this for the element to be visible and then continues the next functionality.
But the problem is after waiting if the element is not found the testcase fails and showing error in the eclipse console.But coming to the report it is displaying as pass.How to solve this issue I want to be failed if element not found.
public void waitforelement(By element){
try{
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfElementLocated(element));
}catch(Exception e){
e.printStackTrace();
Log_Message(“Unable to find the element”, “false”);
}
}


#2

Can someone help me about this


#3

Is your Assertion framework JUNIT or TESTNG ?? The wait.unit will throw a TimeoutException if the element is not found. Your exception handler will catch this and based on your code. This in of itself will not fail a test if JUNIT or TESTNG is being used.

If your code is using TESTNG for the assertion framework, you’d up date your exception handler with something like:

catch(Exception e){
e.printStackTrace();
Log_Message(“Unable to find the element”, “false”);
Assert.fail(e.getMessage(),e);
}

The assert will cause TESTNG to consider the test a failed test.


#4

Thanks for the reply.I am using testng framework.I had changed and made some modification like removed implicity wait and using only explicit wait.So in explicit wait if I use 30 seconds,it will check for the element continuously for 30seconds.During that time if the element not found in the first check,the step in the report is displaying as fail but after second or third check if the element is found then the next step in the report is displayed as pass.But my testcase report showing as failed.How to solve this I want testcase to show as pass.


#5

Please provide the code for us to look at