How to get the correct location of an element after scrolling to it?

I am trying to determine the position of a specific element on a webpage after scrolling to it using JavaScript.

Questions:
How can I accurately get the position of an element after scrolling to it?
Are there any common pitfalls or additional steps I should be aware of?
Any help or suggestions would be greatly appreciated!

Using getBoundingClientRect() after scrolling.
Checking position values before and after scrolling.
Ensuring no CSS transformations are affecting the element’s position.
Testing with SeleniumBase’s bounding_box() method.
Testing with Playwright to capture element positions.