0
考慮到這些簡單的HTML遙控功能:未能評估casperjs
<html>
<body>
<h1 id='h1'>hello casperjs</h1>
<a href='javascript: rmH1()'>remove</a>
<script>
function rmH1(){
document.getElementById('h1').remove();
}
</script>
</body>
</html>
通過點擊a
元素h1
元素被刪除。
而接下來是我的js代碼寫成的CoffeeScript:
casper = require('casper').create()
casper.start 'file:///Users/username/my.html', ->
@capture 'before.png'
@evaluate ->
rmH1()
@capture 'after.png'
casper.run()
但是從截圖沒有被移除,以及在h1
元素。
如何正確調用遠程功能rmH1()
?
不重複,但可能會提供一些見解:[CasperJS評估](http://stackoverflow.com/questions/11864373/casperjs-evaluate) – royhowie