无法使用Selenium查看区段标记内的数据

2024-10-06 09:55:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图数一数一页上有多少个按钮。然后再按一下。然而,要访问这些按钮,我必须经过一个iframe、一些通用(div)层和一个区域(section)层

我可以使用

driver.switch_to.frame("iframeID")

但是我不知道如何访问secion层中的元素

html如下所示:

<iframe id="iframeID" resize="" src="about:blank;" seamless="" scrolling="no" allowfullscreen="" style="height: 2135px;" xpath="1">
   #document
   <!document>
      <html>
         <head>...</head>
         <body>
            <section class="sectionC">
               <div class="divC">
                  <button type="button" class="buttonC" data-id="1234" style="">Done</button>
                </div>
            </section>
         </body>
      </html>
</iframe>

Tags: divid区域stylehtmldriversectionbody