Test Steps are all passed but Test case is failing with 'Alert Not Found'

I have used keywords to verify the alert and its text, all those steps are being passed but test case is failing with No Alert Found error

@Katalon_team @Russ_Thomas @kazurayam

Recently a few people reported that Chrome browser closes the alert dialog quickly & intentionally. See

I know we can handle this alert using different workarounds but still at the end Test case fails with the same error but step passes. I used the below code, let me know if I am doing this correctly?

Code:

public static boolean verifyAlertPresent(TestObject to) {
		WebUI.delay(3)
		KeywordUtil.logInfo("Inside While")
		while(!WebUI.verifyAlertPresent(3)) {
			KeywordUtil.logInfo("Alert Not Present")
			KeywordUtil.logInfo("Clicking Element")
			WebUI.enhancedClick(to)
			WebUI.delay(3)
		}

Even though my Test case fails…

@Katalon_team @Russ_Thomas @nam.nguyen @duyluong

I do not understand by this sentence what you don’t like.

To me, apparently your test failed as it showed a :x: mark in red color.

Do you want any more?

Which “step” do you want to fail with :x:?

I am confused.
The Stack Trace shows a message “No alert found”. This indicates to me that you could not handle the alert.
So I do not see what you mean by saying “I know …”

I am clicking the element and then asking to check for the alert after few seconds of delay using a while loop. I am clicking the element again if there is no alert until there is alert found.

I update my code as below but still my Test case fails please help me @kazurayam

public static verifyAlertPresent(TestObject to) {
		WebUI.delay(3)
		KeywordUtil.logInfo("Inside While")
		while(!WebUI.verifyAlertPresent(3,FailureHandling.OPTIONAL)) {
			KeywordUtil.logInfo("Alert Not Present")
			KeywordUtil.logInfo("Clicking Element")
			WebUI.enhancedClick(to)
			WebUI.delay(5)
		}
}

Here I assume you are using Chrome browser.

Have you read this?

Chrome will intentionally closes Alert message when it is driven by Selenium and other test automation tools. Therefore, the your test script will ALWAYS find No Alert dialog.

I think you can not achieve what you want to do with Chrome.

Ok is there any solution will using capabilities work?

I don’t know.

But @Bailrod wrote something at

I tried it but was not successful let me try it again carefully

Thank you @kazurayam

if chrome stops supporting such automations, you guys should rethink your work.
honestly, how relevant is an automated test which should crash the browser?
such scenario should be tested manually, for the rest only sane possitive or negative tests should be automated.
whatever depends on the under the hood OS and is browser specific makes no sense to be automated since such can change overnight.
simply does not justify the effort to catch all cases