Scroll to Position - How to find x and y co-ordinates?

Hi All,

I have to scroll to certain column in ag-grid table using Scroll To Position.

Position I want to reach is highlighted.
How do we get x and y co-ordinates to pass into this function?
Please can anyone guide me on this?

Thanks in advance.

Sorry, but this sounds more like a homework assignment than testing a browser page. The “problem” with X and Y would be the page size, the screen resolution and others. Setting the page to maximum (like below) will set page size. Otherwise, bring up the code Inspect and look in the corner at your settings for your web page, then try some tests estimates less than the max less the insets.


Another method to get the highlighted cell is to create a table and move through the column, row by row, breaking when you have the value you want (unless your assignment states specifically). Tables and moving through them are discussed in other tutorials and questions, such as:

Once you have the specific column WebElement, you can use, getLocation() that returns a Point object, which gives you the X and Y position,

‘get the x position of the sixth column’
int spotX = myColumns.get(5).getLocation().getX();
‘get the y position of the sixth column’
int spotY = myColumns.get(5).getLocation().getY();

or use, getRect() that returns the upper left X and Y, as well as the height and width of the cell.

Just a note that you may need a fudge factor added to the X and subtracted from the Y. The X and Y are the corner positions. If you want to ensure you are inside the cell, then you need the fudge factor added/subtracted from the starting position.

@helpdesk Thanks for the detailed reply. But In this case, Scroll to Position isn’t working as the table I am dealing with is an ag-grid table, and the problem here is not all of the rows are in the DOM until we scroll to their position . So Katalon throws the error “Unable to locate element” when I use Scroll to element and when I use Scroll to Position , Scroll action is not happening.

Facing somewhat similar issue as this but I need horizontal scroll for Ag-Grid table. Scroll To Position does not load hidden elements