I noticed there are only questions like how to access iframe inside a shadow dom, that can not solve my problem i think...
So the target page is like this(normal Cloudflare human verification that you can see everywhere):
<div>
#shadow-root (closed) <!--(1)-->
<iframe>
#shadow-root (closed) <!--(2)-->
</iframe>
</div>
I used selenium's cdp js evaluation work around the (1) #shadow-root, but the cdp just don't work for the (2) one, my python code:
def inject_shadow_open():
driver.execute_cdp_cmd('Page.addScriptToEvaluateOnNewDocument', {'source': """
if (!Element.prototype.__attachShadow) {
Element.prototype.__attachShadow = Element.prototype.attachShadow;
Element.prototype.attachShadow = function(config) {
return this.__attachShadow({ ...config, mode: "open" });
};
}
"""})
driver.execute_script("""
try {
delete Element.prototype.attachShadow;
Element.prototype.attachShadow = function(config) {
return this.__attachShadow({ ...config, mode: "open" });
};
} catch(e) { console.log('Injection already exists') }
""")
What should I do next?