Reputation: 28486
Using CasperJs, I'm trying to do some testing on canvas, by grabbing it and using canvas.toDataURL();
. However, the canvas does not have an id, the code looks something like this:
<div id= 'derp' ...>
<canvas ...> </canvas>
</div>
Can I still get the canvas using something like
var canvas = document.getElementById(????);
or is there a better way of grabbing the canvas?
Upvotes: 8
Views: 15403
Reputation: 61
You can also list all the canvas with this:
document.getElementsByTagName('canvas')
Upvotes: 6
Reputation: 887195
You can use CSS selectors:
document.querySelector('#derp canvas')
Upvotes: 14