How can I delete an element in Selenium using Python

How can I delete an element in Selenium using Python?

Hi Tom Dale,

You can directly delete the node using the following script, without having to refer to parent:

js_string = "var element = document.getElementById(\"element_id\");element.remove();"
browser.execute_script(js_string)

If you have the reference to the element, you can get the id using selenium :

element.get_attribute(id)