Categories
javascript python selenium

Python selenium, how can i delete an element?

I’ve been trying the last hour to delete an element by without any success. And the element can only be reached via class name.
I’ve tried:

js = "var aa=document.getElementsByClassName('classname')[0];aa.parentNode.removeChild(aa)"
driver.execute_script(js)

I get error that parentNode is undefined.

So what the best way to delete an element using Selenium?