# Clicking by Coordintaes

**URL:** <https://forum.katalon.com/t/clicking-by-coordintaes/11501>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [June 13, 2018, 8:30am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501 "2018-06-13T08:30:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jolina\_Yao](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@Jolina\_Yao](https://forum.katalon.com/u/Jolina_Yao)\
**Post date:** [June 13, 2018, 8:30am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/1 "2018-06-13T08:30:25Z")

</div>

Currently have a webpage that has multiple buttons/icons with exact same id, class, etc…, wondering if there is a way to work around establishing test object and, instead, hard-codes the coordinates I want to click on?

---

<div class="post-metadata">

**Author:** ![Marek\_Melocik](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/marek_melocik/32/371_2.png) [@Marek\_Melocik](https://forum.katalon.com/u/Marek_Melocik)\
**Post date:** [June 13, 2018, 8:45am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/2 "2018-06-13T08:45:49Z")

</div>

Hi Jolina,

you can (coordinates from top left corner)

```auto
WebUI.clickOffset(testObject, coordX, coordY)

```

---

<div class="post-metadata">

**Author:** ![Jolina\_Yao](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@Jolina\_Yao](https://forum.katalon.com/u/Jolina_Yao)\
**Post date:** [June 18, 2018, 9:18am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/3 "2018-06-18T09:18:56Z")

</div>

I was aware of this function, but was confused on how to calculate the coordX and coordY offset values?

Also, in what unit is the offset encoded in?

---

<div class="post-metadata">

**Author:** ![Mate\_Mrse](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mate_mrse/32/345_2.png) [@Mate\_Mrse](https://forum.katalon.com/u/Mate_Mrse)\
**Post date:** [June 18, 2018, 9:33am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/4 "2018-06-18T09:33:26Z")

</div>

You can get element coordinates with JavaScript:

```auto
document.onmousemove = function(e){
var x = e.pageX;
var y = e.pageY;
e.target.title = "X is "+x+" and Y is "+y;
};

```

(enter this in dev tools console)

---

<div class="post-metadata">

**Author:** ![Waturu](https://avatars.discourse-cdn.com/v4/letter/w/cc9497/32.png) [@Waturu](https://forum.katalon.com/u/Waturu)\
**Post date:** [June 24, 2019, 4:43am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/5 "2019-06-24T04:43:07Z")

</div>

where is code to execute ? in script or keyword ?

---

<div class="post-metadata">

**Author:** ![HYN](https://avatars.discourse-cdn.com/v4/letter/h/67e7ee/32.png) [@HYN](https://forum.katalon.com/u/HYN)\
**Post date:** [July 23, 2019, 6:51pm UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/6 "2019-07-23T18:51:32Z")

</div>

Hi everyone,

How to click by coordintaes without element?

Thanks.

---

<div class="post-metadata">

**Author:** ![Mate\_Mrse](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mate_mrse/32/345_2.png) [@Mate\_Mrse](https://forum.katalon.com/u/Mate_Mrse)\
**Post date:** [July 24, 2019, 7:59am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/7 "2019-07-24T07:59:07Z")

</div>

Try using the `WebUI.clickOffset(testObject, coordX, coordY)` method, but set the testObject to the html `<body>` element.

---

<div class="post-metadata">

**Author:** ![HYN](https://avatars.discourse-cdn.com/v4/letter/h/67e7ee/32.png) [@HYN](https://forum.katalon.com/u/HYN)\
**Post date:** [July 24, 2019, 8:10am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/8 "2019-07-24T08:10:27Z")

</div>

It’s work fine. Thank you!!!

---

<div class="post-metadata">

**Author:** ![mikkili.rahul.tej](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mikkili.rahul.tej](https://forum.katalon.com/u/mikkili.rahul.tej)\
**Post date:** [July 29, 2019, 7:47am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/9 "2019-07-29T07:47:43Z")

</div>

Hi Mate ,

my Test Object is Iframe . i tried to use X and Y Coordinates also …its not working …can u suggest me any best way …??

Thanq

With Regards,  
Mikkky…

---

<div class="post-metadata">

**Author:** ![Mate\_Mrse](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mate_mrse/32/345_2.png) [@Mate\_Mrse](https://forum.katalon.com/u/Mate_Mrse)\
**Post date:** [July 29, 2019, 8:44am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/10 "2019-07-29T08:44:22Z")

</div>

@mikkili.rahul.tej

Have you switched to Iframe first?

---

<div class="post-metadata">

**Author:** ![mikkili.rahul.tej](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mikkili.rahul.tej](https://forum.katalon.com/u/mikkili.rahul.tej)\
**Post date:** [July 29, 2019, 8:59am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/11 "2019-07-29T08:59:52Z")

</div>

that things already done …tried to other way switch to window index also …but non of them worked.

can able to get in to the Iframe but cannot able to click on the object **bec file type hidden.**

---

<div class="post-metadata">

**Author:** ![Mate\_Mrse](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mate_mrse/32/345_2.png) [@Mate\_Mrse](https://forum.katalon.com/u/Mate_Mrse)\
**Post date:** [July 29, 2019, 9:58am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/12 "2019-07-29T09:58:16Z")

</div>

What exactly is your issue?  
What do you mean by “none of them worked”?  
Is this even related to clicking by coordinates?  
If not, it would be the best if you created a new thread, but first make sure to read this:

> [@\[TIP\] How To Help Us Help You!](http://forum.katalon.com/t/tip-how-to-help-us-help-you-my-test-is-broken-nothing-works-please-help-me/12919):
>
> My test is BROKEN! NOTHING WORKS! HELP ME! Relax. We get it. We really do. There are some pretty smart and clever people on this forum, but you must realize, they are not magicians or wizards or gods. They cannot see your code, they can’t see your errors and they don’t even know what your AUT is meant to do even though it might seem perfectly obvious to you. So please relax and follow the advice below, before you start writing your post. The advice below will tell you the exact information …

---

<div class="post-metadata">

**Author:** ![mikkili.rahul.tej](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mikkili.rahul.tej](https://forum.katalon.com/u/mikkili.rahul.tej)\
**Post date:** [July 29, 2019, 10:16am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/13 "2019-07-29T10:16:10Z")

</div>

Hi Mate,

I am trying to Click on upload text filed which is in Iframe but i cannot able to click.

**below is my code**

WebUI.mouseOver(findTestObject(‘Object Repository/PipelineProcess/Page\_Sales Performance Home/iframe’))  
WebUI.mouseOver(findTestObject(‘Object Repository/PipelineProcess/Page\_Sales Performance Home/iframe\_Supporting Documents \_’))  
WebUI.click(findTestObject(‘Object Repository/PipelineProcess/Page\_Sales Performance Home/input\_fileName’))

**using X and Y cordinates**

WebUI.clickOffset(findTestObject(‘Object Repository/PipelineProcess/Page\_Sales Performance Home/input\_fileName’), 280, 16)

Thanq  
With Regards,  
Mikky.

---

<div class="post-metadata">

**Author:** ![Mate\_Mrse](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mate_mrse/32/345_2.png) [@Mate\_Mrse](https://forum.katalon.com/u/Mate_Mrse)\
**Post date:** [July 29, 2019, 10:30am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/14 "2019-07-29T10:30:57Z")

</div>

See [https://docs.katalon.com/katalon-studio/docs/handling\_iframe\_issue.html#why-is-it-important-to-know-how-to-test-iframes](https://docs.katalon.com/katalon-studio/docs/handling_iframe_issue.html#why-is-it-important-to-know-how-to-test-iframes).

You need to use `WebUI.switchToIframe()` before interacting with the elements inside of the iframe.

---

<div class="post-metadata">

**Author:** ![mikkili.rahul.tej](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mikkili.rahul.tej](https://forum.katalon.com/u/mikkili.rahul.tej)\
**Post date:** [August 3, 2019, 7:38am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/15 "2019-08-03T07:38:01Z")

</div>

tried already …its not working …

---

<div class="post-metadata">

**Author:** ![ThanhTo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thanhto/32/697_2.png) [@ThanhTo](https://forum.katalon.com/u/ThanhTo)\
**Post date:** [August 3, 2019, 7:40am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/16 "2019-08-03T07:40:59Z")

</div>

Hi @mikkili.rahul.tej

Please provide the screenshots of the errors, visuals of the page containing the element that you want to click and the console log (copy paste the text in the console tab).

Cheers !

---

<div class="post-metadata">

**Author:** ![mikkili.rahul.tej](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mikkili.rahul.tej](https://forum.katalon.com/u/mikkili.rahul.tej)\
**Post date:** [August 3, 2019, 8:48am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/17 "2019-08-03T08:48:41Z")

</div>

![UploadIssue](https://europe1.discourse-cdn.com/katalon/original/2X/1/1e4159524e36534ed7a43f4a7525c92dfde8fd7d.png) ![Uploadissue2](https://europe1.discourse-cdn.com/katalon/original/2X/2/28c6c35425424c89823de3804350491ff4790040.png)

Console code  
Unable to click on object ‘Object Repository/Page\_Sales Performance Home/input\_fileName’ using offset x=310 and y=15 (Root cause: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/PipelineProcess/delete/Page\_Sales Performance Home/input\_fileName’ located by ‘By.xpath: id(“fileUploadTable”)/tbody[1]/tr[1]/td[1]/input[@class=“file hidden”]’ not found)e[0;39m  
2019-08-03 16:34:47.637 e[39mDEBUGe[0;39m e[36mtestcase.UploadFile -e[0;39m e[39m25: delay(20)

Script code …

WebUI.mouseOver(findTestObject(‘Object Repository/Page\_Sales Performance Home/iframe’))

WebUI.clickOffset(findTestObject(‘Object Repository/Page\_Sales Performance Home/input\_fileName’),310,15)

Hi Thanh To ,  
Appended as per your request

Thanq..

---

<div class="post-metadata">

**Author:** ![ThanhTo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thanhto/32/697_2.png) [@ThanhTo](https://forum.katalon.com/u/ThanhTo)\
**Post date:** [August 3, 2019, 10:59am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/18 "2019-08-03T10:59:54Z")

</div>

Are you certain about the coordinates of the objects ? How did you arrive at the coordinates ?

Another approach would be to execute javascript ( see `WebUI#executeJavascript` documentation).

> **[\[WebUI\] Execute JavaScript](https://docs.katalon.com/katalon-studio/docs/webui-execute-javascript.html)**
>
> Description   Execute JavaScript on the currently selected frame or window. The provided script fragment will be executed as the body of an anonymous function. Since 5.0 Parameters   Param...

First you would retrieve element at the coordinate, `WebUI#executeJavascript` will return a Selenium `WebElement` if an element at that coordinate exists, then you can use `click()` method on the `WebElement`.

> **[DocumentOrShadowRoot.elementFromPoint()](https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/elementFromPoint)**
>
> The elementFromPoint() method—available on both the Document and ShadowRoot objects—returns the topmost Element at the specified coordinates (relative to the viewport).

Cheers !

---

<div class="post-metadata">

**Author:** ![mikkili.rahul.tej](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mikkili.rahul.tej](https://forum.katalon.com/u/mikkili.rahul.tej)\
**Post date:** [August 5, 2019, 8:58am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/19 "2019-08-05T08:58:51Z")

</div>

Hi Thanh,

Ans1)i tried @Mate_Mrse script to find the coordinates .

Ans2)tried ur way using java script …created a custom keyword and called it in the script .but still having issue .

code

@Keyword

def ClickTO(TestObject to, int timeout) {

```
WebDriver driver = DriverFactory.getWebDriver();

WebElement element=WebUiCommonHelper.findWebElement(to ,timeout)

JavascriptExecutor executor=((driver) as JavascriptExecutor)

executor.executeScript('arguements[0].clcik()',element)

```

}

**Script**

CustomKeywords.‘keywordPackage.ClickTO.ClickTO’(findTestObject(‘Object Repository/input\_fileName’), 60)

**Log file error**

e[39mTest object with id ‘Object Repository/Pageormance Home/input\_fileName’ does not exist

but when the checked the Xpath .its working fine .

kindly suggest any thing i need to change .

**log view error**

keywordPackage.ClickTO.ClickTO:71

keywordPackage.ClickTO.ClickTO(findTestObject(“Object Repository/PipelineProcess/Page\_Sales Performance Home/input\_fileName”), 60) FAILED.  
Reason:  
java.lang.NullPointerException  
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElements(WebUiCommonHelper.java:704)  
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1008)  
at com.kms.katalon.core.webui.common.WebUiCommonHelper$findWebElement.call(Unknown Source)  
at keywordPackage.ClickTO.ClickTO(ClickTO.groovy:71)  
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:49)

Thanq

With Regards,  
Mikky.

---

<div class="post-metadata">

**Author:** ![lashabibilashvili198](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/lashabibilashvili198/32/13723_2.png) [@lashabibilashvili198](https://forum.katalon.com/u/lashabibilashvili198)\
**Post date:** [September 1, 2020, 11:20am UTC](https://forum.katalon.com/t/clicking-by-coordintaes/11501/20 "2020-09-01T11:20:47Z")

</div>

how to click by coordinates if I’m working on desktop applications?
