Search code examples
pythonseleniumselenium-webdriverwebautomation

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>

how do I switch to this frame in python selenium

I watched some tutorial on youtube and after using control F in elements this iframe is number 10 out of 12 iframes


Solution

  • In case there are more then one identical frames you can select required frame by index:

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