我需要检查已加载的特定图像(已收到资源)并通过img元素正确呈现(其他内容不与img重叠)。
我尝试过如下:
//push query of resource failed to download into the object with url as key
page.onResourceError = function( error ){
errors[ error.url ] = error
}
//get src of image to be checked
var src = page.evaluate(function( selector ){
return $( selector ).attr('src');
}, selector );
//check if resource in question has failed to be downloaded
if( errors[ src ] ){
//do stuff
}
这足以检查资源是否已下载?如何获取实际资源主体并将其与phantomjs制作的屏幕截图进行比较。