IF statement on WebUI.Click always returns null?

I have the following code where WebUI.Click always returns null. This makes the conditional statement useless.

I did notice that in the docs there was not a return type for WebUI.Click - is there something I am doing wrong despite this? Does this always return null? I have seen this solution recommended before.

if(!(WebUI.click(findTestObject('JFA/Login Page/btn_SignIn'), FailureHandling.OPTIONAL))) {
	KeywordUtil.markFailed("Log-in Failed")
}
else {
	KeywordUtil.markPassed("Log-in Success")
}

WebUI.click() doesn’t return a usable value – it’s a void method:

Trying to use a conditional statement without a testable value is also completely pointless.

Using a conditional where it’s unusable is something I would say is wrong.

Your code looks to be trying to prove login success/failure. How is a (un)successful click meant to prove that?

What exactly would you like to achieve?

As @Russ_Thomas says, the click method does not return a boolean condition, which is what you need for an if statement. What you can do as an example is to click on your sign in page, and then check if you have moved to it, like:

WebUI.click(findTestObject('JFA/Login Page/btn_SignIn'))
WebUI.waitForPageLoad(10)
if (WebUI.verifyTextPresent('**something specific on the new page**', false, FailureHandling.OPTIONAL)) {

image

or

WebUI.click(findTestObject('JFA/Login Page/btn_SignIn'))
WebUI.waitForPageLoad(10)
if (WebUI.verifyElementText(findTextObject('yourObject'), '**the elements text**', FailureHandling.OPTIONAL)) {

image

Edit: I throw in the Helptext for your reference of where to tell if a statement has a return value. Note the first word in both Helptext. Also, with if conditions, you should add the FailureHandling option to the statement (because sometimes the statement will throw null without it).