0

I would like to delete this element so it is not showed anymore on my page, using node.js, how could i do this using xpath or css selector?

<div class="antigate_solver recaptcha solved"><a class="status" tabindex="0" title="AntiCaptcha: Captcha solving status"></a><a class="control" title=""></a></div><div class="antigate_solver recaptcha solved"><a class="status" tabindex="0" title="AntiCaptcha: Captcha solving status"></a><a class="control" title=""></a></div>
Zayonx
  • 164
  • 1
  • 12

1 Answers1

-2

Based on this StackOverflow answer, you may call the JavascriptExecutor and use the .remove() method on the object that you want to get rid of. Note this way of doing it requires an id on the element; however it can be generalized to remove elements of a certain class as well by changing getElementById to getElementsByClassName.

WebDriver driver = new ChromeDriver();
JavascriptExecutor js;
if (driver instanceof JavascriptExecutor) {
    js = (JavascriptExecutor) driver;
}
js.executeScript("return document.getElementById('element-to-remove').remove();");
Erica Kane
  • 3,137
  • 26
  • 36