如何在 python selenium 中使用 Iframes?

How to use Iframes in python selenium?

<iframe ng-repeat="contentFrame in contentFrames" src="/PrivateArea/MDL_Action/Default.aspx?rid=241&amp;ifrsafe=1" class="tg_pageFrame ng-scope ng-isolate-scope" iframe-onload="contentFrame.pageNavigated()"></iframe>

如何在 python selenium

中切换到此框架

我在 youtube 上看了一些教程,在元素中使用控件 F 后,这个 iframe 在 12 个 iframe 中排名第 10

如果有不止一个相同的帧,您可以 select 按索引要求的帧:

iframe = driver.find_elements_by_tag_name('iframe')[9]
driver.switch_to.frame(iframe)