简体   繁体   中英

Selenium changing html on a page with python

<div id="modalContent" style="opacity: 1; top: 35%;">
            </div>

Say I want to delete this on everytime I go to a particular website.

driver = webdriver.Chrome()
driver.get("some url")
#driver.removeelement("""<div id="modalContent" style="opacity: 1; top: 35%;">
        #</div>""")

Is there a way to do this?

To do this, you should execute some javascript on the DOM element. Here is how I would do it.

driver.execute_script("document.getElementById('modalContent').remove()")

Should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM