I’m looking for a library, or a strategy, that can be used, ideally in conjunction with Ruby/Nokogiri, to determine the layout location of items on a web page, when viewed in the browser.
For example, in the current page I’m looking at, there is a “Ask Question” button in the top right corner (I am guessing in the header). If, for example, I wanted to see where the all the words “question” are on the page, which would match this word, and other places hat have the word question, in terms of XY coordinates or pixels, how would I do that?
I clearly have to load the CSS. But, what else?
Any suggestions would be appreciated.
The Watir project might be able to help, as it talks directly to the browser, allowing you to get information about a page after the browser has finished rendering it. You’ll need to look through the API to see if you can get the pixel locations for elements.
Pixel locations will be difficult though, because those are tied to font sizes and a real-human user could have something that is overriding the settings applied by the CSS. The information you get from a browser in your testing could vary wildly from what a real user would see. That might, or might not, be an issue for you.