I want to hide elements on canvas element by executing a javascript in python.
I have tried below:
def hide_elements():
driver = LiveLibrary.get_webdriver_instance()
js_script = '''\
element1 = document.getElementsByClassName('someclass');
element1[0].style.display = 'none';
element2 = document.getElementsByClassName('another');
element2[0].style.display = 'none';
element3 = document.getElementsByClassName('highlight');
element3[0].style.display = 'none';
element4 = document.getElementsByClassName('overlay');
element4[0].style.display = 'none';
'''
driver.execute_script(js_script)
The above works but as you can see there is a repetition of code. Is there a way I can simplify this rather than finding each element and hiding them?
[...document.querySelectorAll("[class^=class]")].forEach(ele => ele.style.display = "none");