这是我用来查看图像是否存在的简单脚本。有什么方法可以使用选择器保存图像以查看它是否存在?这是我的代码:
var casper = require('casper').create();
casper.start('https://example.ws/', function() {
this.echo(this.getTitle());
});
casper.thenOpen('https://example.ws/login.html', function() {
this.echo(this.getTitle());
if (this.exists('img#cpt_img')) {
this.echo('the heading exists');
}
});
casper.run();
最佳答案
您可以使用 download() 方法:
this.download(
this.getElementAttribute('img#cpt_img', 'src'),
"my_image.png"
);
关于css - 如何将图像保存到临时文件以备后用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22336077/