Additional comment:
When I ran the Test Case TC1 of https://github.com/kazurayam/Cannot_find_elements_when_XPath_expression_is_null project, I got the following message in the Console:
2018-12-22 20:28:17.159 ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/TC1 FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to verify object 'Object Repository/Page_AngularJS Hub Text Inputs/iframe_Example_exampleIFrame' is present (Root cause: java.lang.IllegalArgumentException: Cannot find elements when the XPath expression is null.)
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:27)
...
This message does not tell me where the IllegalArgumentException was raised, by which class, by which method in which line. I wanted to see the StackTrace of the IllegalArgumentException. I wondered why the Stack Trace is not printed.
I read the source of VerifyElementPresentKeyword and other related classes.
I would like to propose to Katalon Team to modify the com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain class.
public class WebUIKeywordMain {
private static final String TIMED_OUT_WAITING_FOR_PAGE_LOAD = "Timed out waiting for page load."
@CompileStatic
public static runKeyword(Closure closure, FailureHandling flowControl, boolean takeScreenShot, String errorMessage) {
try {
return closure.call();
} catch (Throwable e) {
if (isPageLoadTimeoutException(e) && DriverFactory.isEnablePageLoadTimeout() && DriverFactory.isIgnorePageLoadTimeoutException()) {
stepFailed(errorMessage, FailureHandling.OPTIONAL, ExceptionsUtil.getMessageForThrowable(e), takeScreenShot);
return;
}
// kazurayam wants to insert a line here
e.printStackTrace()
stepFailed(errorMessage, flowControl, ExceptionsUtil.getMessageForThrowable(e), takeScreenShot);
}
}