我想删除此元素,以便不再使用node.js在页面上显示该元素,如何使用xpath或CSS选择器来做到这一点?
<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>
答案 0 :(得分:0)
您可以使用JavascriptExecutor并设置隐藏状态:
WebDriver driver;
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById('//id of element').setAttribute('style', 'visibility: hidden;')");
在Selenium中通过nodejs:
driver.executeScript("document.getElementById('//id of element').setAttribute('style', 'visibility: hidden;')");
答案 1 :(得分:0)
请参见another StackOverflow answer。调用JavascriptExecutor并在对象上使用.remove()
方法。