# JavaScript clicks required for headless mode execution?

**URL:** <https://forum.katalon.com/t/javascript-clicks-required-for-headless-mode-execution/49138>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [November 11, 2020, 5:47pm UTC](https://forum.katalon.com/t/javascript-clicks-required-for-headless-mode-execution/49138 "2020-11-11T17:47:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [November 11, 2020, 6:26pm UTC](https://forum.katalon.com/t/javascript-clicks-required-for-headless-mode-execution/49138/2 "2020-11-11T18:26:57Z")

</div>

> [@Jeff\_Feldman](#):
>
> This feels like it makes the use of Katalon as a whole a lot less desirable for web UI testing.

I do this a lot - I don’t think it’s “less desirable” if (that’s a big **IF** ) you know what you’re doing - read on…

> [@Jeff\_Feldman](#):
>
> Just curious if anyone has any feedback on this? Am I wrong in converting Katalon ‘Click’ keywords to JavaScript clicks when I receive these errors in Headless mode? Is there still value in using Katalon even if their ‘Click’ keyword fails frequently in headless mode? Is there a better way to manage this?

That’s a ton of questions which I’ll answer together…

The number one issue with going the JavaScript route is inherent in the DOM element click API (i.e., it’s not JavaScript’s fault). Your click code (your click event) is applied to the element _regardless_ of its availability. What does that mean?

1. You can click an invisible element.
2. You can click an element that is not visible in the viewport (it’s “off screen”).
3. You can click on an element obscured by other elements (visible or not).
4. Anything else you can think of…

All of which leads to this simple fact: your code can do things a user cannot do. You _could_ pass a test that _should_ fail.

And that’s why I said, “if you know what you’re doing”, above. If you take reasonable precautions to ensure the target element is “visible to a human” and is ready to receive clicks, I see no issue with using JavaScript when all other means at your disposal have failed to accomplish your goal.

It’s for this reason that the Katalon devs developed **[WebUI.enhancedClick](https://docs.katalon.com/katalon-studio/docs/webui-enhanced-click.html)** – as a last resort, that API tries a JavaScript click if other methods fail.

Hope that helps…

---

_[View the full topic](https://forum.katalon.com/t/javascript-clicks-required-for-headless-mode-execution/49138)._
