Hi friend,
getElementByClassName is not a method on document. You'll want to use
getElementsByClassName('classname')[0]...
but only if you are sure it's the only one with that class.
And you can also do this:
element = driver.find_element_by_class_name('classname')
driver.execute_script("string"
var element = arguments[0];
element.parentNode.removeChild(element);
"", element)
Or you can use a solution that relies on JavaScript to find the element:
driver.execute_script(" "
var element = document.querySelector(".classname");
if (element)
element.parentNode.removeChild(element);
" ")
This solution is much better if you use a remote server to run the tests (like BrowserStack and so on) but there's a non-negligible cost for communication between the Selenium client and the server.
This worked for me. Check it out!