# \[KShare\] How to work better with Browser Alerts with custom keywords?

**URL:** <https://forum.katalon.com/t/kshare-how-to-work-better-with-browser-alerts-with-custom-keywords/108506>\
**Category:** Kshare\
**Tags:** linh-nguyen, thong-tran, gatedknowledge, support, start-page, custom-keyword, katalon-studio\
**Created:** [November 27, 2023, 11:16am UTC](https://forum.katalon.com/t/kshare-how-to-work-better-with-browser-alerts-with-custom-keywords/108506 "2023-11-27T11:16:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![support.squad](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/support.squad/32/23139_2.png) [@support.squad](https://forum.katalon.com/u/support.squad)\
**Post date:** [November 27, 2023, 11:16am UTC](https://forum.katalon.com/t/kshare-how-to-work-better-with-browser-alerts-with-custom-keywords/108506/1 "2023-11-27T11:16:42Z")

</div>

### How to work better with Browser Alerts with custom keywords?

Have you ever encountered a situation where you were unable to successfully complete activities on a browser alert **because it disappeared too quickly**?

If yes, then please find the custom keyword provided below

The solution is a custom keyword that you can put under the “Keywords“ folder of the Katalon Projects

[KatalonAlert.groovy](https://forum.katalon.com/uploads/short-url/ojRViSN7tAzscEUXEORBkcxErcU.groovy) (6.8 KB)

Accepting Next Alert pop-up and Verify present Alert:

```auto
// Accept the next confirm popup
CustomKeywords.'KatalonAlert.acceptNextAlert'()
WebUI.click(findTestObject('Object Repository/login/Button_Login'))
// Verify alert present
CustomKeywords.'KatalonAlert.handleNextAlert'()
WebUI.click(findTestObject('Object Repository/login/Button_Login'))
CustomKeywords.'KatalonAlert.verifyAlertPresent'()

```

1. Please note that the keyword `acceptNextAlert` **must be called before we trigger the alert** (e.g. click login button) or if you want to use `a verify keyword` , then you have to call one of `handleNextAlert` , `acceptNextAlert`, `denyNextAlert` before the alert trigger as well.

2. **There must be no delay between the alert trigger** (e.g. click login button) and the verify keyword (e.g. verifyAlertPresent). For example, the below script will produce an error:

```auto
CustomKeywords.'KatalonAlert.acceptNextAlert'()
WebUI.click(findTestObject('Object Repository/login/Button_Login'))
WebUI.delay(3) // Don't delay here
CustomKeywords.'KatalonAlert.verifyAlertPresent'()

```

Let us know if the custom keywords that we have provided works for you. And if they do, then don’t forget to show us some love by clicking on the like button below ❤!

And feel free to leave us your feedback so that we could improve our articles in the future!

* * *

We also have other topics related to working with custom keywords in Katalon Studio, check them out below 👇

> 📌 [How to use the **Windows.switchToDesktop()** custom keyword to switch window faster?](http://forum.katalon.com/t/kshare-how-to-use-the-windows-switchtodesktop-custom-keyword-to-switch-window-faster/108501)
> 
> 📌 [How to use the **WebUI.setText()** custom keyword successfully?](http://forum.katalon.com/t/kshare-how-to-use-the-webui-settext-custom-keyword-successfully/108503)
> 
> 📌 [How to use the **WebUI.dragAndDropToObject** custom keyword successfully?](http://forum.katalon.com/t/kshare-how-to-use-the-webui-draganddroptoobject-custom-keyword-successfully/108504)
> 
> 📌 [How to work better with Browser Alerts?](http://forum.katalon.com/t/kshare-how-to-work-better-with-browser-alerts-with-custom-keywords/108506) → You are here

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [November 27, 2023, 11:57am UTC](https://forum.katalon.com/t/kshare-how-to-work-better-with-browser-alerts-with-custom-keywords/108506/2 "2023-11-27T11:57:33Z")

</div>

Thank you Product Support team (@support.squad) as always for this insightful topic. And also a big shout-out to the two individuals below for your contribution to this topic:

| ![Linh Nguyen](https://europe1.discourse-cdn.com/katalon/original/3X/8/4/84e17374fb62b33f2d3ea89a16c9bf09f01aaf0b.png) | ![Thong Tran](https://europe1.discourse-cdn.com/katalon/original/3X/2/4/2473c611894c7134b42923bcd8045dfc1afcef73.png) |
| --- | --- |
| **Linh Nguyen** (@linh.nguyen) - Product Support Manager at Katalon | **Thong Tran** (@thong.tran) - Senior Software Engineer at Katalon |
| Linh is the Product Support team Manager at Katalon. She spent many years working as an Automation Testing QA before joining Katalon Product Support as a technical support expert. Based on her experiences, she usually provides customers with highly applicable solutions. She now manages her team with a user-centric approach to guarantee customers greater success with Katalon Products. | A passionate Katalon developer with a wealth of programming and testing expertise. Thong has been dedicated to providing exceptional enterprise support for the past five years, helping Katalon’s customers achieve their testing goals with ease. |

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [March 12, 2024, 3:12am UTC](https://forum.katalon.com/t/kshare-how-to-work-better-with-browser-alerts-with-custom-keywords/108506/7 "2024-03-12T03:12:34Z")

</div>

Do you have an idea for a topic that you would like the Product Supoprt team to cover in their next [KShare](http://forum.katalon.com/docs?ascending=false&solved=false&tags=support) article? Then share them with us by simply fill in the form below 👇

> **[\[KShare\] Your feedback matters!](https://forms.gle/v8FVQ2GFMk4Dcuox9)**
>
> Have an idea for which topic we should cover in our KShare articles next? Then let us know in this form!
