to set MutationObserver, How to inject javascript before page-loading using Selenium
问题 I'm trying to set MutationObserver for observing page mutation while loading. In order to do that, MutationObserver should be configured before page loading. With selenium-chromedriver, couldn't find the way to inject JS for such purpose. I know chrome extension can do that but extensions won't work on headless mode. That's the problem. 回答1: It's possible via the DevTool API by calling Page.addScriptToEvaluateOnNewDocument from selenium import webdriver from selenium.webdriver.remote