About 5 years ago this question was asked:
"On a web page in my web browser (preferably, but not necessarily Firefox), I can search (byctrl+f) for a given text "abc" within the body text of the page. From there then I must move the mouse cursor to another (relative) position (height plus x pixels), and there I must do a mouse click.
I cannot do this otherwise since the needed info is not contained in the source code but is fetched by mouse click from the web server. The problem for me is to identify the position of the found text "abc", in order to move the mouse cursor there; from there it's easy.
I currently try to solve my problem by searching for the background color which changes for the text "abc" when found, but the same color is found in lots of other positions on the screen, so this is unreliable, and finding the text "abc" as a graphic is unreliable, too. So I'm looking for an alternative, programmatic way to identify the position of found text, if there is any."
==> I'm currently facing the same problem and so far haven't really found a solution! I'm using Python, but libraries such as pyautogui do not include any way (as far as I can tell) of obtaining the position of text located via Ctrl-F. I'm hoping for some solution that works under Windows and Linux, if possible. Any solutions/workarounds/suggestions would be greatly appreciated! Wayne
You can use
locationof python to get coordinates of an element.Output:
I would also like to say that the coordinates would vary with different screen dimensions.