# Alerts are displayed, but disappear before I can accept it

**URL:** <https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318>\
**Category:** Bug Report\
**Tags:** tracked, bugs-report, katalon-studio\
**Created:** [November 24, 2021, 1:05am UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318 "2021-11-24T01:05:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Loo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/matthew_loo/32/20464_2.png) [@Matthew\_Loo](https://forum.katalon.com/u/Matthew_Loo)\
**Post date:** [November 24, 2021, 1:05am UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/1 "2021-11-24T01:05:43Z")

</div>

#### Please let us know what you are using Katalon Studio for?

I’m testing the Clear Cache link on my page.  
My automation is clicking the link and as a result of the click, an alert would normally appear and wait to be accepted.  
I would accept the alert and continue on with the rest of the test.

However it seems to appear and disappear straight away, before I can accept it. This is causing the acceptAlert() to fail because the alert is no longer there to be accepted.

#### How would your work be affected if this issue has not been resolved?

Alerts on other pages are appearing and disappearing as well, before it can be accept it, which is causing my test to fail

#### Operating System

Windows 10

#### Katalon Studio Version

version 8.2.0 build 208

#### Katalon Studio logs

[log.txt](https://forum.katalon.com/uploads/short-url/5EenFJznjYIGjC9wrRCxsKn9KwB.txt) (205.7 KB)

#### Screenshots / Videos

[2021-11-24\_13h32\_18.7z](https://forum.katalon.com/uploads/short-url/jvlaJ3nt60utvsfjNLcWBuYqUhD.7z) (2.6 MB)

In this video you can see something appear in the top left of the screen and then disappear.

#### Environment (for Web testing):

Microsoft Edge  
Version 96.0.1054.29 (Official build) (64-bit)

Chrome  
Version 96.0.4664.45 (Official Build) (64-bit)

#### Steps to reproduce:

create a test case that ensures an alert will appear and acceptAlert

WebUI.waitForAlert(5)  
WebUI.acceptAlert()

#### Expected Behavior:

I expect the WebUI.acceptAlert() to be able to accept the alert when it appears.

I run through the test manually and the alert appears and waits for me to accept it, this is working as expected.

#### Actual Behavior:

The alert appears and disappears before it can be accepted and causes my test to fail.

---

<div class="post-metadata">

**Author:** ![h.kramer](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/h.kramer/32/16103_2.png) [@h.kramer](https://forum.katalon.com/u/h.kramer)\
**Post date:** [November 24, 2021, 2:25pm UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/2 "2021-11-24T14:25:50Z")

</div>

Hi Matthew, Well described, this is my problem too. Is it related to the new update 8.2. Before that, the problem didn’t exist.

---

<div class="post-metadata">

**Author:** ![Matthew\_Loo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/matthew_loo/32/20464_2.png) [@Matthew\_Loo](https://forum.katalon.com/u/Matthew_Loo)\
**Post date:** [November 24, 2021, 7:22pm UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/3 "2021-11-24T19:22:09Z")

</div>

I noticed the Webdrivers are not updating, I’m getting the following. It could be related

[ERROR] Driver for chrome not found (valid browsers chrome|firefox|opera|edge|phantomjs|iexplorer|selenium\_server\_standalone)

Warning: There are some errors during “Updating web driver…”. The results may not be as expected.

---

<div class="post-metadata">

**Author:** ![nam.nguyen](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/nam.nguyen/32/18640_2.png) [@nam.nguyen](https://forum.katalon.com/u/nam.nguyen)\
**Post date:** [November 25, 2021, 10:19am UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/4 "2021-11-25T10:19:49Z")

</div>

Hi @Matthew_Loo,

Could you please provide us with more information about these items?

- Your current WebDriver version
- Execution log
- Script sample to reproduce this issue

And have you faced this issue with the previous versions?

Regards,  
Nam Nguyen.

---

<div class="post-metadata">

**Author:** ![h.kramer](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/h.kramer/32/16103_2.png) [@h.kramer](https://forum.katalon.com/u/h.kramer)\
**Post date:** [November 25, 2021, 3:21pm UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/5 "2021-11-25T15:21:32Z")

</div>

It goes so fast that there is indeed no possibility to click on it. This is a photo of a recording.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/7/9/792d720e6c9c553380d638832dd6999c01530a2c.jpeg)

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/0/f/0fe0f442251d347bbe29b30de9ff56215066e79c.jpeg)

---

<div class="post-metadata">

**Author:** ![Matthew\_Loo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/matthew_loo/32/20464_2.png) [@Matthew\_Loo](https://forum.katalon.com/u/Matthew_Loo)\
**Post date:** [November 28, 2021, 8:02pm UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/6 "2021-11-28T20:02:50Z")

</div>

Maybe you can help me out here and give me instructions on how I can find the current WebDriver version.  
at the moment I’m just trying to update to the latest drivers and I’m getting an error either it’s installed a bad driver, or I’m still running with an out of date driver. I wouldn’t know.

---

<div class="post-metadata">

**Author:** ![Matthew\_Loo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/matthew_loo/32/20464_2.png) [@Matthew\_Loo](https://forum.katalon.com/u/Matthew_Loo)\
**Post date:** [November 28, 2021, 9:52pm UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/7 "2021-11-28T21:52:19Z")

</div>

**I’ve create alert.html to simulate the alert opening in the browser.**

- If you execute the file directly from the browser, you will see that the alert does not flash on and then off, it waits for input.

- if you execute the test script, you will see it flash on and then off.

[alert.html](https://forum.katalon.com/uploads/short-url/5pRplFGczHx9QShIoD7LL7HorAP.html) (245 Bytes)

**The following test script will open the alert.html and display the alert, and attempt to accept it.**  
**Of course you need to change the path to where ever you saved the alert.html**

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject  
import org.openqa.selenium.WebDriver as WebDriver  
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory  
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI  
import internal.GlobalVariable as GlobalVariable  
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile  
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW  
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS  
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows  
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW  
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject  
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData  
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase  
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint  
import com.kms.katalon.core.model.FailureHandling as FailureHandling  
import com.kms.katalon.core.testcase.TestCase as TestCase  
import com.kms.katalon.core.testdata.TestData as TestData  
import com.kms.katalon.core.testobject.TestObject as TestObject  
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint  
import org.openqa.selenium.By;  
import org.openqa.selenium.WebElement;

WebUI.openBrowser(‘’)

WebUI.navigateToUrl(‘f:\Testing\alert.html’)

WebDriver wd =DriverFactory.getWebDriver();

WebElement elementOpen = wd.findElement(By.xpath(“/html/body/button”));

elementOpen.click();

println(‘aaaaa’)  
WebUI.verifyAlertPresent(5)

WebUI.acceptAlert()  
println(‘bbbbbb’)  
WebUI.delay(5)

---

<div class="post-metadata">

**Author:** ![Matthew\_Loo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/matthew_loo/32/20464_2.png) [@Matthew\_Loo](https://forum.katalon.com/u/Matthew_Loo)\
**Post date:** [November 28, 2021, 9:59pm UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/8 "2021-11-28T21:59:06Z")

</div>

This is the execution log I get when I run it  
[executionlog.txt](https://forum.katalon.com/uploads/short-url/w0hfkB3OWv5SvzQa1Eo7UjbAOYN.txt) (9.5 KB)

---

<div class="post-metadata">

**Author:** ![Matthew\_Loo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/matthew_loo/32/20464_2.png) [@Matthew\_Loo](https://forum.katalon.com/u/Matthew_Loo)\
**Post date:** [November 28, 2021, 10:23pm UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/9 "2021-11-28T22:23:49Z")

</div>

Thanks Heidi, for adding your supporting details

Matt

---

<div class="post-metadata">

**Author:** ![mpokvytyte](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mpokvytyte/32/18752_2.png) [@mpokvytyte](https://forum.katalon.com/u/mpokvytyte)\
**Post date:** [December 1, 2021, 2:18pm UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/10 "2021-12-01T14:18:41Z")

</div>

guys, this is major inconvenience ant it really upsets me that after almost every version update there are issues. this software is created and used for automation testing, yet it is apparent that your own regression testing process before the releases is flawed. This is the last chance you are getting from me, I have wasted two days trying to fix the issue, then realizing this must be your software’s issue, now a big chunk of my tests doesn’t work, which caused even more work for me as they have to be run manually. when is this going to be fixed?

---

<div class="post-metadata">

**Author:** ![Matthew\_Loo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/matthew_loo/32/20464_2.png) [@Matthew\_Loo](https://forum.katalon.com/u/Matthew_Loo)\
**Post date:** [December 1, 2021, 7:30pm UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/11 "2021-12-01T19:30:24Z")

</div>

Okay, since I didn’t get a reply from you, I decided to spend a little bit of time to find the drivers and I found this, it’s strange the folder for the Chrome driver is labeled with win32, not sure whether that’s significant or not, just thought I would mention it.

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/a/f/afc90eea0927817430b6a6da6cc0795d992543eb.png)

the chrome driver version is

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/e/b/eb3c5ad16c46e74ebc6de8518cf44b62f4594ff1.png)

---

<div class="post-metadata">

**Author:** ![Matthew\_Loo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/matthew_loo/32/20464_2.png) [@Matthew\_Loo](https://forum.katalon.com/u/Matthew_Loo)\
**Post date:** [December 3, 2021, 12:38am UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/12 "2021-12-03T00:38:30Z")

</div>

Here’s a handy bit of information.

Terminate the running webdrivers before doing a webdriver update , this will mitigate any driver update issues. Not sure why Katalon doesn’t do it as part of it’s webDriver update process and It didn’t resolve the Alert issue. that’s still a problem

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/6/0/60ad13011cec4be511947a6a0dbf84905c0b2386.png)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [December 4, 2021, 5:43am UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/13 "2021-12-04T05:43:41Z")

</div>

> [@Matthew\_Loo](#):
>
> However it seems to appear and disappear straight away,

I could not see any Alert coming up in [the video](http://forum.katalon.com/uploads/short-url/jvlaJ3nt60utvsfjNLcWBuYqUhD.7z), so I’m confused.

---

<div class="post-metadata">

**Author:** ![Matthew\_Loo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/matthew_loo/32/20464_2.png) [@Matthew\_Loo](https://forum.katalon.com/u/Matthew_Loo)\
**Post date:** [December 6, 2021, 10:16pm UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/14 "2021-12-06T22:16:19Z")

</div>

here it is

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/3/b/3b0ad77888df913feaf75a6ff9af073dde985a56.jpeg)  
and that’s the point. It flashes on and off, it doesn’t even have a chance to display text. It doesn’t stay on the screen. So it’s not visible and I can’t accept it, which causes my test to fail.

Watch the video again, even better pause the video and move the video to the same position in the image

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [December 7, 2021, 1:32am UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/15 "2021-12-07T01:32:53Z")

</div>

> [@Matthew\_Loo](#):
>
> [alert.html](https://forum.katalon.com/uploads/short-url/5pRplFGczHx9QShIoD7LL7HorAP.html) (245 Bytes)

I tried to reproduce your issue on my side usig the alert.html you shared. Yes, I could.

I executed thiis:

```auto
import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
import com.kms.katalon.core.model.FailureHandling as FailureHandling

import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

WebUI.openBrowser("")
WebUI.navigateToUrl("http://localhost/alert.html") // I have a HTTP Server at http://localhost which makes the katalon project accessible as a web site. It does nothing special.
WebDriver wd = DriverFactory.getWebDriver();
WebElement elementOpen = wd.findElement(By.xpath("/html/body/button"));

elementOpen.click()

boolean present1 = WebUI.verifyAlertPresent(5, FailureHandling.STOP_ON_FAILURE)
// this line passed; it meas an Aleart is there.
println("present1 :" + present1)

WebUI.delay(3)

// we will check if the Aler is still there...
boolean present2 = WebUI.verifyAlertPresent(1, FailureHandling.CONTINUE_ON_FAILURE)   
// Chrome+FF+Edge; this line failed; it means no Alert is there.
// Safari; thiis line passed; it means an Alert is thre. Safari seems to be a bit loose.                                                  
println("present2? :" + present2)

WebUI.closeBrowser()

```

on Chrome, Edge Chromium, FireFox, the 2nd `WebUI.verifyAlertPresent()` failed because the Alert has already disappeared automatically.

Interesting enough, on Safari, the 2nd `WebUI.verifyAleartPresent()` passed. I could see the Alert dialog stayed displayed on the screen.

So I guess that the newer version of security-conscious browsers (Chrome, Edge, FireFox) intentionally automatically closes Alert dialogs when a browser is controlled by software automation  
like Selenium. I tried to search on Google for relevant articles on this issue, but I couldn’t find any.

I guess, Safari is outdated. Safari seems to be less security-conscious.

@Matthew_Loo  
You may want to use Safari for this test. Safari seems to be your sole friend. 😉 But even Safari may change in future.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [December 7, 2021, 1:45am UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/16 "2021-12-07T01:45:25Z")

</div>

For your information, see this

> **[Sign in with a supported browser - Android - Google Account Help](https://support.google.com/accounts/answer/7675428?co=GENIE.Platform%3DAndroid&hl=en)**
>
> To help protect your account, Google doesn’t let you sign in from some browsers. Google might stop sign-ins from browsers that: Don’t support JavaScript or have JavaScript turned off Have unsecu

> To help protect your account, Google doesn’t let you sign in from some browsers. Google might stop sign-ins from browsers that:  
> …  
> Are being controlled through software automation rather than a human

This is a proof that _Chrome behaves specially when it is controlled by selenium_.

I guess browsers may do something special for Alert. Alert dialog could be risky because malicious software may use Alerts to invade your peaceful life.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [December 7, 2021, 2:05am UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/17 "2021-12-07T02:05:26Z")

</div>

Some people argue that we should not use JavaScript `alert` in productional web application. See, for example, this.

> <https://stackoverflow.com/questions/20359807/why-shouldnt-i-use-alert-in-javascript>

---

<div class="post-metadata">

**Author:** ![Matthew\_Loo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/matthew_loo/32/20464_2.png) [@Matthew\_Loo](https://forum.katalon.com/u/Matthew_Loo)\
**Post date:** [December 7, 2021, 3:19am UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/18 "2021-12-07T03:19:33Z")

</div>

That’s not a very satisfactory answer, as you pointed out it’s only a matter of time before Safari starts acting the same way. The application I’m testing relays on alerts to confirm deletions, changes and saves. so you can imagine how redundant all my test cases and test suites have become. This must be happening to other tester out there, I’m surprised there isn’t a bigger commotion about this.

Also changing the way alerts are implemented , because my automation is broken would not fly with the development team. There’s time and cost to do this, especially when it works fine under normal conditions. There are much higher priorities, this would rank very lower or not at all.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [December 7, 2021, 3:57am UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/20 "2021-12-07T03:57:10Z")

</div>

> [@Matthew\_Loo](#):
>
> because my automation is broken would not fly with the development team.

You should try it.

If my guess — Chrome, Edge, FF does not allow automation software to test alerts, which would indicate the foreseeable direction of browser technology — is right, I think you should at least report to the development managers. You should tell them: “our application is not testable by Selenium at all due to javascript alert()!”

IMHO, they should not use JavaScript alert() for productional use cases.

There are alternatives how to implement alert dialog. For example,

- [Bootstrap alert](https://getbootstrap.com/docs/4.0/components/alerts/)

JavaScript “alert()” is not the only way.

---

<div class="post-metadata">

**Author:** ![h.kramer](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/h.kramer/32/16103_2.png) [@h.kramer](https://forum.katalon.com/u/h.kramer)\
**Post date:** [December 7, 2021, 12:14pm UTC](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318/21 "2021-12-07T12:14:51Z")

</div>

Dave-Evers, message helped me. Thanks Dave! [Execute Javascript Alert Disappears](http://forum.katalon.com/t/execute-javascript-alert-disappears/34808/6)

[Next page](https://forum.katalon.com/t/alerts-are-displayed-but-disappear-before-i-can-accept-it/60318.md?page=2)
