Srk*_*rki 6 python selenium selenium-chromedriver selenium-webdriver shadow-dom
我正在尝试单击#shadow-root (closed)iframe 内的按钮
<iframe title="recaptcha challenge expires in two minutes"
<div class="button-holder help-button-holder">
#shadow-root (closed)
<link rel="stylesheet" href="chrome-extension://mpbjkejclgfgadiemmefgebjfooflfhl/src/solve/solver-button.css">
<button tabindex="0" title="Solve the challenge" id="solver-button"></button>
</div>
</iframe>
Run Code Online (Sandbox Code Playgroud)
这就是我用来切换到 iframe 的方法
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@title='recaptcha challenge expires in two minutes']")))
Run Code Online (Sandbox Code Playgroud)
我怎样才能点击//button[@id="solver-button"]
这是它的真实外观的照片
iframe-链接
按钮链接
您切换到的代码行<iframe>非常完美。但是,所需的元素位于#shadow-root(封闭)内,并且使用Selenium您将无法与#shadow-root(封闭)内的元素进行交互,因为根据Shadow DOM 遍历支持中的讨论:
| 归档时间: |
|
| 查看次数: |
4526 次 |
| 最近记录: |