Is it possible to remove a html element using nightmarejs?

335 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 answers

0
Benjamin Charais 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
scott On
var test = new Nightmare()
  .goto("https://www.google.com")
  .evaluate(function() {
    var element = document.getElementById(elementId);
    element.parentNode.removeChild(element);
  });