如何使用Selenium和Python点击#shadow-root(关闭)内的按钮

3 人关注

我正在尝试点击 #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>
</iframe>

这是我用来切换到iframe的方法

WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@title='recaptcha challenge expires in two minutes']")))

How can I click //button[@id="solver-button"]

以下是它的真实面貌的照片

如图link

button-link

1 个评论
我也面临同样的情况!最后,我不得不直接到父 div 去点击。然后它就对我有用了。
python
selenium
selenium-webdriver
selenium-chromedriver
shadow-dom
Srki
Srki
发布于 2022-02-27
1 个回答
undetected Selenium
undetected Selenium
发布于 2022-02-28
0 人赞同