Reputation: 1634
Considering these simple html:
<html>
<body>
<h1 id='h1'>hello casperjs</h1>
<a href='javascript: rmH1()'>remove</a>
<script>
function rmH1(){
document.getElementById('h1').remove();
}
</script>
</body>
</html>
By clicking the a
element the h1
element is removed.
And next is my js code written in coffeescript:
casper = require('casper').create()
casper.start 'file:///Users/username/my.html', ->
@capture 'before.png'
@evaluate ->
rmH1()
@capture 'after.png'
casper.run()
However from the screenshots the h1
element was not removed as well.
How do I correctly call the remote function rmH1()
?
Upvotes: 0
Views: 88
Reputation: 61952
There is no such thing as element.remove()
. You should use
var h1 = document.getElementById('h1');
h1.parentNode.removeChild(h1);
Had you listened to the "page.error"
event, you would have seen that remove
is not a function.
Upvotes: 1