Is it possible to remove a html element using nightmarejs?

377 Views Asked by At

I would like to know how to remove a html element based on its id when I load a website using nightmare js.

Thanks

2

There are 2 best solutions below

0
On BEST ANSWER

You are capable of using the .evaluate() method so that you can then run vanilla JS code, in which you could use a JQuery command to accomplish what you need...

var test = new Nightmare()
  .goto("https://www.google.com")
  .evaluate(function() {
    $("#selectorID").remove();
  });
0
On
var test = new Nightmare()
  .goto("https://www.google.com")
  .evaluate(function() {
    var element = document.getElementById(elementId);
    element.parentNode.removeChild(element);
  });