You can use Chrome (version 59 and above) in a headless mode to do this type of thing. See Google's getting started page for that.
It looks like you can use the WWW:Mechanize::Cheom to drive headless chrome from perl. But if that doesn't work well, there is a Node.js module called Puppeteer bug Google (described in the link above) that you could use (by running a node.js program as an external command from perl). That is less efficient, and would require yet another dependency for WeBWorK (node), but it might work.
Or you might just be able to get away with running headless chrome directly (examples for creating screen snapshots are in the link above).
Is it going to be a security concern to enable WW problems to activate a headless browser?
Probably, but I can't think of an exploit off the top of my head.
Once I have the base64, how to bring it to life as an image in the tex? I'd go looking for perl modules that could decode the base64 and write it as a temporary file, and include the image in the tex in the usual way.