Here is a little ditty I wrote to scrape some jokes off a page for validation and reuse. You can expand this script to test against various browsers simply by turning the topLeft, bottomRight, topScroller, bottomScroller into image collections while adding additional SUT images to your suite. Also to note, is the trick to scroll up a bit, scrape, then scroll back down if the bottom of the page has not been reached and scraped.
-- URL in browser set to
-- http://4q.cc/index.php?pid=top100&person=chuck
set path to "/tmp/chucknorrisjokes.txt"
delete file path
TypeText homeKey
repeat forever
set topLefts to EveryImageLocation(topLeft)
set bottomRights to EveryImageLocation(bottomRight)
if not aboveAndLeftOf(item 1 of topLefts, item 1 of bottomRights) then \
delete item 1 of bottomRights
repeat with each aBottomRight in bottomRights
DragAndDrop item repeatIndex() of topLefts, aBottomRight
TypeCommand "c"
get remoteClipboard()
if it is not in file path then put it & return after file path
end repeat
if ImageFound(bottomScroller) then exit repeat
else TypeText upArrow, upArrow, upArrow
TypeText pageDown
end repeat
to aboveAndLeftOf pt1, pt2
return ( item 1 of pt1 <= item 1 of pt2 ) and \
( item 2 of pt1 <= item 2 of pt2 )
end aboveAndLeftOf
The scraped data is stored uniquely into a file, and at the end of the run we would need to either manually validate the existence of 100 expected unique jokes, or do it with script. Writing such a script would need a baseline data source of expected values. This is often the case in proper test conditions, but unique enough of a problem set to be left to the reader.
Although DragAndDrop has been deprecated to the EP 4.x Drag and Drop commands, I still like the concise nature of DragAndDrop. You also may note the use of a inline helper handler called AboveAndLeftOf pt1, pt2… This should be moved to a shared SenseTalk library. Last year I discussed it and related relative positional handlers for points in a posting.